X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/39328e6050c1fb8f0f66d2688f82b72b40ac175a..165161a173154072eb7b999386a13562e110bd0a:/src/pz/admin.py?ds=inline diff --git a/src/pz/admin.py b/src/pz/admin.py index 1373a5687..23ad9c249 100644 --- a/src/pz/admin.py +++ b/src/pz/admin.py @@ -1,5 +1,5 @@ from django.contrib import admin -from django.contrib.admin.filters import FieldListFilter +from django.contrib.admin.filters import FieldListFilter, SimpleListFilter from django.contrib import messages from django.db.models import Q from django.shortcuts import get_object_or_404, redirect @@ -50,10 +50,30 @@ class EmptyFieldListFilter(FieldListFilter): } +class PayedListFilter(SimpleListFilter): + title = 'pobrane' + parameter_name = 'payed' + def lookups(self, request, model_admin): + return ( + ('yes', 'tak'), + ('no', 'nie'), + ) + + def queryset(self, request, queryset): + if self.value() == 'yes': + return queryset.filter(payment__is_dd=True, payment__realised=True).distinct() + if self.value() == 'no': + return queryset.exclude(payment__is_dd=True, payment__realised=True).distinct() + + + class BankExportFeedbackLineInline(admin.TabularInline): model = models.BankExportFeedbackLine extra = 0 +class BankPaymentInline(admin.TabularInline): + model = models.Payment + extra = 0 @admin.register(models.DirectDebit) class DirectDebitAdmin(admin.ModelAdmin): @@ -87,6 +107,7 @@ class DirectDebitAdmin(admin.ModelAdmin): 'is_consumer', ('fundraiser_commission', EmptyFieldListFilter), ('fundraiser_bonus', EmptyFieldListFilter), + PayedListFilter, ] fieldsets = [ (None, { @@ -121,7 +142,7 @@ class DirectDebitAdmin(admin.ModelAdmin): }) ] readonly_fields = ['agree_contact', 'iban_valid', 'iban_warning', 'latest_status'] - inlines = [BankExportFeedbackLineInline] + inlines = [BankExportFeedbackLineInline, BankPaymentInline] def set_bank_submission(m, r, q): q.update(bank_submission_date=now()) @@ -155,7 +176,7 @@ class DirectDebitAdmin(admin.ModelAdmin): @admin.register(models.BankExportFeedback) class BankExportFeedbackAdmin(admin.ModelAdmin): - inlines = [BankExportFeedbackLineInline] + inlines = [BankExportFeedbackLineInline, BankPaymentInline]