Commit 5853049a authored by Levy--Falk Hugo's avatar Levy--Falk Hugo

Empêche le changement de méthode de paiement après création.

parent c979bdda
......@@ -5,7 +5,7 @@ from django.utils.translation import ugettext_lazy as _l
from . import PAYMENT_METHODS
from cotisations.utils import find_payment_method
def payment_method_factory(payment, *args, **kwargs):
def payment_method_factory(payment, *args, creation=True, **kwargs):
payment_method = kwargs.pop('instance', find_payment_method(payment))
if payment_method is not None:
return forms.modelform_factory(type(payment_method), fields='__all__')(
......@@ -13,7 +13,10 @@ def payment_method_factory(payment, *args, **kwargs):
instance=payment_method,
**kwargs
)
return PaymentMethodForm(payment_method, *args, **kwargs)
elif creation:
return PaymentMethodForm(payment_method, *args, **kwargs)
else:
return forms.Form()
class PaymentMethodForm(forms.Form):
......@@ -25,6 +28,10 @@ class PaymentMethodForm(forms.Form):
payment_method = forms.ChoiceField(
label=_l("Special payment method"),
help_text=_l("Warning : You will not be able to change the payment "
"method later. But you will be allowed to edit its "
"options."
),
required=False
)
......
......@@ -485,7 +485,8 @@ def edit_paiement(request, paiement_instance, **_kwargs):
payment_method = payment_method_factory(
paiement_instance,
request.POST or None,
prefix='payment_method'
prefix='payment_method',
creation=False
)
if payment.is_valid() and payment_method.is_valid():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment