order permissions
This commit is contained in:
@@ -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.')
|
||||
|
||||
@@ -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}'
|
||||
|
||||
Reference in New Issue
Block a user