X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/5fb53c16b8de6efee032dea734dd9047f33d3d54..df60910b2d457f031cbe0a153e51e7378c0165d8:/src/pz/models.py diff --git a/src/pz/models.py b/src/pz/models.py index 1a77217b9..87e25fc0e 100644 --- a/src/pz/models.py +++ b/src/pz/models.py @@ -1,3 +1,4 @@ +import re from django.db import models from django.utils.timezone import now from django.utils.translation import ugettext_lazy as _ @@ -56,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) @@ -63,20 +65,28 @@ class DirectDebit(models.Model): notes = models.TextField(_('notes'), blank=True) needs_redo = models.BooleanField(_('needs redo'), default=False) - is_cancelled = models.BooleanField(_('is cancelled'), default=False) + cancelled_at = models.DateTimeField(_('cancelled at'), null=True, blank=True) optout = models.BooleanField(_('optout'), default=False) 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