mirror of
https://github.com/flibusta-apps/book_library_server.git
synced 2025-12-06 15:15:36 +01:00
Code clean up
This commit is contained in:
@@ -5,11 +5,7 @@ from fastapi_pagination.ext.ormar import paginate
|
||||
|
||||
from app.depends import check_token
|
||||
from app.models import BookAnnotation as BookAnnotationDB
|
||||
from app.serializers.book_annotation import (
|
||||
BookAnnotation,
|
||||
CreateBookAnnotation,
|
||||
UpdateBookAnnotation,
|
||||
)
|
||||
from app.serializers.book_annotation import BookAnnotation
|
||||
|
||||
|
||||
book_annotation_router = APIRouter(
|
||||
@@ -26,11 +22,6 @@ async def get_book_annotations():
|
||||
return await paginate(BookAnnotationDB.objects)
|
||||
|
||||
|
||||
@book_annotation_router.post("/", response_model=BookAnnotation)
|
||||
async def create_book_annotation(data: CreateBookAnnotation):
|
||||
return await BookAnnotationDB.objects.create(**data.dict())
|
||||
|
||||
|
||||
@book_annotation_router.get("/{id}", response_model=BookAnnotation)
|
||||
async def get_book_annotation(id: int):
|
||||
annotation = await BookAnnotationDB.objects.get_or_none(id=id)
|
||||
@@ -39,15 +30,3 @@ async def get_book_annotation(id: int):
|
||||
raise HTTPException(status.HTTP_404_NOT_FOUND)
|
||||
|
||||
return annotation
|
||||
|
||||
|
||||
@book_annotation_router.put("/{id}", response_model=BookAnnotation)
|
||||
async def update_book_annotation(id: int, data: UpdateBookAnnotation):
|
||||
annotation = await BookAnnotationDB.objects.get_or_none(id=id)
|
||||
|
||||
if annotation is None:
|
||||
raise HTTPException(status.HTTP_404_NOT_FOUND)
|
||||
|
||||
annotation.update_from_dict(data.dict())
|
||||
|
||||
return annotation.save()
|
||||
|
||||
Reference in New Issue
Block a user