Add UserCardDetail create method that assigns appropriate object permission

This commit is contained in:
PCoder 2017-10-21 00:00:21 +02:00
parent 51039a5cb3
commit 255c8a1d80

View file

@ -196,4 +196,14 @@ class UserCardDetail(AssignPermissionsMixin, models.Model):
class Meta:
permissions = (
('view_usercarddetail', 'View User Card'),
)
)
@classmethod
def create(cls, stripe_customer=None, last4=None, brand=None,
fingerprint=None, exp_month=None, exp_year=None):
instance = cls.objects.create(
stripe_customer=stripe_customer, last4=last4, brand=brand,
fingerprint=fingerprint, exp_month=exp_month, exp_year=exp_year
)
instance.assign_permissions(stripe_customer.user)
return instance