mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-04 17:06:27 +00:00
Empêche le changement de méthode de paiement après création.
This commit is contained in:
parent
c979bdda45
commit
5853049aef
2 changed files with 11 additions and 3 deletions
|
@ -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():
|
||||
|
|
Loading…
Reference in a new issue