Browse Source

correction du filtre des paiements actifs

Élie Bouttier 7 years ago
parent
commit
3d5aa273f4
1 changed files with 4 additions and 4 deletions
  1. 4 4
      banking/admin.py

+ 4 - 4
banking/admin.py

@@ -41,10 +41,10 @@ class PaymentStatusFilter(admin.SimpleListFilter):
         )
 
     def queryset(self, request, queryset):
-        # FIXME ne marche pas, les STOP sont inclus
-        actives = PaymentUpdate.objects.filter(validated=True).order_by('payment', '-start') \
-                        .distinct('payment').exclude(payment_method=PaymentUpdate.STOP) \
-                        .values_list('payment__pk', flat=True)
+        payments = PaymentUpdate.objects.filter(validated=True).order_by('payment', '-start')\
+                        .distinct('payment').values('payment_method', 'payment__pk')
+        actives = filter(lambda p: p['payment_method'] != PaymentUpdate.STOP, payments)
+        actives = map(lambda p: p['payment__pk'], actives)
         if self.value() == '0':
             return queryset.exclude(pk__in=actives)
         if self.value() == '1':