Aktualizace zavislosti, pridani debrief poznamek
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
from __future__ import annotations
|
||||
from datetime import datetime
|
||||
from typing import Optional, List
|
||||
from typing import Optional, List, Any
|
||||
import strawberry
|
||||
from graphql import GraphQLError
|
||||
from strawberry.permission import PermissionExtension, BasePermission
|
||||
from strawberry.types import Info
|
||||
|
||||
from database import models
|
||||
from decorators.endpoints import authenticated_user_only
|
||||
from external.gpx_parser import GPXParser
|
||||
@@ -92,8 +96,23 @@ class Photo:
|
||||
)
|
||||
|
||||
|
||||
class IsAuthenticated(BasePermission):
|
||||
message = "User is not authenticated"
|
||||
error_class = GraphQLError
|
||||
error_extensions = {"code": "UNAUTHORIZED"}
|
||||
|
||||
def has_permission(self, source: Any, info: Info, **kwargs) -> bool:
|
||||
return bool(info.context.user_id)
|
||||
|
||||
|
||||
@strawberry_sqlalchemy_type(models.Flight)
|
||||
class Flight:
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__()
|
||||
|
||||
for key, value in kwargs.items():
|
||||
setattr(self, key, value)
|
||||
|
||||
async def load_gpx_track(root):
|
||||
if not root.gpx_track_filename:
|
||||
return None
|
||||
@@ -148,6 +167,11 @@ class Flight:
|
||||
resolver=lambda root: flight_duration_dataloader.load(root.id)
|
||||
)
|
||||
|
||||
debriefing_notes: Optional[str] = strawberry.field(
|
||||
permission_classes=[IsAuthenticated],
|
||||
resolver=lambda root: root.debriefing_notes
|
||||
)
|
||||
|
||||
|
||||
@strawberry_sqlalchemy_type(models.Copilot)
|
||||
class Copilot:
|
||||
|
||||
Reference in New Issue
Block a user