celery & attributes list by product

This commit is contained in:
2025-07-19 10:41:03 +03:30
parent a6b29ad28d
commit dc1e79c684
7 changed files with 97 additions and 8 deletions

View File

@@ -42,6 +42,7 @@ class QuotaDistributionSerializer(serializers.ModelSerializer):
if quota.is_closed:
raise QuotaClosedException()
# check if assigned organization is in quota limitation
if assigned_organization not in quota.limit_by_organizations.all():
raise QuotaLimitByOrganizationException()

View File

@@ -118,11 +118,26 @@ class ProductViewSet(viewsets.ModelViewSet):
class AttributeViewSet(viewsets.ModelViewSet):
""" attributes of reference product """ #
queryset = product_models.Attribute.objects.all()
queryset = product_models.Attribute.objects.select_related('product').all()
serializer_class = product_serializers.AttributeSerializer
filter_backends = [filters.SearchFilter]
search_fields = ['name']
@action(
methods=['get'],
detail=True,
url_path='by_product',
url_name='by_product',
name='by_product'
)
def get_attributes_by_product(self, request, pk=None):
""" get attributes by product with global ones """
attributes = self.queryset.filter(Q(is_global=True) | Q(product__id=pk))
serializer = self.serializer_class(attributes, many=True)
return Response(serializer.data)
@action(
methods=['put'],
detail=True,