From aa644fd20877017f4a78ea33eebc0a09437b197a Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 23 Jul 2022 08:48:32 +0200 Subject: [PATCH] allow a third pronoun if total character count is 11 or lower --- files/helpers/regex.py | 2 +- files/routes/settings.py | 7 +++++-- files/templates/settings_profile.html | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/files/helpers/regex.py b/files/helpers/regex.py index 0553b96e65..5e62394e40 100644 --- a/files/helpers/regex.py +++ b/files/helpers/regex.py @@ -102,7 +102,7 @@ search_token_regex = re.compile('"([^"]*)"|(\S+)', flags=re.A) git_regex = re.compile("ref: (refs/.+)", flags=re.A) -pronouns_regex = re.compile("([a-z]{2,5}|i)/[a-z]{2,5}", flags=re.A) +pronouns_regex = re.compile("([a-z]{2,5}|i)/[a-z]{2,5}(/[a-z]{2,5})?", flags=re.A) knowledgebase_page_regex = re.compile("[a-zA-Z0-9_\-]+", flags=re.A) diff --git a/files/routes/settings.py b/files/routes/settings.py index 20669bcc84..c7dfd7bf3b 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -892,11 +892,14 @@ def settings_pronouns_change(v): pronouns = request.values.get("pronouns").replace("𒐪","").lower().strip() + if len(pronouns) > 11: + return render_template("settings_profile.html", v=v, error="Your pronouns exceed the character limit (11 characters)") + if pronouns == v.pronouns: - return render_template("settings_profile.html", v=v, error="You didn't change anything") + return render_template("settings_profile.html", v=v, error="You didn't change anything.") if not pronouns_regex.fullmatch(pronouns): - return render_template("settings_profile.html", v=v, error="The pronouns you entered don't match the required format {2-5 characters}/{2-5 characters}") + return render_template("settings_profile.html", v=v, error="The pronouns you entered don't match the required format.") v.pronouns = pronouns g.db.add(v) diff --git a/files/templates/settings_profile.html b/files/templates/settings_profile.html index 58b95cb32d..9a5db74296 100644 --- a/files/templates/settings_profile.html +++ b/files/templates/settings_profile.html @@ -473,7 +473,7 @@
- +
{2-5 characters} / {2-5 characters}