Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

stripe: Add 'is_sponsored' method to 'BillingSession' class.

Prakhar Pratyush1b17626327bb
diff --git a/corporate/lib/stripe.py b/corporate/lib/stripe.py
index a2a61e7d9e1..3de88c354aa 100644
--- a/corporate/lib/stripe.py
+++ b/corporate/lib/stripe.py
@@ -612,6 +612,10 @@ class BillingSession(ABC):
def approve_sponsorship(self) -> None:
pass
+ @abstractmethod
+ def is_sponsored(self) -> bool:
+ pass
+
@abstractmethod
def is_sponsored_or_pending(self, customer: Optional[Customer]) -> bool:
pass
@@ -1774,11 +1778,13 @@ class RealmBillingSession(BillingSession):
)
internal_send_private_message(notification_bot, user, message)
+ @override
+ def is_sponsored(self) -> bool:
+ return self.realm.plan_type == self.realm.PLAN_TYPE_STANDARD_FREE
+
@override
def is_sponsored_or_pending(self, customer: Optional[Customer]) -> bool:
- if (
- customer is not None and customer.sponsorship_pending
- ) or self.realm.plan_type == self.realm.PLAN_TYPE_STANDARD_FREE:
+ if (customer is not None and customer.sponsorship_pending) or self.is_sponsored():
return True
return False
@@ -1967,11 +1973,13 @@ class RemoteRealmBillingSession(BillingSession): # nocoverage
# TBD
pass
+ @override
+ def is_sponsored(self) -> bool:
+ return self.remote_realm.plan_type == self.remote_realm.PLAN_TYPE_COMMUNITY
+
@override
def is_sponsored_or_pending(self, customer: Optional[Customer]) -> bool:
- if (
- customer is not None and customer.sponsorship_pending
- ) or self.remote_realm.plan_type == self.remote_realm.PLAN_TYPE_COMMUNITY:
+ if (customer is not None and customer.sponsorship_pending) or self.is_sponsored():
return True
return False
@@ -2171,6 +2179,10 @@ class RemoteServerBillingSession(BillingSession): # nocoverage
plan.status = CustomerPlan.ENDED
plan.save(update_fields=["status"])
+ @override
+ def is_sponsored(self) -> bool:
+ return self.remote_server.plan_type == self.remote_server.PLAN_TYPE_COMMUNITY
+
@override
def is_sponsored_or_pending(self, customer: Optional[Customer]) -> bool:
# TBD