diff --git a/corporate/models.py b/corporate/models.py index 4d065ab0bc..ec36259a6e 100644 --- a/corporate/models.py +++ b/corporate/models.py @@ -66,6 +66,15 @@ class CustomerPlan(models.Model): # TODO maybe override setattr to ensure billing_cycle_anchor, etc are immutable + @property + def name(self) -> str: + return { + CustomerPlan.STANDARD: 'Zulip Standard', + CustomerPlan.PLUS: 'Zulip Plus', + CustomerPlan.ENTERPRISE: 'Zulip Enterprise', + }[self.tier] + + def get_current_plan_by_customer(customer: Customer) -> Optional[CustomerPlan]: return CustomerPlan.objects.filter( customer=customer, status__lt=CustomerPlan.LIVE_STATUS_THRESHOLD).first() diff --git a/corporate/views.py b/corporate/views.py index 5972344b69..b523da7107 100644 --- a/corporate/views.py +++ b/corporate/views.py @@ -264,10 +264,6 @@ def billing_home(request: HttpRequest) -> HttpResponse: if new_plan is not None: # nocoverage plan = new_plan assert(plan is not None) # for mypy - plan_name = { - CustomerPlan.STANDARD: 'Zulip Standard', - CustomerPlan.PLUS: 'Zulip Plus', - }[plan.tier] free_trial = plan.status == CustomerPlan.FREE_TRIAL downgrade_at_end_of_cycle = plan.status == CustomerPlan.DOWNGRADE_AT_END_OF_CYCLE switch_to_annual_at_end_of_cycle = plan.status == CustomerPlan.SWITCH_TO_ANNUAL_AT_END_OF_CYCLE @@ -284,7 +280,7 @@ def billing_home(request: HttpRequest) -> HttpResponse: payment_method = 'Billed by invoice' context.update({ - 'plan_name': plan_name, + 'plan_name': plan.name, 'has_active_plan': True, 'free_trial': free_trial, 'downgrade_at_end_of_cycle': downgrade_at_end_of_cycle,