Skip to content

Commit

Permalink
fix: sort discount-codes by -id
Browse files Browse the repository at this point in the history
  • Loading branch information
AmooHashem committed Jan 10, 2025
1 parent 630fa6a commit b43fdcd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions apps/sale/views/discount_code_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class DiscountCodeViewSet(ModelViewSet):
my_tags = ['payments']
serializer_class = DiscountCodeSerializer
queryset = DiscountCode.objects.all()
queryset = DiscountCode.objects.order_by('-id')
permission_classes = [IsDiscountCodeModifier]

def get_serializer_context(self):
Expand All @@ -24,7 +24,7 @@ def get_serializer_context(self):
@action(detail=False, methods=['GET'])
def program_discount_codes(self, request, pk=None):
program_slug = request.GET.get('program', None)
discount_codes = DiscountCode.objects.filter(
discount_codes = self.get_queryset().filter(
merchandises__program__slug=program_slug).distinct()
return Response(self.serializer_class(discount_codes, many=True).data, status=status.HTTP_200_OK)

Expand Down

0 comments on commit b43fdcd

Please sign in to comment.