Pridani sentry, fix mazani upravenych fotek
This commit is contained in:
+7
-1
@@ -2,9 +2,15 @@ import os
|
||||
|
||||
APP_DEBUG = True
|
||||
GRAPHIQL = True
|
||||
|
||||
ACCESS_TOKEN_VALIDITY_MINUTES = 20
|
||||
REFRESH_TOKEN_VALIDITY_DAYS = 30
|
||||
|
||||
API_URL = os.environ.get("API_URL") or "http://localhost:8000"
|
||||
APP_SECRET_KEY = os.environ.get("APP_SECRET_KEY") or "test"
|
||||
ALLOW_CORS_ORIGINS = os.environ.get("ALLOW_CORS_ORIGINS", "").split()
|
||||
SENTRY_DSN = os.environ.get("SENTRY_DSN")
|
||||
|
||||
APP_SECRET_KEY = os.environ.get("APP_SECRET_KEY") or "test"
|
||||
|
||||
if not APP_SECRET_KEY:
|
||||
raise ValueError("Missing APP_SECRET_KEY!")
|
||||
|
||||
@@ -132,7 +132,7 @@ class Photo(BaseModel):
|
||||
|
||||
flight: Mapped['Flight'] = relationship(foreign_keys=[flight_id])
|
||||
point_of_interest: Mapped['PointOfInterest'] = relationship()
|
||||
adjustment: Mapped['PhotoAdjustment'] = relationship()
|
||||
adjustment: Mapped['PhotoAdjustment'] = relationship(passive_deletes=True)
|
||||
created_by: Mapped['User'] = relationship()
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ class PhotoAdjustment(BaseModel):
|
||||
__tablename__ = "photo_adjustment"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
photo_id: Mapped[int] = mapped_column(Integer, ForeignKey('photo.id'), nullable=False)
|
||||
photo_id: Mapped[int] = mapped_column(Integer, ForeignKey('photo.id', ondelete='CASCADE'), nullable=False)
|
||||
rotate: Mapped[float] = mapped_column(Float, nullable=True)
|
||||
contrast: Mapped[float] = mapped_column(Float, nullable=True)
|
||||
brightness: Mapped[float] = mapped_column(Float, nullable=True)
|
||||
|
||||
+7
-4
@@ -1,6 +1,6 @@
|
||||
import sentry_sdk
|
||||
from datetime import timedelta
|
||||
from typing import Optional
|
||||
|
||||
from fastapi import FastAPI, APIRouter, Depends, Security
|
||||
from fastapi_jwt import JwtAuthorizationCredentials, JwtAccessBearerCookie, JwtRefreshBearerCookie
|
||||
from sqlalchemy import select
|
||||
@@ -9,7 +9,7 @@ from starlette.middleware.cors import CORSMiddleware
|
||||
from starlette.responses import RedirectResponse, Response
|
||||
from starlette.staticfiles import StaticFiles
|
||||
from strawberry.fastapi import GraphQLRouter
|
||||
from config import APP_SECRET_KEY, GRAPHIQL, APP_DEBUG, ALLOW_CORS_ORIGINS
|
||||
from config import APP_SECRET_KEY, GRAPHIQL, APP_DEBUG, ALLOW_CORS_ORIGINS, SENTRY_DSN, ACCESS_TOKEN_VALIDITY_MINUTES, REFRESH_TOKEN_VALIDITY_DAYS
|
||||
from database import models, async_session
|
||||
from endpoints.login import LoginEndpoint, LoginInput, RefreshEndpoint, LogoutEndpoint
|
||||
from endpoints.photo_editor_preview import PhotoEditorEndpoint
|
||||
@@ -22,15 +22,18 @@ class App:
|
||||
access_security = JwtAccessBearerCookie(
|
||||
secret_key=APP_SECRET_KEY,
|
||||
auto_error=False,
|
||||
access_expires_delta=timedelta(minutes=20),
|
||||
access_expires_delta=timedelta(minutes=ACCESS_TOKEN_VALIDITY_MINUTES),
|
||||
)
|
||||
refresh_security = JwtRefreshBearerCookie(
|
||||
secret_key=APP_SECRET_KEY,
|
||||
auto_error=True,
|
||||
refresh_expires_delta=timedelta(days=30),
|
||||
refresh_expires_delta=timedelta(days=REFRESH_TOKEN_VALIDITY_DAYS),
|
||||
)
|
||||
|
||||
def create_app(self):
|
||||
if SENTRY_DSN:
|
||||
sentry_sdk.init(dsn=SENTRY_DSN, enable_tracing=True)
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
self.setup_exception_handlers(app)
|
||||
|
||||
@@ -75,6 +75,7 @@ class PhotoEditor:
|
||||
return round(w), round(h)
|
||||
|
||||
def rotate(self, degrees: float, crop_after_rotate: bool = False):
|
||||
degrees *= -1
|
||||
self.img = self.img.rotate(degrees, resample=Image.Resampling.BICUBIC, expand=True)
|
||||
|
||||
if crop_after_rotate:
|
||||
|
||||
Reference in New Issue
Block a user