plans: Show special text for legacy orgs scheduled for upgrade.

This commit is contained in:
Aman Agrawal 2023-12-05 08:55:44 +00:00 committed by Tim Abbott
parent 8d9a7679bc
commit 34730203b3
2 changed files with 22 additions and 2 deletions

View File

@ -74,6 +74,8 @@ class PlansPageContext:
is_new_customer: bool = False
on_free_tier: bool = False
customer_plan: Optional[CustomerPlan] = None
is_legacy_server_with_scheduled_upgrade: bool = False
legacy_server_new_plan: Optional[CustomerPlan] = None
billing_base_url: str = ""
@ -183,6 +185,16 @@ 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:
assert context.customer_plan.end_date is not None
context.legacy_server_new_plan = CustomerPlan.objects.get(
customer=customer,
billing_cycle_anchor=context.customer_plan.end_date,
status=CustomerPlan.NEVER_STARTED,
)
context.is_new_customer = (
not context.on_free_tier and context.customer_plan is None and not context.is_sponsored

View File

@ -188,7 +188,11 @@
</div>
<div class="bottom">
<div class="text-content">
{% if is_self_hosted_realm and on_free_tier and not sponsorship_pending %}
{% if is_legacy_server_with_scheduled_upgrade and legacy_server_new_plan.tier == legacy_server_new_plan.TIER_SELF_HOSTED_BUSINESS %}
<a href="{{ billing_base_url }}/billing/" class="button current-plan-button">
Upgrade is scheduled
</a>
{% elif is_self_hosted_realm and on_free_tier and not sponsorship_pending %}
<a href="{{ billing_base_url }}/sponsorship/" class="button current-plan-button request-sponsorship">
Request sponsorship
</a>
@ -247,7 +251,11 @@
</div>
<div class="bottom">
<div class="text-content">
{% if is_self_hosted_realm and customer_plan and customer_plan.tier == customer_plan.TIER_SELF_HOSTED_ENTERPRISE %}
{% if is_legacy_server_with_scheduled_upgrade and legacy_server_new_plan.tier == legacy_server_new_plan.TIER_SELF_HOSTED_ENTERPRISE %}
<a href="{{ billing_base_url }}/billing/" class="button current-plan-button">
Upgrade is scheduled
</a>
{% elif is_self_hosted_realm and customer_plan and customer_plan.tier == customer_plan.TIER_SELF_HOSTED_ENTERPRISE %}
<a href='{{ billing_base_url }}/billing' class="button current-plan-button" type="button">
<i class="icon current-plan-icon"></i>
Current plan