X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/357027375ff8867f42ca34bcbfb5a78b5b185fc3..fc0b706f8c7eb67531df0a2acd972412e47c7010:/src/funding/admin.py diff --git a/src/funding/admin.py b/src/funding/admin.py index d70aef66a..a59704dbd 100644 --- a/src/funding/admin.py +++ b/src/funding/admin.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # @@ -21,29 +20,33 @@ class PerkAdmin(admin.ModelAdmin): list_filter = ['offer'] - class PayedFilter(admin.SimpleListFilter): title = _('payment complete') parameter_name = 'payed' + def lookups(self, request, model_admin): return ( ('yes', _('Yes')), ('no', _('No')), ) + def queryset(self, request, queryset): if self.value() == 'yes': return queryset.exclude(payed_at=None) elif self.value() == 'no': return queryset.filter(payed_at=None) + class PerksFilter(admin.SimpleListFilter): title = _('perks') parameter_name = 'perks' + def lookups(self, request, model_admin): return ( ('yes', _('Yes')), ('no', _('No')), ) + def queryset(self, request, queryset): if self.value() == 'yes': return queryset.exclude(perks=None) @@ -58,7 +61,6 @@ class FundingAdmin(admin.ModelAdmin): list_filter = [PayedFilter, 'offer', PerksFilter] - class SpentAdmin(admin.ModelAdmin): model = Spent list_display = ['book', 'amount', 'timestamp']