diff --git a/accounts/forms.py b/accounts/forms.py index a9db15b0..47de5150 100644 --- a/accounts/forms.py +++ b/accounts/forms.py @@ -1,9 +1,58 @@ from django import forms +from django.core.validators import RegexValidator from django.utils.text import gettext_lazy as _ + from registration.forms import RegistrationFormUniqueEmail +username_first_char_validator = RegexValidator( + r"^[a-zA-Z]", _("Username must start with a letter.") +) +username_validator = RegexValidator( + r"^[a-zA-Z0-9_.]*$", + _('Invalid username. Allowed characters are letters, numbers, "." and "_".'), +) +username_last_char_validator = RegexValidator( + r"[a-zA-Z0-9]$", _("Username must end with a letter or a number.") +) +no_consequtive_dots = RegexValidator( + r"\.\.", + _("Username must not contain consecutive . or _ characters."), + inverse_match=True, +) +no_consequtive_underscores = RegexValidator( + r"__", + _("Username must not contain consecutive . or _ characters."), + inverse_match=True, +) +no_consequtive_funnystuff = RegexValidator( + r"_\.", + _("Username must not contain consecutive . or _ characters."), + inverse_match=True, +) +no_consequtive_funnystuff2 = RegexValidator( + r"\._", + _("Username must not contain consecutive . or _ characters."), + inverse_match=True, +) + class RegistrationForm(RegistrationFormUniqueEmail): + + username = forms.CharField( + max_length=16, + min_length=3, + strip=False, + validators=[ + username_first_char_validator, + username_validator, + username_last_char_validator, + no_consequtive_dots, + no_consequtive_underscores, + no_consequtive_funnystuff, + no_consequtive_funnystuff2, + ], + ) + accept_privacy_policy = forms.BooleanField( required=True, initial=False, label=_("Accept privacy policy") ) diff --git a/locale/ar/LC_MESSAGES/django.po b/locale/ar/LC_MESSAGES/django.po index b77afb2d..03a7014d 100644 --- a/locale/ar/LC_MESSAGES/django.po +++ b/locale/ar/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: volunteer-planner.org\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-03-25 11:54+0100\n" +"POT-Creation-Date: 2022-03-25 21:54+0100\n" "PO-Revision-Date: 2022-03-15 17:56+0000\n" "Last-Translator: Christoph Meißner\n" "Language-Team: Arabic (http://www.transifex.com/coders4help/volunteer-planner/language/ar/)\n" @@ -36,6 +36,18 @@ msgstr "" msgid "Accounts" msgstr "الحسابات " +msgid "Username must start with a letter." +msgstr "" + +msgid "Invalid username. Allowed characters are letters, numbers, \".\" and \"_\"." +msgstr "" + +msgid "Username must end with a letter or a number." +msgstr "" + +msgid "Username must not contain consecutive . or _ characters." +msgstr "" + msgid "Accept privacy policy" msgstr "" diff --git a/locale/bg/LC_MESSAGES/django.po b/locale/bg/LC_MESSAGES/django.po index b37918fc..699b7adf 100644 --- a/locale/bg/LC_MESSAGES/django.po +++ b/locale/bg/LC_MESSAGES/django.po @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: volunteer-planner.org\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-03-25 11:54+0100\n" +"POT-Creation-Date: 2022-03-25 21:54+0100\n" "PO-Revision-Date: 2022-03-15 17:56+0000\n" "Last-Translator: Christoph Meißner\n" "Language-Team: Bulgarian (http://www.transifex.com/coders4help/volunteer-planner/language/bg/)\n" @@ -32,6 +32,18 @@ msgstr "" msgid "Accounts" msgstr "" +msgid "Username must start with a letter." +msgstr "" + +msgid "Invalid username. Allowed characters are letters, numbers, \".\" and \"_\"." +msgstr "" + +msgid "Username must end with a letter or a number." +msgstr "" + +msgid "Username must not contain consecutive . or _ characters." +msgstr "" + msgid "Accept privacy policy" msgstr "" diff --git a/locale/cs/LC_MESSAGES/django.po b/locale/cs/LC_MESSAGES/django.po index 0b6c0d3e..824aae33 100644 --- a/locale/cs/LC_MESSAGES/django.po +++ b/locale/cs/LC_MESSAGES/django.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: volunteer-planner.org\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-03-25 11:54+0100\n" +"POT-Creation-Date: 2022-03-25 21:54+0100\n" "PO-Revision-Date: 2022-03-15 17:56+0000\n" "Last-Translator: Christoph Meißner\n" "Language-Team: Czech (http://www.transifex.com/coders4help/volunteer-planner/language/cs/)\n" @@ -34,6 +34,18 @@ msgstr "poslední přihlášení" msgid "Accounts" msgstr "Účty" +msgid "Username must start with a letter." +msgstr "" + +msgid "Invalid username. Allowed characters are letters, numbers, \".\" and \"_\"." +msgstr "" + +msgid "Username must end with a letter or a number." +msgstr "" + +msgid "Username must not contain consecutive . or _ characters." +msgstr "" + msgid "Accept privacy policy" msgstr "Přijmout zásady ochrany osobních údajů" diff --git a/locale/da/LC_MESSAGES/django.po b/locale/da/LC_MESSAGES/django.po index 0473868b..dc444d7c 100644 --- a/locale/da/LC_MESSAGES/django.po +++ b/locale/da/LC_MESSAGES/django.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: volunteer-planner.org\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-03-25 11:54+0100\n" +"POT-Creation-Date: 2022-03-25 21:54+0100\n" "PO-Revision-Date: 2017-09-22 15:35+0000\n" "Last-Translator: Dorian Cantzen \n" "Language-Team: Danish (http://www.transifex.com/coders4help/volunteer-planner/language/da/)\n" @@ -33,6 +33,18 @@ msgstr "" msgid "Accounts" msgstr "" +msgid "Username must start with a letter." +msgstr "" + +msgid "Invalid username. Allowed characters are letters, numbers, \".\" and \"_\"." +msgstr "" + +msgid "Username must end with a letter or a number." +msgstr "" + +msgid "Username must not contain consecutive . or _ characters." +msgstr "" + msgid "Accept privacy policy" msgstr "" diff --git a/locale/de/LC_MESSAGES/django.po b/locale/de/LC_MESSAGES/django.po index 3f715171..fb8c8739 100644 --- a/locale/de/LC_MESSAGES/django.po +++ b/locale/de/LC_MESSAGES/django.po @@ -19,7 +19,7 @@ msgid "" msgstr "" "Project-Id-Version: volunteer-planner.org\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-03-25 11:54+0100\n" +"POT-Creation-Date: 2022-03-25 21:54+0100\n" "PO-Revision-Date: 2016-11-21 18:24+0000\n" "Last-Translator: Sönke Klinger \n" "Language-Team: German (http://www.transifex.com/coders4help/volunteer-planner/language/de/)\n" @@ -47,6 +47,18 @@ msgstr "Letzte Anmeldung" msgid "Accounts" msgstr "Benutzerkonten" +msgid "Username must start with a letter." +msgstr "Benutzername muss mit einem Buchstaben anfangen." + +msgid "Invalid username. Allowed characters are letters, numbers, \".\" and \"_\"." +msgstr "Ungültiger Benutzername. Erlaubte Zeichen sind Buchstaben, Ziffern, \".\" and \".\"." + +msgid "Username must end with a letter or a number." +msgstr "Benutzername muss mit einem Buchstaben oder einer Ziffer enden." + +msgid "Username must not contain consecutive . or _ characters." +msgstr "Benutzername darf keine aufeinanderfolgenden . oder _ enthalten." + msgid "Accept privacy policy" msgstr "Einwilligung (nach Art 6 Abs 1 Satz 1 a DSGVO)" diff --git a/locale/el/LC_MESSAGES/django.po b/locale/el/LC_MESSAGES/django.po index 490e96f8..3646763c 100644 --- a/locale/el/LC_MESSAGES/django.po +++ b/locale/el/LC_MESSAGES/django.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: volunteer-planner.org\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-03-25 11:54+0100\n" +"POT-Creation-Date: 2022-03-25 21:54+0100\n" "PO-Revision-Date: 2016-01-29 08:23+0000\n" "Last-Translator: Dorian Cantzen \n" "Language-Team: Greek (http://www.transifex.com/coders4help/volunteer-planner/language/el/)\n" @@ -37,6 +37,18 @@ msgstr "" msgid "Accounts" msgstr "Λογαριασμοί" +msgid "Username must start with a letter." +msgstr "" + +msgid "Invalid username. Allowed characters are letters, numbers, \".\" and \"_\"." +msgstr "" + +msgid "Username must end with a letter or a number." +msgstr "" + +msgid "Username must not contain consecutive . or _ characters." +msgstr "" + msgid "Accept privacy policy" msgstr "" diff --git a/locale/en/LC_MESSAGES/django.po b/locale/en/LC_MESSAGES/django.po index 7b0bdff3..0ace3c9f 100644 --- a/locale/en/LC_MESSAGES/django.po +++ b/locale/en/LC_MESSAGES/django.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-03-25 11:54+0100\n" +"POT-Creation-Date: 2022-03-25 21:54+0100\n" "PO-Revision-Date: 2015-10-04 21:53+0000\n" "Last-Translator: Dorian Cantzen \n" "Language-Team: English (http://www.transifex.com/coders4help/volunteer-planner/language/en/)\n" @@ -29,6 +29,18 @@ msgstr "" msgid "Accounts" msgstr "" +msgid "Username must start with a letter." +msgstr "" + +msgid "Invalid username. Allowed characters are letters, numbers, \".\" and \"_\"." +msgstr "" + +msgid "Username must end with a letter or a number." +msgstr "" + +msgid "Username must not contain consecutive . or _ characters." +msgstr "" + msgid "Accept privacy policy" msgstr "" diff --git a/locale/es/LC_MESSAGES/django.po b/locale/es/LC_MESSAGES/django.po index d7ea2d15..93822496 100644 --- a/locale/es/LC_MESSAGES/django.po +++ b/locale/es/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: volunteer-planner.org\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-03-25 11:54+0100\n" +"POT-Creation-Date: 2022-03-25 21:54+0100\n" "PO-Revision-Date: 2016-04-13 17:27+0000\n" "Last-Translator: Antonio Mireles \n" "Language-Team: Spanish (http://www.transifex.com/coders4help/volunteer-planner/language/es/)\n" @@ -36,6 +36,18 @@ msgstr "" msgid "Accounts" msgstr "Cuentas" +msgid "Username must start with a letter." +msgstr "" + +msgid "Invalid username. Allowed characters are letters, numbers, \".\" and \"_\"." +msgstr "" + +msgid "Username must end with a letter or a number." +msgstr "" + +msgid "Username must not contain consecutive . or _ characters." +msgstr "" + msgid "Accept privacy policy" msgstr "" diff --git a/locale/es_MX/LC_MESSAGES/django.po b/locale/es_MX/LC_MESSAGES/django.po index d51212cb..9e682e11 100644 --- a/locale/es_MX/LC_MESSAGES/django.po +++ b/locale/es_MX/LC_MESSAGES/django.po @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: volunteer-planner.org\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-03-25 11:54+0100\n" +"POT-Creation-Date: 2022-03-25 21:54+0100\n" "PO-Revision-Date: 2015-09-24 12:23+0000\n" "Last-Translator: Dorian Cantzen \n" "Language-Team: Spanish (Mexico) (http://www.transifex.com/coders4help/volunteer-planner/language/es_MX/)\n" @@ -32,6 +32,18 @@ msgstr "" msgid "Accounts" msgstr "" +msgid "Username must start with a letter." +msgstr "" + +msgid "Invalid username. Allowed characters are letters, numbers, \".\" and \"_\"." +msgstr "" + +msgid "Username must end with a letter or a number." +msgstr "" + +msgid "Username must not contain consecutive . or _ characters." +msgstr "" + msgid "Accept privacy policy" msgstr "" diff --git a/locale/fa/LC_MESSAGES/django.po b/locale/fa/LC_MESSAGES/django.po index dd492624..84a2d55e 100644 --- a/locale/fa/LC_MESSAGES/django.po +++ b/locale/fa/LC_MESSAGES/django.po @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: volunteer-planner.org\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-03-25 11:54+0100\n" +"POT-Creation-Date: 2022-03-25 21:54+0100\n" "PO-Revision-Date: 2016-01-29 08:23+0000\n" "Last-Translator: Dorian Cantzen \n" "Language-Team: Persian (http://www.transifex.com/coders4help/volunteer-planner/language/fa/)\n" @@ -32,6 +32,18 @@ msgstr "" msgid "Accounts" msgstr "" +msgid "Username must start with a letter." +msgstr "" + +msgid "Invalid username. Allowed characters are letters, numbers, \".\" and \"_\"." +msgstr "" + +msgid "Username must end with a letter or a number." +msgstr "" + +msgid "Username must not contain consecutive . or _ characters." +msgstr "" + msgid "Accept privacy policy" msgstr "" diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po index 79b54ac2..1828a3d4 100644 --- a/locale/fr/LC_MESSAGES/django.po +++ b/locale/fr/LC_MESSAGES/django.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: volunteer-planner.org\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-03-25 11:54+0100\n" +"POT-Creation-Date: 2022-03-25 21:54+0100\n" "PO-Revision-Date: 2016-12-08 20:50+0000\n" "Last-Translator: Dolfeus \n" "Language-Team: French (http://www.transifex.com/coders4help/volunteer-planner/language/fr/)\n" @@ -38,6 +38,18 @@ msgstr "" msgid "Accounts" msgstr "Comptes utilisateur" +msgid "Username must start with a letter." +msgstr "" + +msgid "Invalid username. Allowed characters are letters, numbers, \".\" and \"_\"." +msgstr "" + +msgid "Username must end with a letter or a number." +msgstr "" + +msgid "Username must not contain consecutive . or _ characters." +msgstr "" + msgid "Accept privacy policy" msgstr "" diff --git a/locale/hr/LC_MESSAGES/django.po b/locale/hr/LC_MESSAGES/django.po index f3f86696..1ea14fcd 100644 --- a/locale/hr/LC_MESSAGES/django.po +++ b/locale/hr/LC_MESSAGES/django.po @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: volunteer-planner.org\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-03-25 11:54+0100\n" +"POT-Creation-Date: 2022-03-25 21:54+0100\n" "PO-Revision-Date: 2016-01-29 08:23+0000\n" "Last-Translator: Dorian Cantzen \n" "Language-Team: Croatian (http://www.transifex.com/coders4help/volunteer-planner/language/hr/)\n" @@ -32,6 +32,18 @@ msgstr "" msgid "Accounts" msgstr "" +msgid "Username must start with a letter." +msgstr "" + +msgid "Invalid username. Allowed characters are letters, numbers, \".\" and \"_\"." +msgstr "" + +msgid "Username must end with a letter or a number." +msgstr "" + +msgid "Username must not contain consecutive . or _ characters." +msgstr "" + msgid "Accept privacy policy" msgstr "" diff --git a/locale/hu/LC_MESSAGES/django.po b/locale/hu/LC_MESSAGES/django.po index 2f8aa580..a2ddbca9 100644 --- a/locale/hu/LC_MESSAGES/django.po +++ b/locale/hu/LC_MESSAGES/django.po @@ -14,7 +14,7 @@ msgid "" msgstr "" "Project-Id-Version: volunteer-planner.org\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-03-25 11:54+0100\n" +"POT-Creation-Date: 2022-03-25 21:54+0100\n" "PO-Revision-Date: 2016-01-29 08:23+0000\n" "Last-Translator: Dorian Cantzen \n" "Language-Team: Hungarian (http://www.transifex.com/coders4help/volunteer-planner/language/hu/)\n" @@ -42,6 +42,18 @@ msgstr "" msgid "Accounts" msgstr "" +msgid "Username must start with a letter." +msgstr "" + +msgid "Invalid username. Allowed characters are letters, numbers, \".\" and \"_\"." +msgstr "" + +msgid "Username must end with a letter or a number." +msgstr "" + +msgid "Username must not contain consecutive . or _ characters." +msgstr "" + msgid "Accept privacy policy" msgstr "" diff --git a/locale/hy/LC_MESSAGES/django.po b/locale/hy/LC_MESSAGES/django.po index b2a74449..7d463319 100644 --- a/locale/hy/LC_MESSAGES/django.po +++ b/locale/hy/LC_MESSAGES/django.po @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: volunteer-planner.org\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-03-25 11:54+0100\n" +"POT-Creation-Date: 2022-03-25 21:54+0100\n" "PO-Revision-Date: 2015-09-24 12:23+0000\n" "Last-Translator: Dorian Cantzen \n" "Language-Team: Armenian (http://www.transifex.com/coders4help/volunteer-planner/language/hy/)\n" @@ -32,6 +32,18 @@ msgstr "" msgid "Accounts" msgstr "" +msgid "Username must start with a letter." +msgstr "" + +msgid "Invalid username. Allowed characters are letters, numbers, \".\" and \"_\"." +msgstr "" + +msgid "Username must end with a letter or a number." +msgstr "" + +msgid "Username must not contain consecutive . or _ characters." +msgstr "" + msgid "Accept privacy policy" msgstr "" diff --git a/locale/it/LC_MESSAGES/django.po b/locale/it/LC_MESSAGES/django.po index 3f3532f0..791e19f6 100644 --- a/locale/it/LC_MESSAGES/django.po +++ b/locale/it/LC_MESSAGES/django.po @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: volunteer-planner.org\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-03-25 11:54+0100\n" +"POT-Creation-Date: 2022-03-25 21:54+0100\n" "PO-Revision-Date: 2016-01-29 08:23+0000\n" "Last-Translator: Dorian Cantzen \n" "Language-Team: Italian (http://www.transifex.com/coders4help/volunteer-planner/language/it/)\n" @@ -32,6 +32,18 @@ msgstr "" msgid "Accounts" msgstr "" +msgid "Username must start with a letter." +msgstr "" + +msgid "Invalid username. Allowed characters are letters, numbers, \".\" and \"_\"." +msgstr "" + +msgid "Username must end with a letter or a number." +msgstr "" + +msgid "Username must not contain consecutive . or _ characters." +msgstr "" + msgid "Accept privacy policy" msgstr "" diff --git a/locale/nl/LC_MESSAGES/django.po b/locale/nl/LC_MESSAGES/django.po index 1cf82bae..cce3c6ca 100644 --- a/locale/nl/LC_MESSAGES/django.po +++ b/locale/nl/LC_MESSAGES/django.po @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: volunteer-planner.org\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-03-25 11:54+0100\n" +"POT-Creation-Date: 2022-03-25 21:54+0100\n" "PO-Revision-Date: 2016-01-29 08:23+0000\n" "Last-Translator: Dorian Cantzen \n" "Language-Team: Dutch (http://www.transifex.com/coders4help/volunteer-planner/language/nl/)\n" @@ -32,6 +32,18 @@ msgstr "" msgid "Accounts" msgstr "" +msgid "Username must start with a letter." +msgstr "" + +msgid "Invalid username. Allowed characters are letters, numbers, \".\" and \"_\"." +msgstr "" + +msgid "Username must end with a letter or a number." +msgstr "" + +msgid "Username must not contain consecutive . or _ characters." +msgstr "" + msgid "Accept privacy policy" msgstr "" diff --git a/locale/no/LC_MESSAGES/django.po b/locale/no/LC_MESSAGES/django.po index 42a32165..ce4819fe 100644 --- a/locale/no/LC_MESSAGES/django.po +++ b/locale/no/LC_MESSAGES/django.po @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: volunteer-planner.org\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-03-25 11:54+0100\n" +"POT-Creation-Date: 2022-03-25 21:54+0100\n" "PO-Revision-Date: 2016-01-29 08:23+0000\n" "Last-Translator: Dorian Cantzen \n" "Language-Team: Norwegian (http://www.transifex.com/coders4help/volunteer-planner/language/no/)\n" @@ -32,6 +32,18 @@ msgstr "" msgid "Accounts" msgstr "" +msgid "Username must start with a letter." +msgstr "" + +msgid "Invalid username. Allowed characters are letters, numbers, \".\" and \"_\"." +msgstr "" + +msgid "Username must end with a letter or a number." +msgstr "" + +msgid "Username must not contain consecutive . or _ characters." +msgstr "" + msgid "Accept privacy policy" msgstr "" diff --git a/locale/pl/LC_MESSAGES/django.po b/locale/pl/LC_MESSAGES/django.po index 60e59339..594ae4ec 100644 --- a/locale/pl/LC_MESSAGES/django.po +++ b/locale/pl/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: volunteer-planner.org\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-03-25 11:54+0100\n" +"POT-Creation-Date: 2022-03-25 21:54+0100\n" "PO-Revision-Date: 2017-09-22 15:29+0000\n" "Last-Translator: Dorian Cantzen \n" "Language-Team: Polish (http://www.transifex.com/coders4help/volunteer-planner/language/pl/)\n" @@ -36,6 +36,18 @@ msgstr "" msgid "Accounts" msgstr "" +msgid "Username must start with a letter." +msgstr "" + +msgid "Invalid username. Allowed characters are letters, numbers, \".\" and \"_\"." +msgstr "" + +msgid "Username must end with a letter or a number." +msgstr "" + +msgid "Username must not contain consecutive . or _ characters." +msgstr "" + msgid "Accept privacy policy" msgstr "" diff --git a/locale/pt/LC_MESSAGES/django.po b/locale/pt/LC_MESSAGES/django.po index f2218a5d..79187890 100644 --- a/locale/pt/LC_MESSAGES/django.po +++ b/locale/pt/LC_MESSAGES/django.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: volunteer-planner.org\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-03-25 11:54+0100\n" +"POT-Creation-Date: 2022-03-25 21:54+0100\n" "PO-Revision-Date: 2016-01-29 08:23+0000\n" "Last-Translator: Dorian Cantzen \n" "Language-Team: Portuguese (http://www.transifex.com/coders4help/volunteer-planner/language/pt/)\n" @@ -37,6 +37,18 @@ msgstr "" msgid "Accounts" msgstr "Contas" +msgid "Username must start with a letter." +msgstr "" + +msgid "Invalid username. Allowed characters are letters, numbers, \".\" and \"_\"." +msgstr "" + +msgid "Username must end with a letter or a number." +msgstr "" + +msgid "Username must not contain consecutive . or _ characters." +msgstr "" + msgid "Accept privacy policy" msgstr "" diff --git a/locale/pt_BR/LC_MESSAGES/django.po b/locale/pt_BR/LC_MESSAGES/django.po index d5ac6387..dbc00a03 100644 --- a/locale/pt_BR/LC_MESSAGES/django.po +++ b/locale/pt_BR/LC_MESSAGES/django.po @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: volunteer-planner.org\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-03-25 11:54+0100\n" +"POT-Creation-Date: 2022-03-25 21:54+0100\n" "PO-Revision-Date: 2015-09-24 12:23+0000\n" "Last-Translator: Dorian Cantzen \n" "Language-Team: Portuguese (Brazil) (http://www.transifex.com/coders4help/volunteer-planner/language/pt_BR/)\n" @@ -32,6 +32,18 @@ msgstr "" msgid "Accounts" msgstr "" +msgid "Username must start with a letter." +msgstr "" + +msgid "Invalid username. Allowed characters are letters, numbers, \".\" and \"_\"." +msgstr "" + +msgid "Username must end with a letter or a number." +msgstr "" + +msgid "Username must not contain consecutive . or _ characters." +msgstr "" + msgid "Accept privacy policy" msgstr "" diff --git a/locale/ro/LC_MESSAGES/django.po b/locale/ro/LC_MESSAGES/django.po index 111f5f6f..ba61aa90 100644 --- a/locale/ro/LC_MESSAGES/django.po +++ b/locale/ro/LC_MESSAGES/django.po @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: volunteer-planner.org\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-03-25 11:54+0100\n" +"POT-Creation-Date: 2022-03-25 21:54+0100\n" "PO-Revision-Date: 2016-01-29 08:23+0000\n" "Last-Translator: Dorian Cantzen \n" "Language-Team: Romanian (http://www.transifex.com/coders4help/volunteer-planner/language/ro/)\n" @@ -32,6 +32,18 @@ msgstr "" msgid "Accounts" msgstr "" +msgid "Username must start with a letter." +msgstr "" + +msgid "Invalid username. Allowed characters are letters, numbers, \".\" and \"_\"." +msgstr "" + +msgid "Username must end with a letter or a number." +msgstr "" + +msgid "Username must not contain consecutive . or _ characters." +msgstr "" + msgid "Accept privacy policy" msgstr "" diff --git a/locale/ru/LC_MESSAGES/django.po b/locale/ru/LC_MESSAGES/django.po index a411c2c4..34d6db23 100644 --- a/locale/ru/LC_MESSAGES/django.po +++ b/locale/ru/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: volunteer-planner.org\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-03-25 11:54+0100\n" +"POT-Creation-Date: 2022-03-25 21:54+0100\n" "PO-Revision-Date: 2022-03-10 13:42+0000\n" "Last-Translator: Anna Dunn\n" "Language-Team: Russian (http://www.transifex.com/coders4help/volunteer-planner/language/ru/)\n" @@ -36,6 +36,18 @@ msgstr "" msgid "Accounts" msgstr "Aккаунты" +msgid "Username must start with a letter." +msgstr "" + +msgid "Invalid username. Allowed characters are letters, numbers, \".\" and \"_\"." +msgstr "" + +msgid "Username must end with a letter or a number." +msgstr "" + +msgid "Username must not contain consecutive . or _ characters." +msgstr "" + msgid "Accept privacy policy" msgstr "" diff --git a/locale/sk/LC_MESSAGES/django.po b/locale/sk/LC_MESSAGES/django.po index 3aa11b9d..e84be4ff 100644 --- a/locale/sk/LC_MESSAGES/django.po +++ b/locale/sk/LC_MESSAGES/django.po @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: volunteer-planner.org\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-03-25 11:54+0100\n" +"POT-Creation-Date: 2022-03-25 21:54+0100\n" "PO-Revision-Date: 2016-01-29 08:23+0000\n" "Last-Translator: Dorian Cantzen \n" "Language-Team: Slovak (http://www.transifex.com/coders4help/volunteer-planner/language/sk/)\n" @@ -32,6 +32,18 @@ msgstr "" msgid "Accounts" msgstr "" +msgid "Username must start with a letter." +msgstr "" + +msgid "Invalid username. Allowed characters are letters, numbers, \".\" and \"_\"." +msgstr "" + +msgid "Username must end with a letter or a number." +msgstr "" + +msgid "Username must not contain consecutive . or _ characters." +msgstr "" + msgid "Accept privacy policy" msgstr "" diff --git a/locale/sl/LC_MESSAGES/django.po b/locale/sl/LC_MESSAGES/django.po index 44471158..2043a674 100644 --- a/locale/sl/LC_MESSAGES/django.po +++ b/locale/sl/LC_MESSAGES/django.po @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: volunteer-planner.org\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-03-25 11:54+0100\n" +"POT-Creation-Date: 2022-03-25 21:54+0100\n" "PO-Revision-Date: 2016-01-29 08:23+0000\n" "Last-Translator: Dorian Cantzen \n" "Language-Team: Slovenian (http://www.transifex.com/coders4help/volunteer-planner/language/sl/)\n" @@ -32,6 +32,18 @@ msgstr "" msgid "Accounts" msgstr "" +msgid "Username must start with a letter." +msgstr "" + +msgid "Invalid username. Allowed characters are letters, numbers, \".\" and \"_\"." +msgstr "" + +msgid "Username must end with a letter or a number." +msgstr "" + +msgid "Username must not contain consecutive . or _ characters." +msgstr "" + msgid "Accept privacy policy" msgstr "" diff --git a/locale/sq/LC_MESSAGES/django.po b/locale/sq/LC_MESSAGES/django.po index ff9f1e21..6c3ff5c1 100644 --- a/locale/sq/LC_MESSAGES/django.po +++ b/locale/sq/LC_MESSAGES/django.po @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: volunteer-planner.org\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-03-25 11:54+0100\n" +"POT-Creation-Date: 2022-03-25 21:54+0100\n" "PO-Revision-Date: 2016-01-29 08:23+0000\n" "Last-Translator: Dorian Cantzen \n" "Language-Team: Albanian (http://www.transifex.com/coders4help/volunteer-planner/language/sq/)\n" @@ -32,6 +32,18 @@ msgstr "" msgid "Accounts" msgstr "" +msgid "Username must start with a letter." +msgstr "" + +msgid "Invalid username. Allowed characters are letters, numbers, \".\" and \"_\"." +msgstr "" + +msgid "Username must end with a letter or a number." +msgstr "" + +msgid "Username must not contain consecutive . or _ characters." +msgstr "" + msgid "Accept privacy policy" msgstr "" diff --git a/locale/sr_RS/LC_MESSAGES/django.po b/locale/sr_RS/LC_MESSAGES/django.po index 1457fb7d..23d3450c 100644 --- a/locale/sr_RS/LC_MESSAGES/django.po +++ b/locale/sr_RS/LC_MESSAGES/django.po @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: volunteer-planner.org\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-03-25 11:54+0100\n" +"POT-Creation-Date: 2022-03-25 21:54+0100\n" "PO-Revision-Date: 2016-01-29 08:23+0000\n" "Last-Translator: Dorian Cantzen \n" "Language-Team: Serbian (Serbia) (http://www.transifex.com/coders4help/volunteer-planner/language/sr_RS/)\n" @@ -32,6 +32,18 @@ msgstr "" msgid "Accounts" msgstr "" +msgid "Username must start with a letter." +msgstr "" + +msgid "Invalid username. Allowed characters are letters, numbers, \".\" and \"_\"." +msgstr "" + +msgid "Username must end with a letter or a number." +msgstr "" + +msgid "Username must not contain consecutive . or _ characters." +msgstr "" + msgid "Accept privacy policy" msgstr "" diff --git a/locale/sv/LC_MESSAGES/django.po b/locale/sv/LC_MESSAGES/django.po index 27041b89..04be3460 100644 --- a/locale/sv/LC_MESSAGES/django.po +++ b/locale/sv/LC_MESSAGES/django.po @@ -11,7 +11,7 @@ msgid "" msgstr "" "Project-Id-Version: volunteer-planner.org\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-03-25 11:54+0100\n" +"POT-Creation-Date: 2022-03-25 21:54+0100\n" "PO-Revision-Date: 2016-01-29 08:23+0000\n" "Last-Translator: Dorian Cantzen \n" "Language-Team: Swedish (http://www.transifex.com/coders4help/volunteer-planner/language/sv/)\n" @@ -39,6 +39,18 @@ msgstr "" msgid "Accounts" msgstr "Konton" +msgid "Username must start with a letter." +msgstr "" + +msgid "Invalid username. Allowed characters are letters, numbers, \".\" and \"_\"." +msgstr "" + +msgid "Username must end with a letter or a number." +msgstr "" + +msgid "Username must not contain consecutive . or _ characters." +msgstr "" + msgid "Accept privacy policy" msgstr "" diff --git a/locale/tr/LC_MESSAGES/django.po b/locale/tr/LC_MESSAGES/django.po index 2222e46d..73997bb3 100644 --- a/locale/tr/LC_MESSAGES/django.po +++ b/locale/tr/LC_MESSAGES/django.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: volunteer-planner.org\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-03-25 11:54+0100\n" +"POT-Creation-Date: 2022-03-25 21:54+0100\n" "PO-Revision-Date: 2016-01-29 08:23+0000\n" "Last-Translator: Dorian Cantzen \n" "Language-Team: Turkish (http://www.transifex.com/coders4help/volunteer-planner/language/tr/)\n" @@ -33,6 +33,18 @@ msgstr "" msgid "Accounts" msgstr "" +msgid "Username must start with a letter." +msgstr "" + +msgid "Invalid username. Allowed characters are letters, numbers, \".\" and \"_\"." +msgstr "" + +msgid "Username must end with a letter or a number." +msgstr "" + +msgid "Username must not contain consecutive . or _ characters." +msgstr "" + msgid "Accept privacy policy" msgstr "" diff --git a/locale/tr_TR/LC_MESSAGES/django.po b/locale/tr_TR/LC_MESSAGES/django.po index 2a096526..6cc201ec 100644 --- a/locale/tr_TR/LC_MESSAGES/django.po +++ b/locale/tr_TR/LC_MESSAGES/django.po @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: volunteer-planner.org\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-03-25 11:54+0100\n" +"POT-Creation-Date: 2022-03-25 21:54+0100\n" "PO-Revision-Date: 2015-09-24 12:23+0000\n" "Last-Translator: Dorian Cantzen \n" "Language-Team: Turkish (Turkey) (http://www.transifex.com/coders4help/volunteer-planner/language/tr_TR/)\n" @@ -32,6 +32,18 @@ msgstr "" msgid "Accounts" msgstr "" +msgid "Username must start with a letter." +msgstr "" + +msgid "Invalid username. Allowed characters are letters, numbers, \".\" and \"_\"." +msgstr "" + +msgid "Username must end with a letter or a number." +msgstr "" + +msgid "Username must not contain consecutive . or _ characters." +msgstr "" + msgid "Accept privacy policy" msgstr "" diff --git a/locale/uk/LC_MESSAGES/django.po b/locale/uk/LC_MESSAGES/django.po index 5595ed44..19f7368b 100644 --- a/locale/uk/LC_MESSAGES/django.po +++ b/locale/uk/LC_MESSAGES/django.po @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: volunteer-planner.org\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-03-25 11:54+0100\n" +"POT-Creation-Date: 2022-03-25 21:54+0100\n" "PO-Revision-Date: 2015-09-24 12:23+0000\n" "Last-Translator: Dorian Cantzen \n" "Language-Team: Ukrainian (http://www.transifex.com/coders4help/volunteer-planner/language/uk/)\n" @@ -32,6 +32,18 @@ msgstr "" msgid "Accounts" msgstr "" +msgid "Username must start with a letter." +msgstr "" + +msgid "Invalid username. Allowed characters are letters, numbers, \".\" and \"_\"." +msgstr "" + +msgid "Username must end with a letter or a number." +msgstr "" + +msgid "Username must not contain consecutive . or _ characters." +msgstr "" + msgid "Accept privacy policy" msgstr "" diff --git a/locale/zh_CN/LC_MESSAGES/django.po b/locale/zh_CN/LC_MESSAGES/django.po index d25b5967..d4e9ffa4 100644 --- a/locale/zh_CN/LC_MESSAGES/django.po +++ b/locale/zh_CN/LC_MESSAGES/django.po @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: volunteer-planner.org\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-03-25 11:54+0100\n" +"POT-Creation-Date: 2022-03-25 21:54+0100\n" "PO-Revision-Date: 2015-09-24 12:23+0000\n" "Last-Translator: Dorian Cantzen \n" "Language-Team: Chinese (China) (http://www.transifex.com/coders4help/volunteer-planner/language/zh_CN/)\n" @@ -32,6 +32,18 @@ msgstr "" msgid "Accounts" msgstr "" +msgid "Username must start with a letter." +msgstr "" + +msgid "Invalid username. Allowed characters are letters, numbers, \".\" and \"_\"." +msgstr "" + +msgid "Username must end with a letter or a number." +msgstr "" + +msgid "Username must not contain consecutive . or _ characters." +msgstr "" + msgid "Accept privacy policy" msgstr "" diff --git a/templates/registration/registration_form.html b/templates/registration/registration_form.html index 745cdbe1..293b721c 100644 --- a/templates/registration/registration_form.html +++ b/templates/registration/registration_form.html @@ -24,7 +24,7 @@

{% trans "Create a new account" %}

class="form-control" placeholder="{% trans "Email" %}" name="email" - value="{{ form.cleaned_data.email }}"> + value="{{ form.cleaned_data.email|default:form.email.value }}">

{% trans "Volunteer-Planner and shelters will send you emails concerning your shifts." %}

@@ -39,7 +39,7 @@

{% trans "Create a new account" %}

id="Username" placeholder="{% trans "Username" %}" name="username" - value="{{ form.cleaned_data.username }}"> + value="{{ form.cleaned_data.username|default:form.username.value }}">

{% trans "Your username will be visible to other users. Don't use spaces or special characters." %}

diff --git a/tests/registration/test_registration.py b/tests/registration/test_registration.py index 3f57e226..11f03df4 100644 --- a/tests/registration/test_registration.py +++ b/tests/registration/test_registration.py @@ -10,7 +10,6 @@ @override_settings(LANGUAGE_CODE="en", LANGUAGES=(("en", "English"),)) class RegistrationTestCase(TestCase): def setUp(self): - # TODO: fix typo in url name in urls.py self.registration_url = reverse("registration_register") self.valid_user_data = { @@ -51,6 +50,7 @@ def test_invalid_email(self): "email": "invalid-address", "password1": "somepassword", "password2": "differentpassword", + "accept_privacy_policy": True, } response = self.client.post(self.registration_url, user_data) @@ -65,7 +65,7 @@ def test_invalid_email(self): assert RegistrationProfile.objects.count() == 0 - def try_invalid_username(self, invalid_username): + def try_invalid_username(self, invalid_username, expected_errors): """ helper method for the next couple of tests checking invalid usernames """ @@ -74,6 +74,7 @@ def try_invalid_username(self, invalid_username): "email": "somename@example.de", "password1": "somepassword", "password2": "somepassword", + "accept_privacy_policy": True, } response = self.client.post(self.registration_url, user_data) @@ -85,20 +86,113 @@ def try_invalid_username(self, invalid_username): response, "form", "username", - "Enter a valid username. This value may contain only letters, numbers, and " - "@/./+/-/_ characters.", + expected_errors, ) assert RegistrationProfile.objects.count() == 0 + def test_username_beginning(self): + self.try_invalid_username("1username", "Username must start with a letter.") + self.try_invalid_username(".username", "Username must start with a letter.") + self.try_invalid_username("_username", "Username must start with a letter.") + + def test_username_ending(self): + self.try_invalid_username( + "username_", "Username must end with a letter or a number." + ) + self.try_invalid_username( + "username.", "Username must end with a letter or a number." + ) + + def test_username_too_short(self): + self.try_invalid_username( + "ab", "Ensure this value has at least 3 characters (it has 2)." + ) + + def test_username_too_long(self): + self.try_invalid_username( + "abcdef_0123456789", + "Ensure this value has at most 16 characters (it has 17).", + ) + + def test_username_with_consequtive_underscores(self): + self.try_invalid_username( + "invalid__name", "Username must not contain consecutive . or _ characters." + ) + + self.try_invalid_username( + "invalid___name", "Username must not contain consecutive . or _ characters." + ) + + def test_username_with_consequtive_dots(self): + self.try_invalid_username( + "invalid..name", "Username must not contain consecutive . or _ characters." + ) + self.try_invalid_username( + "invalid...name", "Username must not contain consecutive . or _ characters." + ) + + def test_username_with_consequtive_funnystuff(self): + self.try_invalid_username( + "invalid._._name", + "Username must not contain consecutive . or _ characters.", + ) + self.try_invalid_username( + "invalid_._name", "Username must not contain consecutive . or _ characters." + ) + def test_username_with_whitespaces(self): - self.try_invalid_username("some invalid name") + self.try_invalid_username( + "user name", + "Invalid username. " + 'Allowed characters are letters, numbers, "." and "_".', + ) + self.try_invalid_username( + " username", + [ + "Username must start with a letter.", + "Invalid username. " + 'Allowed characters are letters, numbers, "." and "_".', + ], + ) + self.try_invalid_username( + "username ", + [ + "Username must end with a letter or a number.", + "Invalid username. " + 'Allowed characters are letters, numbers, "." and "_".', + ], + ) + self.try_invalid_username( + " username ", + [ + "Username must start with a letter.", + "Username must end with a letter or a number.", + "Invalid username. " + 'Allowed characters are letters, numbers, "." and "_".', + ], + ) + self.try_invalid_username( + " user name ", + [ + "Username must start with a letter.", + "Username must end with a letter or a number.", + "Invalid username. " + 'Allowed characters are letters, numbers, "." and "_".', + ], + ) def test_username_with_special_chars(self): - self.try_invalid_username("someinvalidname$") + self.try_invalid_username( + "invalidname$", + 'Invalid username. Allowed characters are letters, numbers, "." and "_".', + ) def test_username_with_umlauts(self): - self.try_invalid_username("somename with ÖÄÜäöüß") + self.try_invalid_username( + "aÖÄÜäöüß", + 'Invalid username. Allowed characters are letters, numbers, "." and "_".', + ) def test_username_exists_already(self): # register first user @@ -118,15 +212,62 @@ def test_username_exists_already(self): assert RegistrationProfile.objects.count() == 1 + def test_privacy_policy_missing(self): + user_data = { + "username": "somename", + "email": "somename@example.de", + "password1": "somepassword", + "password2": "somepassword", + # "accept_privacy_policy": True, + } + + response = self.client.post(self.registration_url, user_data, follow=True) + + form = response.context["form"] + assert ( + form is not None + ), "We expect the form to be displayed again if the submission failed" + + self.assertFormError( + response, "form", "accept_privacy_policy", "This field is required." + ) + + assert RegistrationProfile.objects.count() == 0 + + def test_privacy_policy_not_accepted(self): + user_data = { + "username": "somename", + "email": "somename@example.de", + "password1": "somepassword", + "password2": "somepassword", + "accept_privacy_policy": "false", + } + + response = self.client.post(self.registration_url, user_data, follow=True) + + assert RegistrationProfile.objects.count() == 0 + + form = response.context["form"] + assert ( + form is not None + ), "We expect the form to be displayed again if the submission failed" + + self.assertFormError( + response, "form", "accept_privacy_policy", "This field is required." + ) + def test_passwords_dont_match(self): user_data = { "username": "somename", "email": "somename@example.de", "password1": "somepassword", "password2": "differentpassword", + "accept_privacy_policy": True, } - response = self.client.post(self.registration_url, user_data) + response = self.client.post(self.registration_url, user_data, follow=True) + + assert RegistrationProfile.objects.count() == 0 form = response.context["form"] assert ( @@ -139,8 +280,6 @@ def test_passwords_dont_match(self): response, "form", "password2", "The two password fields didn’t match." ) - assert RegistrationProfile.objects.count() == 0 - def test_submit_valid_form(self): response = self.client.post( self.registration_url, self.valid_user_data, follow=True