mirror of
https://github.com/flibusta-apps/book_library_server.git
synced 2025-12-06 15:15:36 +01:00
Fix
This commit is contained in:
@@ -13,6 +13,7 @@ from app.serializers.author import Author, AuthorBook, TranslatedBook
|
||||
from app.serializers.author_annotation import AuthorAnnotation
|
||||
from app.services.author import AuthorMeiliSearchService, GetRandomAuthorService
|
||||
from app.services.translator import TranslatorMeiliSearchService
|
||||
from app.utils.transformer import dict_transformer
|
||||
|
||||
|
||||
author_router = APIRouter(
|
||||
@@ -31,7 +32,8 @@ async def get_authors():
|
||||
return await paginate(
|
||||
AuthorDB.objects.select_related(SELECT_RELATED_FIELDS).prefetch_related(
|
||||
PREFETCH_RELATED_FIELDS
|
||||
)
|
||||
),
|
||||
transformer=dict_transformer,
|
||||
)
|
||||
|
||||
|
||||
@@ -88,7 +90,8 @@ async def get_author_books(
|
||||
BookDB.objects.prefetch_related(["source"])
|
||||
.select_related(["annotations", "translators", "sequences"])
|
||||
.filter(authors__id=id, lang__in=allowed_langs, is_deleted=False)
|
||||
.order_by("title")
|
||||
.order_by("title"),
|
||||
transformer=dict_transformer,
|
||||
)
|
||||
|
||||
|
||||
@@ -124,7 +127,8 @@ async def get_translated_books(
|
||||
translators__id=id,
|
||||
lang__in=allowed_langs,
|
||||
is_deleted=False,
|
||||
)
|
||||
),
|
||||
transformer=dict_transformer,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ from fastapi_pagination.ext.ormar import paginate
|
||||
from app.depends import check_token
|
||||
from app.models import AuthorAnnotation as AuthorAnnotationDB
|
||||
from app.serializers.author_annotation import AuthorAnnotation
|
||||
from app.utils.transformer import dict_transformer
|
||||
|
||||
|
||||
author_annotation_router = APIRouter(
|
||||
@@ -19,7 +20,7 @@ author_annotation_router = APIRouter(
|
||||
"/", response_model=Page[AuthorAnnotation], dependencies=[Depends(Params)]
|
||||
)
|
||||
async def get_author_annotations():
|
||||
return await paginate(AuthorAnnotationDB.objects)
|
||||
return await paginate(AuthorAnnotationDB.objects, transformer=dict_transformer)
|
||||
|
||||
|
||||
@author_annotation_router.get("/{id}", response_model=AuthorAnnotation)
|
||||
|
||||
@@ -6,6 +6,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
|
||||
from app.utils.transformer import dict_transformer
|
||||
|
||||
|
||||
book_annotation_router = APIRouter(
|
||||
@@ -19,7 +20,7 @@ book_annotation_router = APIRouter(
|
||||
"/", response_model=Page[BookAnnotation], dependencies=[Depends(Params)]
|
||||
)
|
||||
async def get_book_annotations():
|
||||
return await paginate(BookAnnotationDB.objects)
|
||||
return await paginate(BookAnnotationDB.objects, transformer=dict_transformer)
|
||||
|
||||
|
||||
@book_annotation_router.get("/{id}", response_model=BookAnnotation)
|
||||
|
||||
@@ -10,6 +10,7 @@ from app.filters.genre import get_genre_filter
|
||||
from app.models import Genre as GenreDB
|
||||
from app.serializers.genre import Genre
|
||||
from app.services.genre import GenreMeiliSearchService
|
||||
from app.utils.transformer import dict_transformer
|
||||
|
||||
|
||||
genre_router = APIRouter(
|
||||
@@ -25,7 +26,8 @@ async def get_genres(genre_filter: Annotated[dict, Depends(get_genre_filter)]):
|
||||
return await paginate(
|
||||
GenreDB.objects.prefetch_related(PREFETCH_RELATED_FIELDS)
|
||||
.filter(**genre_filter)
|
||||
.order_by("description")
|
||||
.order_by("description"),
|
||||
transformer=dict_transformer,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ from app.models import Sequence as SequenceDB
|
||||
from app.serializers.sequence import Book as SequenceBook
|
||||
from app.serializers.sequence import Sequence
|
||||
from app.services.sequence import GetRandomSequenceService, SequenceMeiliSearchService
|
||||
from app.utils.transformer import dict_transformer
|
||||
|
||||
|
||||
sequence_router = APIRouter(
|
||||
@@ -22,7 +23,7 @@ sequence_router = APIRouter(
|
||||
|
||||
@sequence_router.get("/", response_model=Page[Sequence], dependencies=[Depends(Params)])
|
||||
async def get_sequences():
|
||||
return await paginate(SequenceDB.objects)
|
||||
return await paginate(SequenceDB.objects, transformer=dict_transformer)
|
||||
|
||||
|
||||
@sequence_router.get("/random", response_model=Sequence)
|
||||
@@ -58,7 +59,8 @@ async def get_sequence_books(
|
||||
BookDB.objects.prefetch_related(["source"])
|
||||
.select_related(["annotations", "authors", "translators"])
|
||||
.filter(sequences__id=id, lang__in=allowed_langs, is_deleted=False)
|
||||
.order_by("sequences__booksequences__position")
|
||||
.order_by("sequences__booksequences__position"),
|
||||
transformer=dict_transformer,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ from fastapi_pagination.ext.ormar import paginate
|
||||
from app.depends import check_token
|
||||
from app.models import Source as SourceDB
|
||||
from app.serializers.source import Source
|
||||
from app.utils.transformer import dict_transformer
|
||||
|
||||
|
||||
source_router = APIRouter(
|
||||
@@ -17,4 +18,4 @@ source_router = APIRouter(
|
||||
|
||||
@source_router.get("", response_model=Page[Source], dependencies=[Depends(Params)])
|
||||
async def get_sources():
|
||||
return await paginate(SourceDB.objects)
|
||||
return await paginate(SourceDB.objects, transformer=dict_transformer)
|
||||
|
||||
@@ -6,6 +6,7 @@ from fastapi_pagination.ext.ormar import paginate
|
||||
from app.depends import check_token
|
||||
from app.models import Translation as TranslationDB
|
||||
from app.serializers.translation import Translation
|
||||
from app.utils.transformer import dict_transformer
|
||||
|
||||
|
||||
translation_router = APIRouter(
|
||||
@@ -19,4 +20,7 @@ translation_router = APIRouter(
|
||||
"/", response_model=Page[Translation], dependencies=[Depends(Params)]
|
||||
)
|
||||
async def get_translations():
|
||||
return await paginate(TranslationDB.objects.select_related(["book", "author"]))
|
||||
return await paginate(
|
||||
TranslationDB.objects.select_related(["book", "author"]),
|
||||
transformer=dict_transformer,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user