diff options
-rw-r--r-- | ishtar/ishtar_base/forms_common.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/ishtar/ishtar_base/forms_common.py b/ishtar/ishtar_base/forms_common.py index c7ca15472..d6a95aa75 100644 --- a/ishtar/ishtar_base/forms_common.py +++ b/ishtar/ishtar_base/forms_common.py @@ -332,6 +332,13 @@ class AccountForm(forms.Form): if not password: raise forms.ValidationError(_(u"You must provide a correct \ password.")) + # check username unicity + usernames = models.IshtarUser.objects.filter(username= + cleaned_data.get('username')) + if cleaned_data.get('pk'): + usernames.exclude(pk=cleaned_data.get('pk')) + if usernames.count(): + raise forms.ValidationError(_(u"This username already exists.")) return cleaned_data class FinalAccountForm(forms.Form): |