Improve template #1
@ -1,9 +1,8 @@
|
|||||||
|
from service.api.dependencies import QueryParams
|
||||||
from service.core.security import verify_password
|
from service.core.security import verify_password
|
||||||
|
from service.crud.user.models import UserPublic, UserRegister
|
||||||
|
from service.crud.utils import order_queryset
|
||||||
from service.database.models import User
|
from service.database.models import User
|
||||||
from ..utils import order_queryset
|
|
||||||
|
|
||||||
from ...api.dependencies import QueryParams
|
|
||||||
from .models import UserPublic, UserRegister
|
|
||||||
|
|
||||||
|
|
||||||
async def authenticate(*, username: str, password: str) -> User | None:
|
async def authenticate(*, username: str, password: str) -> User | None:
|
||||||
|
@ -4,5 +4,7 @@ from service.constants.types import PaginationParams
|
|||||||
|
|
||||||
|
|
||||||
def order_queryset(qs: QuerySet, filters: PaginationParams, default: str) -> QuerySet:
|
def order_queryset(qs: QuerySet, filters: PaginationParams, default: str) -> QuerySet:
|
||||||
ordering = [f for f in filters.order.split(",") if f.split("-")[-1] in qs.fields]
|
ordering = None
|
||||||
|
if filters.order:
|
||||||
|
ordering = [f for f in filters.order.split(",") if f.split("-")[-1] in qs.fields]
|
||||||
return qs.order_by(*(ordering or (default, )))
|
return qs.order_by(*(ordering or (default, )))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user