add pos header validation middleware
This commit is contained in:
@@ -331,10 +331,9 @@ class QuotaViewSet(viewsets.ModelViewSet): # noqa
|
||||
# paginate queryset
|
||||
page = self.paginate_queryset(
|
||||
self.queryset.filter(
|
||||
Q(assigned_organizations=organization) |
|
||||
Q(registerer_organization=organization),
|
||||
Q(is_closed=True)
|
||||
)
|
||||
).order_by('-modify_date')
|
||||
)
|
||||
if page is not None:
|
||||
serializer = self.get_serializer(page, many=True)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from django.db.models import Q
|
||||
|
||||
from apps.product.web.api.v1.serializers import quota_distribution_serializers as distribution_serializers
|
||||
from apps.core.pagination import CustomPageNumberPagination
|
||||
from rest_framework.exceptions import APIException
|
||||
from apps.product import models as product_models
|
||||
from rest_framework.response import Response
|
||||
@@ -9,6 +10,8 @@ from rest_framework import viewsets, filters
|
||||
from rest_framework import status
|
||||
from django.db import transaction
|
||||
|
||||
from common.helpers import get_organization_by_user
|
||||
|
||||
|
||||
def trash(queryset, pk): # noqa
|
||||
""" sent object to trash """
|
||||
@@ -30,6 +33,7 @@ class QuotaDistributionViewSet(viewsets.ModelViewSet):
|
||||
serializer_class = distribution_serializers.QuotaDistributionSerializer
|
||||
filter_backends = [filters.SearchFilter]
|
||||
search_fields = ['']
|
||||
CustomPageNumberPagination.page_size = 5
|
||||
|
||||
@transaction.atomic
|
||||
def create(self, request, *args, **kwargs):
|
||||
@@ -68,17 +72,27 @@ class QuotaDistributionViewSet(viewsets.ModelViewSet):
|
||||
|
||||
return Response(serializer.data)
|
||||
|
||||
# @action(
|
||||
# methods=['get'],
|
||||
# url_name='my_distributions',
|
||||
# url_path='my_distributions',
|
||||
# name='my_distributions'
|
||||
# )
|
||||
# def my_distributions(self, request):
|
||||
#
|
||||
# distributions = self.queryset.filter(
|
||||
# Q(assigned_organization='')
|
||||
# )
|
||||
@action(
|
||||
methods=['get'],
|
||||
detail=False,
|
||||
url_name='my_distributions',
|
||||
url_path='my_distributions',
|
||||
name='my_distributions'
|
||||
)
|
||||
def my_distributions(self, request):
|
||||
""" list of my distributions """
|
||||
organization = get_organization_by_user(request.user)
|
||||
|
||||
# paginate queryset
|
||||
page = self.paginate_queryset(
|
||||
self.queryset.filter(
|
||||
Q(assigned_organization=organization) |
|
||||
Q(assigner_organization=organization)
|
||||
).order_by('-modify_date')
|
||||
)
|
||||
if page is not None:
|
||||
serializer = self.get_serializer(page, many=True)
|
||||
return self.get_paginated_response(serializer.data)
|
||||
|
||||
@action(
|
||||
methods=['put'],
|
||||
|
||||
Reference in New Issue
Block a user