mirror of https://github.com/zulip/zulip.git
stripe: Add 'is_sponsored' method to 'BillingSession' class.
This prep commit adds a 'is_sponsored' method as we need to explicitly check this in 'event_status' view.
This commit is contained in:
parent
29f77bfd31
commit
1b17626327
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue