-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from nebulabroadcast/develop
Nebula 6.0.1
- Loading branch information
Showing
25 changed files
with
704 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import nebula | ||
|
||
from fastapi import Query | ||
from server.session import SessionModel, Session | ||
from server.dependencies import CurrentUser | ||
from server.request import APIRequest | ||
from server.models import RequestModel | ||
|
||
class SessionsRequest(RequestModel): | ||
id_user: int = Query(..., example=1) | ||
|
||
|
||
class Sessions(APIRequest): | ||
name = "sessions" | ||
title = "List sessions" | ||
response_model = list[SessionModel] | ||
|
||
async def handle( | ||
self, | ||
request: SessionsRequest, | ||
user: CurrentUser, | ||
) -> list[SessionModel]: | ||
"""Create or update an object.""" | ||
|
||
id_user = request.id_user | ||
|
||
if id_user != user.id and (not user.is_admin): | ||
raise nebula.ForbiddenException() | ||
|
||
result = [] | ||
async for session in Session.list(): | ||
|
||
if (id_user is not None) and (id_user != session.user["id"]): | ||
continue | ||
|
||
if (not user.is_admin) and (id_user != session.user["id"]): | ||
continue | ||
|
||
result.append(session) | ||
|
||
return result |
Oops, something went wrong.