Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

portico: Fix logic for scheduled upgrade context variables.

Lauryn Menard9fdaa9de0cde
diff --git a/corporate/views/portico.py b/corporate/views/portico.py
index 201c4311174..8c234bb0d38 100644
--- a/corporate/views/portico.py
+++ b/corporate/views/portico.py
@@ -78,8 +78,8 @@ class PlansPageContext:
is_new_customer: bool = False
on_free_tier: bool = False
customer_plan: CustomerPlan | None = None
- is_legacy_server_with_scheduled_upgrade: bool = False
- legacy_server_new_plan: CustomerPlan | None = None
+ has_scheduled_upgrade: bool = False
+ scheduled_upgrade_plan: CustomerPlan | None = None
requested_sponsorship_plan: str | None = None
billing_base_url: str = ""
@@ -123,6 +123,7 @@ def plans_view(request: HttpRequest) -> HttpResponse:
context.on_free_tier = not context.is_sponsored
else:
context.on_free_trial = is_customer_on_free_trial(context.customer_plan)
+ # TODO implement a complimentary access plan/tier for Zulip Cloud.
context.is_new_customer = (
not context.on_free_tier and context.customer_plan is None and not context.is_sponsored
@@ -178,16 +179,19 @@ def remote_realm_plans_page(
and not context.is_sponsored
)
context.on_free_trial = is_customer_on_free_trial(context.customer_plan)
- context.is_legacy_server_with_scheduled_upgrade = (
- context.customer_plan.status == CustomerPlan.SWITCH_PLAN_TIER_AT_PLAN_END
- )
- if context.is_legacy_server_with_scheduled_upgrade:
+ if context.customer_plan.status == CustomerPlan.SWITCH_PLAN_TIER_AT_PLAN_END:
assert context.customer_plan.end_date is not None
- context.legacy_server_new_plan = CustomerPlan.objects.get(
+ context.scheduled_upgrade_plan = CustomerPlan.objects.get(
customer=customer,
billing_cycle_anchor=context.customer_plan.end_date,
status=CustomerPlan.NEVER_STARTED,
)
+ # Fixed-price plan renewals have a CustomerPlan.status of
+ # SWITCH_PLAN_TIER_AT_PLAN_END, so we check to see if there is
+ # a CustomerPlan.tier change for the scheduled upgrade note.
+ context.has_scheduled_upgrade = (
+ context.customer_plan.tier != context.scheduled_upgrade_plan.tier
+ )
if billing_session.customer_plan_exists():
# Free trial is disabled for existing customers.
@@ -243,16 +247,19 @@ def remote_server_plans_page(
CustomerPlan.TIER_SELF_HOSTED_BASE,
)
context.on_free_trial = is_customer_on_free_trial(context.customer_plan)
- context.is_legacy_server_with_scheduled_upgrade = (
- context.customer_plan.status == CustomerPlan.SWITCH_PLAN_TIER_AT_PLAN_END
- )
- if context.is_legacy_server_with_scheduled_upgrade:
+ if context.customer_plan.status == CustomerPlan.SWITCH_PLAN_TIER_AT_PLAN_END:
assert context.customer_plan.end_date is not None
- context.legacy_server_new_plan = CustomerPlan.objects.get(
+ context.scheduled_upgrade_plan = CustomerPlan.objects.get(
customer=customer,
billing_cycle_anchor=context.customer_plan.end_date,
status=CustomerPlan.NEVER_STARTED,
)
+ # Fixed-price plan renewals have a CustomerPlan.status of
+ # SWITCH_PLAN_TIER_AT_PLAN_END, so we check to see if there is
+ # a CustomerPlan.tier change for the scheduled upgrade note.
+ context.has_scheduled_upgrade = (
+ context.customer_plan.tier != context.scheduled_upgrade_plan.tier
+ )
if billing_session.customer_plan_exists():
# Free trial is disabled for existing customers.
diff --git a/templates/corporate/pricing_model.html b/templates/corporate/pricing_model.html
index 40815c815a8..09860e1fb01 100644
--- a/templates/corporate/pricing_model.html
+++ b/templates/corporate/pricing_model.html
@@ -225,7 +225,7 @@
<div class="bottom">
<div class="text-content">
<div class="standard-price-box">
- {% if (is_legacy_server_with_scheduled_upgrade and legacy_server_new_plan.tier == legacy_server_new_plan.TIER_SELF_HOSTED_BASIC)
+ {% if (has_scheduled_upgrade and scheduled_upgrade_plan.tier == scheduled_upgrade_plan.TIER_SELF_HOSTED_BASIC)
or (is_self_hosted_realm and sponsorship_pending and requested_sponsorship_plan == "Basic")
or (is_self_hosted_realm and customer_plan and customer_plan.tier != customer_plan.TIER_SELF_HOSTED_LEGACY)%}
<div class="price"><span class="currency-symbol">$</span>3.50</div>
@@ -246,7 +246,7 @@
</div>
{% endif %}
</div>
- {% if is_legacy_server_with_scheduled_upgrade and legacy_server_new_plan.tier == legacy_server_new_plan.TIER_SELF_HOSTED_BASIC %}
+ {% if has_scheduled_upgrade and scheduled_upgrade_plan.tier == scheduled_upgrade_plan.TIER_SELF_HOSTED_BASIC %}
<a href="{{ billing_base_url }}/billing/" class="button current-plan-button">
Upgrade is scheduled
</a>
@@ -310,7 +310,7 @@
<div class="bottom">
<div class="text-content">
<div class="standard-price-box">
- {% if (is_legacy_server_with_scheduled_upgrade and legacy_server_new_plan.tier == legacy_server_new_plan.TIER_SELF_HOSTED_BUSINESS)
+ {% if (has_scheduled_upgrade and scheduled_upgrade_plan.tier == scheduled_upgrade_plan.TIER_SELF_HOSTED_BUSINESS)
or (is_self_hosted_realm and sponsorship_pending and requested_sponsorship_plan == "Business")
or (is_self_hosted_realm and customer_plan and customer_plan.tier != customer_plan.TIER_SELF_HOSTED_LEGACY)%}
<div class="price"><span class="currency-symbol">$</span>6.67</div>
@@ -333,7 +333,7 @@
</div>
{% endif %}
</div>
- {% if is_legacy_server_with_scheduled_upgrade and legacy_server_new_plan.tier == legacy_server_new_plan.TIER_SELF_HOSTED_BUSINESS %}
+ {% if has_scheduled_upgrade and scheduled_upgrade_plan.tier == scheduled_upgrade_plan.TIER_SELF_HOSTED_BUSINESS %}
<a href="{{ billing_base_url }}/billing/" class="button current-plan-button">
Upgrade is scheduled
</a>
@@ -389,7 +389,7 @@
</div>
<div class="bottom">
<div class="text-content">
- {% if is_legacy_server_with_scheduled_upgrade and legacy_server_new_plan.tier == legacy_server_new_plan.TIER_SELF_HOSTED_ENTERPRISE %}
+ {% if has_scheduled_upgrade and scheduled_upgrade_plan.tier == scheduled_upgrade_plan.TIER_SELF_HOSTED_ENTERPRISE %}
<a href="{{ billing_base_url }}/billing/" class="button current-plan-button">
Upgrade is scheduled
</a>