Do not include the current liaison when searching if a title exists. Fixes #390
- Legacy-Id: 2563
This commit is contained in:
parent
ed2e87ec69
commit
d712ce2533
|
@ -215,7 +215,11 @@ class LiaisonForm(forms.ModelForm):
|
|||
|
||||
def clean_title(self):
|
||||
title = self.cleaned_data.get('title', None)
|
||||
exists = bool(LiaisonDetail.objects.filter(title__iexact=title).count())
|
||||
if self.instance and self.instance.pk:
|
||||
exclude_filter = {'pk': self.instance.pk}
|
||||
else:
|
||||
exclude_filter = {}
|
||||
exists = bool(LiaisonDetail.objects.exclude(**exclude_filter).filter(title__iexact=title).count())
|
||||
if exists:
|
||||
raise forms.ValidationError('A liaison statement with the same title has previously been submitted.')
|
||||
return title
|
||||
|
|
Loading…
Reference in a new issue