upgrade: Provide billing_base_url in page_params.

This makes it cleaner to calculate URLs for the current session type.
This commit is contained in:
Aman Agrawal
2023-12-01 03:18:58 +00:00
committed by Tim Abbott
parent 222077804b
commit bb7b0b6731
4 changed files with 24 additions and 9 deletions

View File

@@ -551,6 +551,7 @@ class UpgradePageParams(TypedDict):
demo_organization_scheduled_deletion_date: Optional[datetime]
monthly_price: int
seat_count: int
billing_base_url: str
class UpgradePageSessionTypeSpecificContext(TypedDict):
@@ -609,6 +610,11 @@ class BillingSession(ABC):
def billing_session_url(self) -> str:
pass
@property
@abstractmethod
def billing_base_url(self) -> str:
pass
@abstractmethod
def support_url(self) -> str:
pass
@@ -1499,6 +1505,7 @@ class BillingSession(ABC):
tier, CustomerPlan.BILLING_SCHEDULE_MONTHLY, percent_off
),
"seat_count": seat_count,
"billing_base_url": self.billing_base_url,
},
"payment_method": current_payment_method,
"plan": "Zulip Cloud Standard",
@@ -2008,6 +2015,11 @@ class RealmBillingSession(BillingSession):
def billing_session_url(self) -> str:
return self.realm.uri
@override
@property
def billing_base_url(self) -> str:
return ""
@override
def support_url(self) -> str:
# TODO: Refactor to not create an import cycle.
@@ -2315,6 +2327,11 @@ class RemoteRealmBillingSession(BillingSession): # nocoverage
def billing_session_url(self) -> str:
return f"{settings.EXTERNAL_URI_SCHEME}{settings.SELF_HOSTING_MANAGEMENT_SUBDOMAIN}.{settings.EXTERNAL_HOST}/realm/{self.remote_realm.uuid}"
@override
@property
def billing_base_url(self) -> str:
return f"/realm/{self.remote_realm.uuid}"
@override
def support_url(self) -> str:
return "TODO:not-implemented"
@@ -2579,6 +2596,11 @@ class RemoteServerBillingSession(BillingSession): # nocoverage
def billing_session_url(self) -> str:
return "TBD"
@override
@property
def billing_base_url(self) -> str:
return f"/server/${self.remote_server.uuid}"
@override
def support_url(self) -> str:
return "TODO:not-implemented"