diff --git a/apps/authorization/api/v1/api.py b/apps/authorization/api/v1/api.py index dc07080..bfcce8b 100644 --- a/apps/authorization/api/v1/api.py +++ b/apps/authorization/api/v1/api.py @@ -66,6 +66,17 @@ class PermissionViewSet(viewsets.ModelViewSet): filter_backends = [filters.SearchFilter] search_fields = ['page__name', ] + def list(self, request, *args, **kwargs): + queryset = self.filter_queryset(self.get_queryset().order_by('-create_date')) # noqa + + page = self.paginate_queryset(queryset) + if page is not None: + serializer = self.get_serializer(page, many=True) + return self.get_paginated_response(serializer.data) + + serializer = self.get_serializer(queryset, many=True) + return Response(serializer.data) + def create(self, request, *args, **kwargs): if self.queryset.filter(name=request.data['name'], page_id=request.data['page']).exists(): raise ConflictException('a permission with this page exists.') diff --git a/apps/product/models.py b/apps/product/models.py index a071929..31de30a 100644 --- a/apps/product/models.py +++ b/apps/product/models.py @@ -112,7 +112,16 @@ class Product(BaseModel): quota__is_closed=False ).aggregate(total_entry=models.Sum('warehouse_entry'))['total_entry'] or 0 - return {'quotas_count': quotas_count, 'total_quotas_weight': total_quotas_weight} + data = { + 'quotas_count': quotas_count, + 'total_quotas_weight': total_quotas_weight, + 'total_remaining_quotas_weight': total_remaining_quotas_weight, + 'total_distributed_weight': total_distributed_weight, + 'total_sold': total_sold, + 'total_warehouse_entry': total_warehouse_entry, + } + + return data def __str__(self): return f'name: {self.name} - type: {self.type}'