allow a third pronoun if total character count is 11 or lower

master
Aevann1 2022-07-23 08:48:32 +02:00
parent 4723332e07
commit aa644fd208
3 changed files with 7 additions and 4 deletions

View File

@ -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)

View File

@ -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)

View File

@ -473,7 +473,7 @@
<div class="w-lg-100">
<form id="profile-settings" action="/settings/pronouns_change" method="post">
<input type="hidden" name="formkey" value="{{v.formkey}}">
<input minlength=3 maxlength=11 pattern="([a-zA-Z]{2,5}|i|I)/[a-zA-Z]{2,5}" autocomplete="off" id="pronounbody" type="text" name="pronouns" class="form-control" placeholder='Enter pronouns here' value="{% if v.pronouns %}{{v.pronouns}}{% endif %}">
<input minlength=3 maxlength=11 pattern="([a-zA-Z]{2,5}|i|I)/[a-zA-Z]{2,5}(/[a-z]{2,5})?" autocomplete="off" id="pronounbody" type="text" name="pronouns" class="form-control" placeholder='Enter pronouns here' value="{% if v.pronouns %}{{v.pronouns}}{% endif %}">
<div class="d-flex mt-2">
<small>{2-5 characters} / {2-5 characters}</small>
<input autocomplete="off" class="btn btn-primary ml-auto" id="pronounsSave" type="submit" onclick="disable(this)" value="Change Pronouns">