deploy product & quota base system

This commit is contained in:
2025-06-09 16:09:50 +03:30
parent fa9c7dfaf8
commit 5f440c52bd
8 changed files with 562 additions and 107 deletions

View File

@@ -57,42 +57,6 @@ class ProductViewSet(viewsets.ModelViewSet):
return Response(e, status=status.HTTP_204_NO_CONTENT)
class ReferenceProductViewSet(viewsets.ModelViewSet):
queryset = product_models.ReferenceProduct.objects.all()
serializer_class = product_serializers.ReferenceProductSerializer
@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 AttributeViewSet(viewsets.ModelViewSet):
""" attributes of reference product """
@@ -243,3 +207,193 @@ class SaleUnitViewSet(viewsets.ModelViewSet):
return Response(status=status.HTTP_200_OK)
except APIException as e:
return Response(e, status=status.HTTP_204_NO_CONTENT)
class IncentivePlanViewSet(viewsets.ModelViewSet):
""" apis for incentive plan """
queryset = product_models.IncentivePlan.objects.all()
serializer_class = product_serializers.IncentivePlanSerializer
@action(
methods=['put'],
detail=True,
url_path='trash',
url_name='trash',
name='trash',
)
@transaction.atomic
def trash(self, request, pk=None):
""" Sent incentive plan 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 incentive plan 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 QuotaViewSet(viewsets.ModelViewSet):
""" apis for product quota """
queryset = product_models.Quota.objects.all()
serializer_class = product_serializers.QuotaSerializer
@action(
methods=['put'],
detail=True,
url_path='trash',
url_name='trash',
name='trash',
)
@transaction.atomic
def trash(self, request, pk=None):
""" Sent quota 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 quota 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 QuotaIncentiveAssignmentViewSet(viewsets.ModelViewSet):
""" apis for incentive assignment """
queryset = product_models.QuotaIncentiveAssignment.objects.all()
serializer_class = product_serializers.QuotaIncentiveAssignmentSerializer
@action(
methods=['put'],
detail=True,
url_path='trash',
url_name='trash',
name='trash',
)
@transaction.atomic
def trash(self, request, pk=None):
""" Sent quota incentive assignment 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 quota incentive assignment 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 QuotaBrokerValueViewSet(viewsets.ModelViewSet): # noqa
""" apis for quota broker value """
queryset = product_models.QuotaBrokerValue.objects.all()
serializer_class = product_serializers.QuotaBrokerValueSerializer
@action(
methods=['put'],
detail=True,
url_path='trash',
url_name='trash',
name='trash',
)
@transaction.atomic
def trash(self, request, pk=None):
""" Sent quota broker value 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 quota broker value 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 QuotaLiveStockAllocationViewSet(viewsets.ModelViewSet):
""" apis for quota livestock allocation """
queryset = product_models.QuotaLivestockAllocation.objects.all()
serializer_class = product_serializers.QuotaLiveStockAllocationSerializer
@action(
methods=['put'],
detail=True,
url_path='trash',
url_name='trash',
name='trash',
)
@transaction.atomic
def trash(self, request, pk=None):
""" Sent quota livestock allocation 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 quota livestock allocation 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)