X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/fbe0f421e3eef997ed79a0d8d8443bf84ae205b3..da1171ae5f512c20c68a0616b3157ae9927a6f1f:/src/club/models.py?ds=sidebyside diff --git a/src/club/models.py b/src/club/models.py index 98b4ee00e..8fe3e4798 100644 --- a/src/club/models.py +++ b/src/club/models.py @@ -69,6 +69,15 @@ class Club(models.Model): c[f'{tag}_wide_spot'] = wide_spot return c + def get_description_for_amount(self, amount, monthly): + amounts = self.monthlyamount_set if monthly else self.singleamount_set + amount = amounts.all().filter(amount__lte=amount).last() + return amount.description if amount is not None else '' + + @property + def paypal_enabled(self): + print("ENABLED?", settings.PAYPAL_ENABLED) + return settings.PAYPAL_ENABLED class SingleAmount(models.Model): @@ -146,6 +155,10 @@ class Schedule(models.Model): super(Schedule, self).save(*args, **kwargs) self.update_contact() + def get_description(self): + club = Club.objects.first() + return club.get_description_for_amount(self.amount, self.monthly) + def initiate_payment(self, request): return self.get_payment_method().initiate(request, self)