From c057dbfb2cc43c48c8522c08cb861ee48d17e723 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= Date: Mon, 20 Apr 2020 11:54:27 +0300 Subject: [PATCH] Cleanup. --- hc/payments/models.py | 15 +++++++++++++++ templates/accounts/billing.html | 10 +++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/hc/payments/models.py b/hc/payments/models.py index d546eec4..c8972582 100644 --- a/hc/payments/models.py +++ b/hc/payments/models.py @@ -70,6 +70,21 @@ class Subscription(models.Model): self._pm = braintree.PaymentMethod.find(o.payment_method_token) return self._pm + @property + def is_supporter(self): + return self.plan_id in ("S5", "S48") + + @property + def is_business(self): + return self.plan_id in ("P20", "Y192") + + @property + def is_business_plus(self): + return self.plan_id in ("P80", "Y768") + + def is_annual(self): + return self.plan_id in ("S48", "Y192", "Y768") + def _get_braintree_subscription(self): if not hasattr(self, "_sub"): self._sub = braintree.Subscription.find(self.subscription_id) diff --git a/templates/accounts/billing.html b/templates/accounts/billing.html index 672d79d2..f665bb44 100644 --- a/templates/accounts/billing.html +++ b/templates/accounts/billing.html @@ -192,7 +192,7 @@
-
+
Selected Plan

Supporter

@@ -208,7 +208,7 @@
-
+
Selected Plan

Business

@@ -224,7 +224,7 @@
-
+
Selected Plan

Business Plus

@@ -251,7 +251,7 @@ type="radio" name="billing_period" value="monthly" - {% if sub.plan_id == "Y192" or sub.plan_id == "Y768" %}{% else %}checked{% endif %}> + {% if not sub.is_annual %}checked{% endif %}> Monthly @@ -261,7 +261,7 @@ type="radio" name="billing_period" value="annual" - {% if sub.plan_id == "Y192" or sub.plan_id == "Y768" %} checked {% endif %}> + {% if sub.is_annual %} checked {% endif %}> Annual, 20% off