mirror of https://github.com/zulip/zulip.git
corporate: Make is_sponsored_or_pending not abstract in BillingSession.
The logic for BillingSession.is_sponsored_or_pending would be the same for all three child classes of BillingSession, so this should be a method on the BillingSession abstract class.
This commit is contained in:
parent
fbd8ed1425
commit
5eabd51702
|
@ -724,10 +724,6 @@ class BillingSession(ABC):
|
||||||
def is_sponsored(self) -> bool:
|
def is_sponsored(self) -> bool:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def is_sponsored_or_pending(self, customer: Optional[Customer]) -> bool:
|
|
||||||
pass
|
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def get_sponsorship_request_session_specific_context(
|
def get_sponsorship_request_session_specific_context(
|
||||||
self,
|
self,
|
||||||
|
@ -766,6 +762,11 @@ class BillingSession(ABC):
|
||||||
def get_metadata_for_stripe_update_card(self) -> Dict[str, Any]:
|
def get_metadata_for_stripe_update_card(self) -> Dict[str, Any]:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def is_sponsored_or_pending(self, customer: Optional[Customer]) -> bool:
|
||||||
|
if (customer is not None and customer.sponsorship_pending) or self.is_sponsored():
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
@catch_stripe_errors
|
@catch_stripe_errors
|
||||||
def create_stripe_customer(self) -> Customer:
|
def create_stripe_customer(self) -> Customer:
|
||||||
stripe_customer_data = self.get_data_for_stripe_customer()
|
stripe_customer_data = self.get_data_for_stripe_customer()
|
||||||
|
@ -2324,12 +2325,6 @@ class RealmBillingSession(BillingSession):
|
||||||
def is_sponsored(self) -> bool:
|
def is_sponsored(self) -> bool:
|
||||||
return self.realm.plan_type == self.realm.PLAN_TYPE_STANDARD_FREE
|
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.is_sponsored():
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
def get_metadata_for_stripe_update_card(self) -> Dict[str, Any]:
|
def get_metadata_for_stripe_update_card(self) -> Dict[str, Any]:
|
||||||
assert self.user is not None
|
assert self.user is not None
|
||||||
|
@ -2591,12 +2586,6 @@ class RemoteRealmBillingSession(BillingSession): # nocoverage
|
||||||
def is_sponsored(self) -> bool:
|
def is_sponsored(self) -> bool:
|
||||||
return self.remote_realm.plan_type == self.remote_realm.PLAN_TYPE_COMMUNITY
|
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.is_sponsored():
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
def get_metadata_for_stripe_update_card(self) -> Dict[str, Any]:
|
def get_metadata_for_stripe_update_card(self) -> Dict[str, Any]:
|
||||||
return {
|
return {
|
||||||
|
@ -2868,11 +2857,6 @@ class RemoteServerBillingSession(BillingSession): # nocoverage
|
||||||
def is_sponsored(self) -> bool:
|
def is_sponsored(self) -> bool:
|
||||||
return self.remote_server.plan_type == self.remote_server.PLAN_TYPE_COMMUNITY
|
return self.remote_server.plan_type == self.remote_server.PLAN_TYPE_COMMUNITY
|
||||||
|
|
||||||
@override
|
|
||||||
def is_sponsored_or_pending(self, customer: Optional[Customer]) -> bool:
|
|
||||||
# TBD
|
|
||||||
return False
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
def get_metadata_for_stripe_update_card(self) -> Dict[str, Any]:
|
def get_metadata_for_stripe_update_card(self) -> Dict[str, Any]:
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in New Issue