Skip to content

Commit

Permalink
Apply suggestions from review
Browse files Browse the repository at this point in the history
Co-authored-by: pitpalme <[email protected]>
  • Loading branch information
christophmeissner and pitpalme committed Mar 29, 2022
1 parent 7d8c69b commit 6534257
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
4 changes: 2 additions & 2 deletions accounts/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
inverse_match=True,
)
username_first_char_validator = RegexValidator(
r"^[_.0-9\s]", _("Username must start with a letter."), inverse_match=True
r"^[\d_.]", _("Username must start with a letter."), inverse_match=True
)
username_last_char_validator = RegexValidator(
r"[\w]$", _('Username must end with a letter, a number or "_".')
Expand All @@ -25,7 +25,7 @@
class RegistrationForm(RegistrationFormUniqueEmail):

username = forms.CharField(
max_length=16,
max_length=32,
min_length=3,
strip=False,
validators=[
Expand Down
7 changes: 2 additions & 5 deletions tests/registration/test_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ def test_username_too_short(self):

def test_username_too_long(self):
self.try_invalid_username(
"abcdef_0123456789",
"Ensure this value has at most 16 characters (it has 17).",
"abcdef0123456789.abcdef0123456789",
"Ensure this value has at most 32 characters (it has 33).",
)

def test_username_with_consequtive_underscores(self):
Expand Down Expand Up @@ -174,7 +174,6 @@ def test_username_with_whitespaces(self):
self.try_invalid_username(
" username",
[
"Username must start with a letter.",
"Invalid username. "
'Allowed characters are letters, numbers, "." and "_".',
],
Expand All @@ -190,7 +189,6 @@ def test_username_with_whitespaces(self):
self.try_invalid_username(
" username ",
[
"Username must start with a letter.",
'Username must end with a letter, a number or "_".',
"Invalid username. "
'Allowed characters are letters, numbers, "." and "_".',
Expand All @@ -199,7 +197,6 @@ def test_username_with_whitespaces(self):
self.try_invalid_username(
" user name ",
[
"Username must start with a letter.",
'Username must end with a letter, a number or "_".',
"Invalid username. "
'Allowed characters are letters, numbers, "." and "_".',
Expand Down

0 comments on commit 6534257

Please sign in to comment.