Aktualizace zavislosti, pridani debrief poznamek
This commit is contained in:
@@ -276,6 +276,7 @@ class Flight(BaseModel):
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
name: Mapped[str] = mapped_column(String(128), nullable=False, server_default="")
|
||||
description: Mapped[str] = mapped_column(Text, nullable=False, server_default="")
|
||||
debriefing_notes: Mapped[str] = mapped_column(Text, nullable=False, server_default="")
|
||||
url_slug: Mapped[str] = mapped_column(String(128), nullable=False, server_default="")
|
||||
event_id: Mapped[int] = mapped_column(Integer, ForeignKey("event.id"), nullable=True)
|
||||
title_photo_id: Mapped[int] = mapped_column(Integer, ForeignKey('photo.id'), nullable=True)
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
class ForgottenPasswordEndpoint():
|
||||
async def on_get(self):
|
||||
pass
|
||||
@@ -2,7 +2,7 @@ import re
|
||||
from fastapi import HTTPException
|
||||
from sqlalchemy import select
|
||||
from typing import Optional
|
||||
from pydantic import BaseModel, root_validator, Field
|
||||
from pydantic import BaseModel, Field, model_validator
|
||||
from database.models import User
|
||||
from database.transaction import get_session
|
||||
from passlib.hash import bcrypt
|
||||
@@ -13,7 +13,7 @@ class RegistrationInput(BaseModel):
|
||||
name: Optional[str]
|
||||
password: str
|
||||
|
||||
@root_validator()
|
||||
@model_validator(mode="before")
|
||||
def validate_email(cls, values):
|
||||
email = values.get("email") or ""
|
||||
|
||||
|
||||
Vendored
-1
@@ -1,6 +1,5 @@
|
||||
from datetime import datetime
|
||||
from typing import List, Dict
|
||||
|
||||
from aiocache import cached
|
||||
from lxml import etree
|
||||
from lxml.etree import _ElementTree
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -12,6 +12,7 @@ from starlette.staticfiles import StaticFiles
|
||||
from strawberry.fastapi import GraphQLRouter
|
||||
from config import APP_SECRET_KEY, GRAPHIQL, APP_DEBUG, ALLOW_CORS_ORIGINS, SENTRY_DSN, REFRESH_TOKEN_VALIDITY_DAYS
|
||||
from database import models, async_session
|
||||
from endpoints.forgotten_password import ForgottenPasswordEndpoint
|
||||
from endpoints.login import LoginEndpoint, LoginInput, RefreshEndpoint, LogoutEndpoint
|
||||
from endpoints.photo_editor_preview import PhotoEditorEndpoint
|
||||
from endpoints.registration import RegistrationInput, RegistrationEndpoint
|
||||
@@ -131,6 +132,10 @@ class App:
|
||||
refresh_token=self.refresh_security
|
||||
).on_post(resp)
|
||||
|
||||
# @self.api_router.get("/forgotten-password")
|
||||
# async def logout(resp: Response):
|
||||
# return await ForgottenPasswordEndpoint().on_get(resp)
|
||||
|
||||
@self.api_router.get("/photo/editor-preview/{photo_id}")
|
||||
async def photo_editor_preview(
|
||||
photo_id: int,
|
||||
|
||||
Reference in New Issue
Block a user