Commits

Anonymous committed b9e7738 Draft

changes for hebrew support

Comments (0)

Files changed (1)

registration/forms.py

+# -*- coding: utf-8 -*
+
 """
 Forms and validation code for user registration.
 
 """
-
-
 from django.contrib.auth.models import User
 from django import forms
 from django.utils.translation import ugettext_lazy as _
     registration backend.
     
     """
-    username = forms.RegexField(regex=r'^[\w.@+-]+$',
+    """
+    Bentzy Sagiv - added hebrew range characters  + bug fix
+    """ 
+    username = forms.RegexField(regex=ur'^[\w.@+-\[\u05D0-\u05EA\]]+$',
                                 max_length=30,
                                 widget=forms.TextInput(attrs=attrs_dict),
                                 label=_("Username"),
-                                error_messages={'invalid': _("This value may contain only letters, numbers and @/./+/-/_ characters.")})
+                                #error_messages={'invalid': _(" שם משתמש יכול להכיל רק אותיות, מספרים וקווים תחתיים"),})
+                                error_message=_('This field may only contain uppercase letters and numbers.'))
     email = forms.EmailField(widget=forms.TextInput(attrs=dict(attrs_dict,
                                                                maxlength=75)),
                              label=_("E-mail"))
         in use.
         
         """
-        existing = User.objects.filter(username__iexact=self.cleaned_data['username'])
-        if existing.exists():
-            raise forms.ValidationError(_("A user with that username already exists."))
-        else:
+        try:
+            user = User.objects.get(username__iexact=self.cleaned_data['username'])
+        except User.DoesNotExist:
             return self.cleaned_data['username']
+        raise forms.ValidationError(_("A user with that username already exists."))
 
     def clean(self):
         """