fix(filters): refine filter logic in TopupFilter to ensure only unpaid topups are considered for expiration check 🐛
This commit is contained in:
+3
-2
@@ -43,9 +43,10 @@ class TopupFilter(django_filters.FilterSet):
|
|||||||
Filter topups based on whether they are expired or not
|
Filter topups based on whether they are expired or not
|
||||||
"""
|
"""
|
||||||
now = timezone.now()
|
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)
|
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))
|
return queryset.filter(Q(expires_at__isnull=True) | Q(expires_at__gte=now))
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|||||||
Reference in New Issue
Block a user