mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	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:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							fbd8ed1425
						
					
				
				
					commit
					5eabd51702
				
			@@ -724,10 +724,6 @@ class BillingSession(ABC):
 | 
			
		||||
    def is_sponsored(self) -> bool:
 | 
			
		||||
        pass
 | 
			
		||||
 | 
			
		||||
    @abstractmethod
 | 
			
		||||
    def is_sponsored_or_pending(self, customer: Optional[Customer]) -> bool:
 | 
			
		||||
        pass
 | 
			
		||||
 | 
			
		||||
    @abstractmethod
 | 
			
		||||
    def get_sponsorship_request_session_specific_context(
 | 
			
		||||
        self,
 | 
			
		||||
@@ -766,6 +762,11 @@ class BillingSession(ABC):
 | 
			
		||||
    def get_metadata_for_stripe_update_card(self) -> Dict[str, Any]:
 | 
			
		||||
        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
 | 
			
		||||
    def create_stripe_customer(self) -> Customer:
 | 
			
		||||
        stripe_customer_data = self.get_data_for_stripe_customer()
 | 
			
		||||
@@ -2324,12 +2325,6 @@ class RealmBillingSession(BillingSession):
 | 
			
		||||
    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.is_sponsored():
 | 
			
		||||
            return True
 | 
			
		||||
        return False
 | 
			
		||||
 | 
			
		||||
    @override
 | 
			
		||||
    def get_metadata_for_stripe_update_card(self) -> Dict[str, Any]:
 | 
			
		||||
        assert self.user is not None
 | 
			
		||||
@@ -2591,12 +2586,6 @@ class RemoteRealmBillingSession(BillingSession):  # nocoverage
 | 
			
		||||
    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.is_sponsored():
 | 
			
		||||
            return True
 | 
			
		||||
        return False
 | 
			
		||||
 | 
			
		||||
    @override
 | 
			
		||||
    def get_metadata_for_stripe_update_card(self) -> Dict[str, Any]:
 | 
			
		||||
        return {
 | 
			
		||||
@@ -2868,11 +2857,6 @@ class RemoteServerBillingSession(BillingSession):  # nocoverage
 | 
			
		||||
    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
 | 
			
		||||
        return False
 | 
			
		||||
 | 
			
		||||
    @override
 | 
			
		||||
    def get_metadata_for_stripe_update_card(self) -> Dict[str, Any]:
 | 
			
		||||
        return {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user