mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-25 00:13:45 +00:00
Oubli d'import + form vide pas validé remplacé par None
This commit is contained in:
parent
ce83d6e299
commit
5915485d89
3 changed files with 7 additions and 6 deletions
|
@ -42,6 +42,7 @@ from django.forms import ModelForm, Form
|
||||||
from django.core.validators import MinValueValidator
|
from django.core.validators import MinValueValidator
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
from django.utils.translation import ugettext_lazy as _l
|
from django.utils.translation import ugettext_lazy as _l
|
||||||
|
from django.shortcuts import get_object_or_404
|
||||||
|
|
||||||
from re2o.field_permissions import FieldPermissionFormMixin
|
from re2o.field_permissions import FieldPermissionFormMixin
|
||||||
from re2o.mixins import FormRevMixin
|
from re2o.mixins import FormRevMixin
|
||||||
|
|
|
@ -30,7 +30,7 @@ def payment_method_factory(payment, *args, creation=True, **kwargs):
|
||||||
|
|
||||||
If the payment has a payment method, returns a ModelForm of it. Else if
|
If the payment has a payment method, returns a ModelForm of it. Else if
|
||||||
it is the creation of the payment, a `PaymentMethodForm`.
|
it is the creation of the payment, a `PaymentMethodForm`.
|
||||||
Else an empty form.
|
Else `None`.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
payment: The payment
|
payment: The payment
|
||||||
|
@ -39,7 +39,7 @@ def payment_method_factory(payment, *args, creation=True, **kwargs):
|
||||||
**kwargs: passed to the form
|
**kwargs: passed to the form
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
A form
|
A form or None
|
||||||
"""
|
"""
|
||||||
payment_method = kwargs.pop('instance', find_payment_method(payment))
|
payment_method = kwargs.pop('instance', find_payment_method(payment))
|
||||||
if payment_method is not None:
|
if payment_method is not None:
|
||||||
|
@ -50,8 +50,6 @@ def payment_method_factory(payment, *args, creation=True, **kwargs):
|
||||||
)
|
)
|
||||||
elif creation:
|
elif creation:
|
||||||
return PaymentMethodForm(*args, **kwargs)
|
return PaymentMethodForm(*args, **kwargs)
|
||||||
else:
|
|
||||||
return forms.Form()
|
|
||||||
|
|
||||||
|
|
||||||
class PaymentMethodForm(forms.Form):
|
class PaymentMethodForm(forms.Form):
|
||||||
|
|
|
@ -463,8 +463,10 @@ def edit_paiement(request, paiement_instance, **_kwargs):
|
||||||
creation=False
|
creation=False
|
||||||
)
|
)
|
||||||
|
|
||||||
if payment.is_valid() and payment_method.is_valid():
|
if payment.is_valid() and \
|
||||||
|
(payment_method is None or payment_method.is_valid()):
|
||||||
payment.save()
|
payment.save()
|
||||||
|
if payment_method is not None:
|
||||||
payment_method.save()
|
payment_method.save()
|
||||||
messages.success(
|
messages.success(
|
||||||
request,
|
request,
|
||||||
|
|
Loading…
Reference in a new issue