mirror of
https://github.com/zulip/zulip.git
synced 2025-11-09 16:37:23 +00:00
models: Add plan_name attribute to CustomerPlan.
This commit is contained in:
@@ -66,6 +66,15 @@ class CustomerPlan(models.Model):
|
|||||||
|
|
||||||
# TODO maybe override setattr to ensure billing_cycle_anchor, etc are immutable
|
# 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]:
|
def get_current_plan_by_customer(customer: Customer) -> Optional[CustomerPlan]:
|
||||||
return CustomerPlan.objects.filter(
|
return CustomerPlan.objects.filter(
|
||||||
customer=customer, status__lt=CustomerPlan.LIVE_STATUS_THRESHOLD).first()
|
customer=customer, status__lt=CustomerPlan.LIVE_STATUS_THRESHOLD).first()
|
||||||
|
|||||||
@@ -264,10 +264,6 @@ def billing_home(request: HttpRequest) -> HttpResponse:
|
|||||||
if new_plan is not None: # nocoverage
|
if new_plan is not None: # nocoverage
|
||||||
plan = new_plan
|
plan = new_plan
|
||||||
assert(plan is not None) # for mypy
|
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
|
free_trial = plan.status == CustomerPlan.FREE_TRIAL
|
||||||
downgrade_at_end_of_cycle = plan.status == CustomerPlan.DOWNGRADE_AT_END_OF_CYCLE
|
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
|
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'
|
payment_method = 'Billed by invoice'
|
||||||
|
|
||||||
context.update({
|
context.update({
|
||||||
'plan_name': plan_name,
|
'plan_name': plan.name,
|
||||||
'has_active_plan': True,
|
'has_active_plan': True,
|
||||||
'free_trial': free_trial,
|
'free_trial': free_trial,
|
||||||
'downgrade_at_end_of_cycle': downgrade_at_end_of_cycle,
|
'downgrade_at_end_of_cycle': downgrade_at_end_of_cycle,
|
||||||
|
|||||||
Reference in New Issue
Block a user