fix dates with end_date empty
This commit is contained in:
parent
88b1ea171c
commit
4120d0230b
|
@ -148,6 +148,10 @@ class MembershipForm(forms.ModelForm):
|
|||
if self.instance.id:
|
||||
members = members.exclude(id=self.instance.id)
|
||||
|
||||
if members.filter(start_date__lte=start_date, end_date=None).exists():
|
||||
msg = _("This membership already exists!")
|
||||
raise forms.ValidationError(msg)
|
||||
|
||||
if (start_date and end_date):
|
||||
if start_date > end_date:
|
||||
msg = _("The end date is less than the start date")
|
||||
|
@ -162,6 +166,16 @@ class MembershipForm(forms.ModelForm):
|
|||
msg = _("This membership already exists!")
|
||||
raise forms.ValidationError(msg)
|
||||
|
||||
if not end_date:
|
||||
members = members.filter(
|
||||
start_date__gte=start_date,
|
||||
)
|
||||
|
||||
if members.exists():
|
||||
msg = _("This membership already exists!")
|
||||
raise forms.ValidationError(msg)
|
||||
|
||||
|
||||
return end_date
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue