2024-10-19 22:18:53 +00:00
|
|
|
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 accounting.models import ClubAccount, Company
|
|
|
|
from accounting.schemas import ClubAccountSchema, CompanySchema
|
2025-01-10 20:37:12 +00:00
|
|
|
from core.auth.api_permissions import CanAccessLookup
|
2024-10-19 22:18:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
@api_controller("/lookup", permissions=[CanAccessLookup])
|
|
|
|
class AccountingController(ControllerBase):
|
|
|
|
@route.get("/club-account", response=PaginatedResponseSchema[ClubAccountSchema])
|
|
|
|
@paginate(PageNumberPaginationExtra, page_size=50)
|
|
|
|
def search_club_account(self, search: Annotated[str, MinLen(1)]):
|
|
|
|
return ClubAccount.objects.filter(name__icontains=search).values()
|
|
|
|
|
|
|
|
@route.get("/company", response=PaginatedResponseSchema[CompanySchema])
|
|
|
|
@paginate(PageNumberPaginationExtra, page_size=50)
|
|
|
|
def search_company(self, search: Annotated[str, MinLen(1)]):
|
|
|
|
return Company.objects.filter(name__icontains=search).values()
|