From 5853049aefa1f7c01393c9d9cc2f251d5a664b84 Mon Sep 17 00:00:00 2001 From: Hugo LEVY-FALK Date: Tue, 3 Jul 2018 16:46:29 +0200 Subject: [PATCH] =?UTF-8?q?Emp=C3=AAche=20le=20changement=20de=20m=C3=A9th?= =?UTF-8?q?ode=20de=20paiement=20apr=C3=A8s=20cr=C3=A9ation.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cotisations/payment_methods/forms.py | 11 +++++++++-- cotisations/views.py | 3 ++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/cotisations/payment_methods/forms.py b/cotisations/payment_methods/forms.py index f5bf4f76..37653c3a 100644 --- a/cotisations/payment_methods/forms.py +++ b/cotisations/payment_methods/forms.py @@ -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 ) diff --git a/cotisations/views.py b/cotisations/views.py index fbf8d7ab..bee266d0 100644 --- a/cotisations/views.py +++ b/cotisations/views.py @@ -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():