From: Radek Czajka Date: Thu, 27 Jan 2022 13:06:11 +0000 (+0100) Subject: PZ admin changes X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/39328e6050c1fb8f0f66d2688f82b72b40ac175a?ds=sidebyside PZ admin changes --- diff --git a/src/pz/admin.py b/src/pz/admin.py index 9687948dc..1373a5687 100644 --- a/src/pz/admin.py +++ b/src/pz/admin.py @@ -60,6 +60,7 @@ class DirectDebitAdmin(admin.ModelAdmin): list_display = [ 'payment_id', 'acquisition_date', 'iban_valid', + 'latest_status', 'bank_submission_date', 'bank_acceptance_date', 'amount', 'first_name', 'last_name', @@ -78,11 +79,14 @@ class DirectDebitAdmin(admin.ModelAdmin): 'fundraiser', 'campaign', ('cancelled_at', EmptyFieldListFilter), + 'latest_status', 'needs_redo', 'optout', 'amount', 'sex', 'is_consumer', + ('fundraiser_commission', EmptyFieldListFilter), + ('fundraiser_bonus', EmptyFieldListFilter), ] fieldsets = [ (None, { @@ -94,7 +98,7 @@ class DirectDebitAdmin(admin.ModelAdmin): ('postal_code', 'phone'), 'email', ('iban', 'iban_valid', 'iban_warning'), - 'payment_id', + ('payment_id', 'latest_status'), 'agree_contact', 'agree_fundraising', 'agree_newsletter', @@ -108,6 +112,7 @@ class DirectDebitAdmin(admin.ModelAdmin): ('cancelled_at', 'needs_redo', 'optout'), 'submission_date', 'fundraiser_commission', + 'fundraiser_bonus', 'fundraiser_bill', 'bank_submission_date', 'bank_acceptance_date', @@ -115,7 +120,7 @@ class DirectDebitAdmin(admin.ModelAdmin): ] }) ] - readonly_fields = ['agree_contact', 'iban_valid', 'iban_warning'] + readonly_fields = ['agree_contact', 'iban_valid', 'iban_warning', 'latest_status'] inlines = [BankExportFeedbackLineInline] def set_bank_submission(m, r, q): diff --git a/src/pz/migrations/0010_auto_20220127_1359.py b/src/pz/migrations/0010_auto_20220127_1359.py new file mode 100644 index 000000000..c0310b7e6 --- /dev/null +++ b/src/pz/migrations/0010_auto_20220127_1359.py @@ -0,0 +1,23 @@ +# Generated by Django 2.2.25 on 2022-01-27 12:59 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('pz', '0009_remove_directdebit_is_cancelled'), + ] + + operations = [ + migrations.AddField( + model_name='directdebit', + name='fundraiser_bonus', + field=models.IntegerField(blank=True, null=True, verbose_name='fundraiser bonus'), + ), + migrations.AddField( + model_name='directdebit', + name='latest_status', + field=models.CharField(blank=True, max_length=255), + ), + ] diff --git a/src/pz/models.py b/src/pz/models.py index 45e6c6208..87e25fc0e 100644 --- a/src/pz/models.py +++ b/src/pz/models.py @@ -57,6 +57,7 @@ class DirectDebit(models.Model): fundraiser = models.ForeignKey(Fundraiser, models.PROTECT, blank=True, null=True, verbose_name=_('fundraiser')) fundraiser_commission = models.IntegerField(_('fundraiser commission'), null=True, blank=True) + fundraiser_bonus = models.IntegerField(_('fundraiser bonus'), null=True, blank=True) fundraiser_bill = models.CharField(_('fundaiser bill number'), max_length=255, blank=True) amount = models.IntegerField(_('amount'), null=True, blank=True) @@ -69,15 +70,23 @@ class DirectDebit(models.Model): campaign = models.ForeignKey(Campaign, models.PROTECT, null=True, blank=True, verbose_name=_('campaign')) + latest_status = models.CharField(max_length=255, blank=True) + class Meta: verbose_name = _('direct debit') verbose_name_plural = _('direct debits') def __str__(self): - return self.payment_id + return "{} {}".format(self.payment_id, self.latest_status) + + def get_latest_status(self): + line = self.bankexportfeedbackline_set.order_by('-feedback__created_at').first() + if line is None: return "" + return line.comment def save(self, **kwargs): self.iban_valid = not self.iban_warning() if self.iban else None + self.latest_status = self.get_latest_status() super().save(**kwargs) @classmethod