mirror of
https://github.com/ae-utbm/sith.git
synced 2024-12-24 16:51:17 +00:00
23 lines
753 B
Python
23 lines
753 B
Python
|
from typing import Annotated
|
||
|
|
||
|
from annotated_types import MinLen
|
||
|
from ninja_extra import ControllerBase, api_controller, paginate, route
|
||
|
from ninja_extra.pagination import PageNumberPaginationExtra
|
||
|
from ninja_extra.schemas import PaginatedResponseSchema
|
||
|
|
||
|
from club.models import Club
|
||
|
from club.schemas import ClubSchema
|
||
|
from core.api_permissions import CanAccessLookup
|
||
|
|
||
|
|
||
|
@api_controller("/club")
|
||
|
class ClubController(ControllerBase):
|
||
|
@route.get(
|
||
|
"/search",
|
||
|
response=PaginatedResponseSchema[ClubSchema],
|
||
|
permissions=[CanAccessLookup],
|
||
|
)
|
||
|
@paginate(PageNumberPaginationExtra, page_size=50)
|
||
|
def search_club(self, search: Annotated[str, MinLen(1)]):
|
||
|
return Club.objects.filter(name__icontains=search).values()
|