stripe: Rename get_legacy_remote_server_next_plan_name.

Rename get_legacy_remote_server_next_plan_name to
get_complimentary_access_next_plan_name, as well as all
associated variables.
This commit is contained in:
Lauryn Menard
2024-12-12 20:56:19 +01:00
committed by Tim Abbott
parent 713bef6ff5
commit b6f8c20772
3 changed files with 17 additions and 13 deletions

View File

@@ -1078,7 +1078,7 @@ class BillingSession(ABC):
status=CustomerPlan.NEVER_STARTED,
)
def get_legacy_remote_server_next_plan_name(self, customer: Customer) -> str | None:
def get_complimentary_access_next_plan_name(self, customer: Customer) -> str | None:
next_plan = self.get_legacy_remote_server_next_plan(customer)
if next_plan is None:
return None
@@ -2550,7 +2550,7 @@ class BillingSession(ABC):
complimentary_access_plan_end_date = self.get_formatted_complimentary_access_plan_end_date(
customer, status=CustomerPlan.SWITCH_PLAN_TIER_AT_PLAN_END
)
legacy_remote_server_next_plan_name = self.get_legacy_remote_server_next_plan_name(customer)
complimentary_access_next_plan_name = self.get_complimentary_access_next_plan_name(customer)
context = {
"plan_name": plan.name,
"has_active_plan": True,
@@ -2581,7 +2581,7 @@ class BillingSession(ABC):
"is_self_hosted_billing": is_self_hosted_billing,
"complimentary_access_plan": complimentary_access_plan_end_date is not None,
"complimentary_access_plan_end_date": complimentary_access_plan_end_date,
"complimentary_access_next_plan_name": legacy_remote_server_next_plan_name,
"complimentary_access_next_plan_name": complimentary_access_next_plan_name,
"using_min_licenses_for_plan": using_min_licenses_for_plan,
"min_licenses_for_plan": min_licenses_for_plan,
"pre_discount_renewal_cents": cents_to_dollar_string(pre_discount_renewal_cents),

View File

@@ -111,10 +111,11 @@ def remote_realm_billing_page(
customer = billing_session.get_customer()
if customer is not None and customer.sponsorship_pending: # nocoverage
# Don't redirect to sponsorship page if the remote realm is on a paid plan or scheduled for an upgrade.
# Don't redirect to sponsorship page if the remote realm is on a paid plan or
# has scheduled an upgrade for their current complimentary access plan.
if (
not billing_session.on_paid_plan()
and billing_session.get_legacy_remote_server_next_plan_name(customer) is None
and billing_session.get_complimentary_access_next_plan_name(customer) is None
):
return HttpResponseRedirect(
reverse("remote_realm_sponsorship_page", args=(realm_uuid,))
@@ -126,7 +127,7 @@ def remote_realm_billing_page(
customer is None
or get_current_plan_by_customer(customer) is None
or (
billing_session.get_legacy_remote_server_next_plan_name(customer) is None
billing_session.get_complimentary_access_next_plan_name(customer) is None
and billing_session.remote_realm.plan_type
in [
RemoteRealm.PLAN_TYPE_SELF_MANAGED,
@@ -178,10 +179,11 @@ def remote_server_billing_page(
customer = billing_session.get_customer()
if customer is not None and customer.sponsorship_pending:
# Don't redirect to sponsorship page if the remote realm is on a paid plan or scheduled for an upgrade.
# Don't redirect to sponsorship page if the remote realm is on a paid plan or
# has scheduled an upgrade for their current complimentary access plan.
if (
not billing_session.on_paid_plan()
and billing_session.get_legacy_remote_server_next_plan_name(customer) is None
and billing_session.get_complimentary_access_next_plan_name(customer) is None
):
return HttpResponseRedirect(
reverse(
@@ -196,7 +198,7 @@ def remote_server_billing_page(
customer is None
or get_current_plan_by_customer(customer) is None
or (
billing_session.get_legacy_remote_server_next_plan_name(customer) is None
billing_session.get_complimentary_access_next_plan_name(customer) is None
and billing_session.remote_server.plan_type
in [
RemoteZulipServer.PLAN_TYPE_SELF_MANAGED,

View File

@@ -336,12 +336,13 @@ def remote_realm_billing_finalize_login(
RemoteRealm.PLAN_TYPE_SELF_MANAGED,
RemoteRealm.PLAN_TYPE_SELF_MANAGED_LEGACY,
]:
# If they have a scheduled upgrade, redirect to billing page.
# If they have a scheduled upgrade while on a complimentary access plan,
# redirect to billing page.
billing_session = RemoteRealmBillingSession(remote_realm)
customer = billing_session.get_customer()
if (
customer is not None
and billing_session.get_legacy_remote_server_next_plan_name(customer) is not None
and billing_session.get_complimentary_access_next_plan_name(customer) is not None
):
return HttpResponseRedirect(
reverse("remote_realm_billing_page", args=(remote_realm_uuid,))
@@ -784,12 +785,13 @@ def remote_billing_legacy_server_from_login_confirmation_link(
RemoteZulipServer.PLAN_TYPE_SELF_MANAGED,
RemoteZulipServer.PLAN_TYPE_SELF_MANAGED_LEGACY,
]:
# If they have a scheduled upgrade, redirect to billing page.
# If they have a scheduled upgrade while on a complimentary access plan,
# redirect to billing page.
billing_session = RemoteServerBillingSession(remote_server)
customer = billing_session.get_customer()
if (
customer is not None
and billing_session.get_legacy_remote_server_next_plan_name(customer) is not None
and billing_session.get_complimentary_access_next_plan_name(customer) is not None
):
return HttpResponseRedirect(
reverse("remote_server_billing_page", args=(remote_server_uuid,))