diff --git a/cotisations/models.py b/cotisations/models.py index 759f5320..e0197567 100644 --- a/cotisations/models.py +++ b/cotisations/models.py @@ -871,7 +871,7 @@ class Paiement(RevMixin, AclMixin, models.Model): """ self.moyen = self.moyen.title() - def end_payment(self, invoice, request, use_payment_method=True): + def end_payment(self, invoice, request, use_payment_method=True, *args, **kwargs): """ The general way of ending a payment. @@ -887,7 +887,7 @@ class Paiement(RevMixin, AclMixin, models.Model): """ payment_method = find_payment_method(self) if payment_method is not None and use_payment_method: - return payment_method.end_payment(invoice, request) + return payment_method.end_payment(invoice, request, *args, **kwargs) # So make this invoice valid, trigger send mail invoice.valid = True diff --git a/cotisations/payment_methods/__init__.py b/cotisations/payment_methods/__init__.py index 1170bd92..77eec252 100644 --- a/cotisations/payment_methods/__init__.py +++ b/cotisations/payment_methods/__init__.py @@ -101,7 +101,7 @@ But this payment method is not really usefull, since it does noting ! You have to redefine the `end_payment` method. Here is its prototype : ```python -def end_payment(self, invoice, request): +def end_payment(self, invoice, request, *args, **kwargs): pass ``` diff --git a/cotisations/payment_methods/balance/models.py b/cotisations/payment_methods/balance/models.py index 9f07f930..d143793a 100644 --- a/cotisations/payment_methods/balance/models.py +++ b/cotisations/payment_methods/balance/models.py @@ -66,7 +66,7 @@ class BalancePayment(PaymentMethodMixin, models.Model): verbose_name=_("allow user to credit their balance"), default=False ) - def end_payment(self, invoice, request): + def end_payment(self, invoice, request, *args, **kwargs): """Changes the user's balance to pay the invoice. If it is not possible, shows an error and invalidates the invoice. """ diff --git a/cotisations/payment_methods/cheque/models.py b/cotisations/payment_methods/cheque/models.py index c05099ab..245d2fbb 100644 --- a/cotisations/payment_methods/cheque/models.py +++ b/cotisations/payment_methods/cheque/models.py @@ -42,7 +42,7 @@ class ChequePayment(PaymentMethodMixin, models.Model): editable=False, ) - def end_payment(self, invoice, request): + def end_payment(self, invoice, request, *args, **kwargs): """Invalidates the invoice then redirect the user towards a view asking for informations to add to the invoice before validating it. """ diff --git a/cotisations/payment_methods/free/models.py b/cotisations/payment_methods/free/models.py index a4c24459..a4be807f 100644 --- a/cotisations/payment_methods/free/models.py +++ b/cotisations/payment_methods/free/models.py @@ -42,7 +42,7 @@ class FreePayment(PaymentMethodMixin, models.Model): editable=False, ) - def end_payment(self, invoice, request): + def end_payment(self, invoice, request, *args, **kwargs): """Ends the payment normally. """ return invoice.paiement.end_payment(invoice, request, use_payment_method=False) diff --git a/cotisations/payment_methods/mixins.py b/cotisations/payment_methods/mixins.py index 8c3b1dc9..ca86984d 100644 --- a/cotisations/payment_methods/mixins.py +++ b/cotisations/payment_methods/mixins.py @@ -23,10 +23,10 @@ class PaymentMethodMixin: """A simple mixin to avoid redefining end_payment if you don't need to""" - def end_payment(self, invoice, request): + def end_payment(self, invoice, request, *args, **kwargs): """Redefine this method in order to get a different ending to the payment session if you whish. Must return a HttpResponse-like object. """ - return self.payment.end_payment(invoice, request, use_payment_method=False) + return self.payment.end_payment(invoice, request, use_payment_method=False, *args, **kwargs) diff --git a/cotisations/payment_methods/note_kfet/models.py b/cotisations/payment_methods/note_kfet/models.py index 4f1a8152..517fcc55 100644 --- a/cotisations/payment_methods/note_kfet/models.py +++ b/cotisations/payment_methods/note_kfet/models.py @@ -49,7 +49,7 @@ class NotePayment(PaymentMethodMixin, models.Model): port = models.PositiveIntegerField(blank=True, null=True) id_note = models.PositiveIntegerField(blank=True, null=True) - def end_payment(self, invoice, request): + def end_payment(self, invoice, request, *args, **kwargs): return redirect( reverse( "cotisations:note_kfet:note_payment", kwargs={"factureid": invoice.id} diff --git a/cotisations/views.py b/cotisations/views.py index 7aa771b5..883da1fd 100644 --- a/cotisations/views.py +++ b/cotisations/views.py @@ -154,7 +154,7 @@ def new_facture(request, user, userid): return new_invoice_instance.paiement.end_payment( new_invoice_instance,request, - ipn_host=settings.ALLOWED_HOSTS[0] if request.path.contains("portail") else None, + ipn_host=settings.ALLOWED_HOSTS[0] if "portail" in request.path else None, ) else: messages.error(request, _("You need to choose at least one article."))