mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
portico: Fix logic for scheduled upgrade context variables.
Renames context variables used for the pricing model template for when the customer has a current plan that has an upgrade to a new plan tier scheduled. Fixes the "Upgrade scheduled" note that was being shown when an annual fixed-price plan has a subsequent fixed-price plan scheduled to start when the current plan ends. Prep for adding a complimentary access plan for Zulip Cloud.
This commit is contained in:
committed by
Tim Abbott
parent
5f8959397b
commit
9fdaa9de0c
@@ -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.
|
||||
|
@@ -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>
|
||||
|
Reference in New Issue
Block a user