mirror of
https://github.com/i701/sarlink-portal-api.git
synced 2025-07-06 17:53:29 +00:00
fix(filters): refine filter logic in TopupFilter to ensure only unpaid topups are considered for expiration check 🐛
All checks were successful
Build and Push Docker Images / Build and Push Docker Images (push) Successful in 3m45s
All checks were successful
Build and Push Docker Images / Build and Push Docker Images (push) Successful in 3m45s
This commit is contained in:
@ -43,9 +43,10 @@ class TopupFilter(django_filters.FilterSet):
|
||||
Filter topups based on whether they are expired or not
|
||||
"""
|
||||
now = timezone.now()
|
||||
if value: # Filter for expired topups
|
||||
queryset = queryset.filter(paid=False)
|
||||
if value:
|
||||
return queryset.filter(expires_at__isnull=False, expires_at__lt=now)
|
||||
else: # Filter for non-expired topups
|
||||
else:
|
||||
return queryset.filter(Q(expires_at__isnull=True) | Q(expires_at__gte=now))
|
||||
|
||||
class Meta:
|
||||
|
Reference in New Issue
Block a user