[damned-lies] Fixes #173 - Sync username accepted chars with Django standards
- From: Claude Paroz <claudep src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies] Fixes #173 - Sync username accepted chars with Django standards
- Date: Fri, 10 Apr 2020 09:47:49 +0000 (UTC)
commit 6892740a1a8bad3c918fed91cd8264f1658b47cc
Author: Claude Paroz <claude 2xlibre net>
Date: Fri Apr 10 11:45:59 2020 +0200
Fixes #173 - Sync username accepted chars with Django standards
people/forms.py | 14 ++++++++++----
people/tests.py | 2 +-
2 files changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/people/forms.py b/people/forms.py
index 0a8436a5..4faa41e7 100644
--- a/people/forms.py
+++ b/people/forms.py
@@ -14,13 +14,19 @@ from common.utils import send_mail
from teams.models import Team
from people.models import Person
+from django.contrib.auth.validators import UnicodeUsernameValidator
+from django.contrib.auth.forms import UsernameField
+
+username_validator = UnicodeUsernameValidator()
+
class RegistrationForm(forms.Form):
""" Form for user registration """
- username = forms.RegexField(widget=forms.TextInput(attrs={'class': 'form-control'}),
- max_length=30, regex=r'^\w+$',
- label=gettext_lazy('Choose a username:'),
- help_text=gettext_lazy('May contain only letters, numbers, underscores or
hyphens'))
+ username = UsernameField(max_length=30,
+ label=gettext_lazy('Choose a username:'),
+ validators=[username_validator],
+ help_text=gettext_lazy('May contain only letters, numbers, and @/./+/-/_
characters.'),
+ widget=forms.TextInput(attrs={'class': 'form-control'}))
email = forms.EmailField(widget=forms.TextInput(attrs={'class': 'form-control'}),
label=gettext_lazy('Email:'))
password1 = forms.CharField(widget=forms.PasswordInput(attrs={'class':
'form-control'},render_value=False),
diff --git a/people/tests.py b/people/tests.py
index 7d81cd7c..f823bb93 100644
--- a/people/tests.py
+++ b/people/tests.py
@@ -26,7 +26,7 @@ class PeopleTestCase(TestCase):
return pn
def test_register(self):
- username = 'tèst01'
+ username = 'tèst-01'
response = self.client.post(
reverse('register'),
{'username': username, 'password1': '1234567',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]