Browse Source

Add *args and **kwargs to some functions

portal
Yohann D'ANELLO 5 years ago
parent
commit
d301f37203
No known key found for this signature in database GPG Key ID: 3A75C55819C8CF85
  1. 4
      cotisations/models.py
  2. 2
      cotisations/payment_methods/__init__.py
  3. 2
      cotisations/payment_methods/balance/models.py
  4. 2
      cotisations/payment_methods/cheque/models.py
  5. 2
      cotisations/payment_methods/free/models.py
  6. 4
      cotisations/payment_methods/mixins.py
  7. 2
      cotisations/payment_methods/note_kfet/models.py
  8. 2
      cotisations/views.py

4
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

2
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
```

2
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.
"""

2
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.
"""

2
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)

4
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)

2
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}

2
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."))

Loading…
Cancel
Save