Add doc. and return empty list for get_all_cards_list function
This commit is contained in:
		
					parent
					
						
							
								14c7d6ac0e
							
						
					
				
			
			
				commit
				
					
						303eb4112d
					
				
			
		
					 1 changed files with 10 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -212,10 +212,19 @@ class UserCardDetail(AssignPermissionsMixin, models.Model):
 | 
			
		|||
 | 
			
		||||
    @classmethod
 | 
			
		||||
    def get_all_cards_list(cls, stripe_customer):
 | 
			
		||||
        """
 | 
			
		||||
        Get all the cards of the given customer as a list
 | 
			
		||||
 | 
			
		||||
        :param stripe_customer: The StripeCustomer object
 | 
			
		||||
        :return: A list of all cards; an empty list if the customer object is
 | 
			
		||||
                 None
 | 
			
		||||
        """
 | 
			
		||||
        cards_list = []
 | 
			
		||||
        if stripe_customer is None:
 | 
			
		||||
            return cards_list
 | 
			
		||||
        user_card_details = UserCardDetail.objects.filter(
 | 
			
		||||
            stripe_customer_id=stripe_customer.id
 | 
			
		||||
        )
 | 
			
		||||
        cards_list = []
 | 
			
		||||
        for card in user_card_details:
 | 
			
		||||
            cards_list.append({
 | 
			
		||||
                'last4': card.last4, 'brand': card.brand, 'id': card.id
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue