Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
billing: Make support_session an explicit parameter.
Tim Abbottefa423395f71
diff --git a/corporate/lib/stripe.py b/corporate/lib/stripe.pyindex 1ea407ad4be..c5db97ae187 100644--- a/corporate/lib/stripe.py+++ b/corporate/lib/stripe.py@@ -1266,20 +1266,27 @@ class BillingSession(ABC):class RealmBillingSession(BillingSession):- def __init__(self, user: Optional[UserProfile] = None, realm: Optional[Realm] = None) -> None:+ def __init__(+ self,+ user: Optional[UserProfile] = None,+ realm: Optional[Realm] = None,+ *,+ support_session: bool = False,+ ) -> None:self.user = userassert user is not None or realm is not None+ if support_session:+ assert user is not None and user.is_staff+ self.support_session = support_session+if user is not None and realm is not None:- assert user.is_staff+ assert user.is_staff or user.realm == realmself.realm = realm- self.support_session = Trueelif user is not None:self.realm = user.realm- self.support_session = Falseelse:assert realm is not None # for mypyself.realm = realm- self.support_session = False@override@propertydiff --git a/corporate/lib/support.py b/corporate/lib/support.pyindex 08113e88758..087eb37b195 100644--- a/corporate/lib/support.py+++ b/corporate/lib/support.py@@ -27,24 +27,24 @@ def get_discount_for_realm(realm: Realm) -> Optional[Decimal]:def attach_discount_to_realm(realm: Realm, discount: Decimal, *, acting_user: UserProfile) -> None:- billing_session = RealmBillingSession(acting_user, realm)+ billing_session = RealmBillingSession(acting_user, realm, support_session=True)billing_session.attach_discount_to_customer(discount)def approve_realm_sponsorship(realm: Realm, *, acting_user: UserProfile) -> None:- billing_session = RealmBillingSession(acting_user, realm)+ billing_session = RealmBillingSession(acting_user, realm, support_session=True)billing_session.approve_sponsorship()def update_realm_sponsorship_status(realm: Realm, sponsorship_pending: bool, *, acting_user: UserProfile) -> None:- billing_session = RealmBillingSession(acting_user, realm)+ billing_session = RealmBillingSession(acting_user, realm, support_session=True)billing_session.update_customer_sponsorship_status(sponsorship_pending)def update_realm_billing_method(realm: Realm, charge_automatically: bool, *, acting_user: UserProfile) -> None:- billing_session = RealmBillingSession(acting_user, realm)+ billing_session = RealmBillingSession(acting_user, realm, support_session=True)billing_session.update_billing_method_of_current_plan(charge_automatically)