mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-27 07:02:26 +00:00
Fix form validation
This commit is contained in:
parent
b38521db69
commit
5c0a4ce748
1 changed files with 9 additions and 8 deletions
|
@ -300,15 +300,16 @@ class MandateForm(ModelForm):
|
||||||
def clean(self):
|
def clean(self):
|
||||||
cleaned_data = super(MandateForm, self).clean()
|
cleaned_data = super(MandateForm, self).clean()
|
||||||
start_date, end_date = cleaned_data['start_date'], cleaned_data['end_date']
|
start_date, end_date = cleaned_data['start_date'], cleaned_data['end_date']
|
||||||
included_mandates = Mandate.objects.filter(
|
if end_date:
|
||||||
Q(start_date__gte=start_date, start_date__lt=end_date)
|
included_mandates = Mandate.objects.filter(
|
||||||
| Q(end_date__gt=start_date, end_date__lte=end_date)
|
Q(start_date__gte=start_date, start_date__lt=end_date)
|
||||||
)
|
| Q(end_date__gt=start_date, end_date__lte=end_date)
|
||||||
if included_mandates:
|
|
||||||
raise forms.ValidationError(
|
|
||||||
_("The specified dates overlap with an existing mandate."),
|
|
||||||
code='invalid'
|
|
||||||
)
|
)
|
||||||
|
if included_mandates:
|
||||||
|
raise forms.ValidationError(
|
||||||
|
_("The specified dates overlap with an existing mandate."),
|
||||||
|
code='invalid'
|
||||||
|
)
|
||||||
return cleaned_data
|
return cleaned_data
|
||||||
|
|
||||||
def save(self, commit=True):
|
def save(self, commit=True):
|
||||||
|
|
Loading…
Reference in a new issue