Search
[wolnelektury.git] / src / club / models.py
index 98b4ee0..8fe3e47 100644 (file)
@@ -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)