From 255c8a1d805dc4583dd6f6487e35908bea14c0b6 Mon Sep 17 00:00:00 2001 From: PCoder Date: Sat, 21 Oct 2017 00:00:21 +0200 Subject: [PATCH] Add UserCardDetail create method that assigns appropriate object permission --- hosting/models.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/hosting/models.py b/hosting/models.py index a33f51d5..ef8b8a74 100644 --- a/hosting/models.py +++ b/hosting/models.py @@ -196,4 +196,14 @@ class UserCardDetail(AssignPermissionsMixin, models.Model): class Meta: permissions = ( ('view_usercarddetail', 'View User Card'), - ) \ No newline at end of file + ) + + @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