SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit b5a9941a authored by Jean-Sébastien Caux's avatar Jean-Sébastien Caux
Browse files

Improve ContactPerson form validation

parent da9a0f84
No related branches found
No related tags found
No related merge requests found
......@@ -38,7 +38,10 @@ class ContactPersonForm(forms.ModelForm):
email = self.cleaned_data['email']
try:
ContactPerson.objects.get(email=email)
self.add_error('email', 'This email is already associated to a Contact Person.')
if self.instance.pk:
pass # OK, this is an update
else:
self.add_error('email', 'This email is already associated to a Contact Person.')
except ContactPerson.DoesNotExist:
pass
try:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment