Skip to content

Commit

Permalink
implement subscription cancellation
Browse files Browse the repository at this point in the history
  • Loading branch information
odenypeter committed Jun 30, 2024
1 parent 451915c commit c44f42c
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion core/views/subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,24 @@ class SubscriptionViewSet(viewsets.ModelViewSet):
All the subscriptions related actions
"""
queryset = Subscription.objects.filter(cancelled=False).order_by('-create_date')
queryset = Subscription.objects.all()
serializer_class = SubscriptionSerializer
permission_classes = (AllowAny, IsAuthenticated)

def get_queryset(self):
queryset = (
super(SubscriptionViewSet, self)
.get_queryset()
.filter(organization=self.request.user.organization)
)

if int(self.request.query_params.get('cancelled', '0')):
queryset = queryset.filter(cancelled=True)
else:
queryset = queryset.filter(cancelled=False)

return queryset.order_by('-create_date')

def create(self, request, *args, **kwargs):
if settings.STRIPE_SECRET:
stripe.api_key = settings.STRIPE_SECRET
Expand Down

0 comments on commit c44f42c

Please sign in to comment.