search & filter on quota

This commit is contained in:
2025-07-30 10:33:52 +03:30
parent efa8d74266
commit e33bb0cc98
4 changed files with 81 additions and 1 deletions

View File

@@ -1,8 +1,9 @@
from apps.product.web.api.v1.serializers import quota_distribution_serializers
from apps.product.services.services import get_products_in_warehouse
from apps.product.web.api.v1.serializers import quota_serializers
from apps.product.services.search.quota_search import QuotaSearch
from apps.product.exceptions import QuotaExpiredTimeException
from apps.core.pagination import CustomPageNumberPagination
from apps.product.services.services import get_products_in_warehouse
from apps.product.web.api.v1.viewsets import product_api
from common.helpers import get_organization_by_user
from rest_framework.exceptions import APIException
@@ -39,6 +40,23 @@ class QuotaViewSet(viewsets.ModelViewSet): # noqa
CustomPageNumberPagination.page_size = 5
search_fields = ['']
def list(self, request, *args, **kwargs):
""" search & filter quotas or return all """
params = self.request.query_params
query = params.get('search')
start_date = params.get('start')
end_date = params.get('end')
search = QuotaSearch(
query=query,
start_date=start_date,
end_date=end_date
)
serializer = self.serializer_class(search.search(), many=True)
return Response(serializer.data, status=status.HTTP_200_OK)
@transaction.atomic
def create(self, request, *args, **kwargs):
""" custom create quota """