Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ format:
source ./venv/bin/activate && autoflake -r --in-place --remove-all-unused-imports ./calendar_backend
source ./venv/bin/activate && isort ./calendar_backend
source ./venv/bin/activate && black ./calendar_backend
source ./venv/bin/activate && autoflake -r --in-place --remove-all-unused-imports ./tests
source ./venv/bin/activate && isort ./tests
source ./venv/bin/activate && black ./tests
source ./venv/bin/activate && autoflake -r --in-place --remove-all-unused-imports ./migrations
source ./venv/bin/activate && isort ./migrations
source ./venv/bin/activate && black ./migrations

db:
docker run -d -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust --name db-timetable_api postgres:15
Expand Down
2 changes: 1 addition & 1 deletion calendar_backend/routes/lecturer/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


settings = get_settings()
router = APIRouter(prefix="/lecturer/{lecturer_id}", tags=["Lecturer: Comment"])
router = APIRouter(prefix="/lecturer/{lecturer_id}", tags=["Lecturer: Comment"], deprecated=True)


@router.post("/comment/", response_model=CommentLecturer)
Expand Down
2 changes: 1 addition & 1 deletion calendar_backend/routes/lecturer/comment_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from calendar_backend.routes.models import CommentLecturer


router = APIRouter(prefix="/lecturer/{lecturer_id}/comment", tags=["Lecturer: Comment Review"])
router = APIRouter(prefix="/lecturer/{lecturer_id}/comment", tags=["Lecturer: Comment Review"], deprecated=True)


@router.get("/review/", response_model=list[CommentLecturer])
Expand Down
15 changes: 12 additions & 3 deletions calendar_backend/routes/lecturer/photo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from fastapi import APIRouter, File, UploadFile
from auth_lib.fastapi import UnionAuth
from fastapi import APIRouter, Depends, File, UploadFile
from fastapi_sqlalchemy import db

from calendar_backend.exceptions import ObjectNotFound
Expand All @@ -14,7 +15,11 @@


@router.post("/photo", response_model=Photo)
async def upload_photo(lecturer_id: int, photo: UploadFile = File(...)) -> Photo:
async def upload_photo(
lecturer_id: int,
photo: UploadFile = File(...),
_=Depends(UnionAuth(scopes=["timetable.lecturer.photo.create"])),
) -> Photo:
"""Загрузить фотографию преподавателя из локального файла

Пример загрузки файла на питоне
Expand Down Expand Up @@ -50,7 +55,11 @@ async def get_lecturer_photos(lecturer_id: int, limit: int = 10, offset: int = 0


@router.delete("/photo/{id}", response_model=None)
async def delete_photo(id: int, lecturer_id: int) -> None:
async def delete_photo(
id: int,
lecturer_id: int,
_=Depends(UnionAuth(scopes=["timetable.lecturer.photo.delete"])),
) -> None:
photo = DbPhoto.get(id, only_approved=False, session=db.session)
if photo.lecturer_id != lecturer_id:
raise ObjectNotFound(DbPhoto, id)
Expand Down
2 changes: 1 addition & 1 deletion calendar_backend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from functools import lru_cache

from auth_lib.fastapi import UnionAuthSettings
from pydantic import AnyHttpUrl, ConfigDict, DirectoryPath, Json, PostgresDsn
from pydantic import AnyHttpUrl, ConfigDict, DirectoryPath, PostgresDsn
from pydantic_settings import BaseSettings


Expand Down
1 change: 0 additions & 1 deletion migrations/versions/63263ee9e08e_fix_photo_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

"""

import sqlalchemy as sa
from alembic import op


Expand Down