* For anonymous users, show only available gifts
This commit is contained in:
parent
3e8b1f7c66
commit
d22f492df0
|
|
@ -187,11 +187,17 @@ class PromoCodeAPI(mixins.CreateModelMixin, generics.GenericAPIView):
|
||||||
|
|
||||||
|
|
||||||
class GiftAPI(viewsets.ModelViewSet):
|
class GiftAPI(viewsets.ModelViewSet):
|
||||||
queryset = Gift.objects.all()
|
|
||||||
serializer_class = GiftSerializer
|
serializer_class = GiftSerializer
|
||||||
permission_classes = [IsAuthenticated | ReadOnly]
|
permission_classes = [IsAuthenticated | ReadOnly]
|
||||||
filterset_class = GiftFilter
|
filterset_class = GiftFilter
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
if self.request.user.is_authenticated or settings.DISABLE_PERMISSIONS:
|
||||||
|
return Gift.objects.all()
|
||||||
|
|
||||||
|
# For anonymous users, show only available gifts
|
||||||
|
return Gift.objects.filter(available_count__gt=0)
|
||||||
|
|
||||||
|
|
||||||
class StatisticsAPI(viewsets.GenericViewSet):
|
class StatisticsAPI(viewsets.GenericViewSet):
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user