From 690b80a61674697763b0c07f377be66ff30852f8 Mon Sep 17 00:00:00 2001 From: PCoder Date: Thu, 13 Jun 2019 05:19:34 +0200 Subject: [PATCH] Add FailedInvoice create method --- hosting/models.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/hosting/models.py b/hosting/models.py index e1bcdd63..aec95dfc 100644 --- a/hosting/models.py +++ b/hosting/models.py @@ -743,4 +743,18 @@ class FailedInvoice(AssignPermissionsMixin, models.Model): help_text="The datetime if/when service was interrupted" ) + class Meta: + permissions = ( + ('view_failedinvoice', 'View User Card'), + ) + + @classmethod + def create(cls, stripe_customer=None, order=None, invoice_id=None): + instance = cls.objects.create( + stripe_customer=stripe_customer, order=order, number_of_attempts=0, + invoice_id=invoice_id + ) + instance.assign_permissions(stripe_customer.user) + return instance +