base of product-quota & list cities by province

This commit is contained in:
2025-06-10 12:15:17 +03:30
parent 136f28672f
commit 2482b9bc45
17 changed files with 534 additions and 19 deletions

View File

@@ -21,6 +21,42 @@ def delete(queryset, pk):
obj.delete()
class ProductCategoryViewSet(viewsets.ModelViewSet):
queryset = product_models.ProductCategory.objects.all()
serializer_class = product_serializers.ProductCategorySerializer
@action(
methods=['put'],
detail=True,
url_path='trash',
url_name='trash',
name='trash',
)
@transaction.atomic
def trash(self, request, pk=None):
""" Sent product to trash """
try:
trash(self.queryset, pk)
except APIException as e:
return Response(e, status.HTTP_204_NO_CONTENT)
@action(
methods=['post'],
detail=True,
url_name='delete',
url_path='delete',
name='delete'
)
@transaction.atomic
def delete(self, request, pk=None):
""" Full delete of product object """
try:
delete(self.queryset, pk)
return Response(status=status.HTTP_200_OK)
except APIException as e:
return Response(e, status=status.HTTP_204_NO_CONTENT)
class ProductViewSet(viewsets.ModelViewSet):
queryset = product_models.Product.objects.all()
serializer_class = product_serializers.ProductSerializer
@@ -209,7 +245,7 @@ class SaleUnitViewSet(viewsets.ModelViewSet):
return Response(e, status=status.HTTP_204_NO_CONTENT)
class IncentivePlanViewSet(viewsets.ModelViewSet):
class IncentivePlanViewSet(viewsets.ModelViewSet): # noqa
""" apis for incentive plan """
queryset = product_models.IncentivePlan.objects.all()