Skip to content

Commit

Permalink
Moving duplicate error message to init
Browse files Browse the repository at this point in the history
  • Loading branch information
clash99 committed Apr 19, 2017
1 parent 8608969 commit 96965ad
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions cadasta/organization/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ class Meta:
def __init__(self, *args, **kwargs):
self.user = kwargs.pop('user', None)
super().__init__(*args, **kwargs)
self.fields['name'].error_messages['unique'] = _(
"Organization with this name already exists.")

def clean_name(self):
name = self.cleaned_data['name']
Expand All @@ -136,10 +138,6 @@ def clean_name(self):
raise forms.ValidationError(
_("Organization name cannot be “Add” or “New”."))

if Organization.objects.filter(name=name).exists():
raise forms.ValidationError(
_("Organization with this name already exists."))

return name

def save(self, *args, **kwargs):
Expand Down

0 comments on commit 96965ad

Please sign in to comment.