From b24be481d7e1c27ce24d3f8f7f8d4d2998090eeb Mon Sep 17 00:00:00 2001 From: Aevann Date: Wed, 4 Oct 2023 15:29:41 +0300 Subject: [PATCH] new_name->new_flair, title->flair --- files/helpers/config/const.py | 2 +- files/routes/admin.py | 18 +++++++++--------- files/routes/settings.py | 4 ++-- files/templates/settings/personal.html | 2 +- files/templates/userpage/admintools.html | 4 ++-- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/files/helpers/config/const.py b/files/helpers/config/const.py index 5db67c94a..6bc3048ca 100644 --- a/files/helpers/config/const.py +++ b/files/helpers/config/const.py @@ -342,7 +342,7 @@ PERMS = { # Minimum admin_level to perform action. 'IS_PERMA_PROGSTACKED': 2, 'USER_BADGES': 2, 'USER_LINK': 2, - 'USER_TITLE_CHANGE': 2, + 'USER_CHANGE_FLAIR': 2, 'LOTTERY_VIEW_PARTICIPANTS': 2, 'POST_COMMENT_INFINITE_PINGS': 2, 'IGNORE_1WEEk_EDITING_LIMIT': 2, diff --git a/files/routes/admin.py b/files/routes/admin.py index 74b7b4874..3f832cc93 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -897,24 +897,24 @@ def unshadowban(user_id, v): return {"message": f"@{user.username} has been unshadowbanned!"} -@app.post("/admin/title_change/") +@app.post("/admin/change_flair/") @limiter.limit('1/second', scope=rpath) @limiter.limit('1/second', scope=rpath, key_func=get_ID) @limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400) @limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID) -@admin_level_required(PERMS['USER_TITLE_CHANGE']) -def admin_title_change(user_id, v): +@admin_level_required(PERMS['USER_CHANGE_FLAIR']) +def admin_change_flair(user_id, v): user = get_account(user_id) - new_name = request.values.get("title")[:256].strip() + new_flair = request.values.get("title")[:256].strip() - user.customtitleplain = new_name - new_name = filter_emojis_only(new_name) - new_name = censor_slurs_profanities(new_name, None) + user.customtitleplain = new_flair + new_flair = filter_emojis_only(new_flair) + new_flair = censor_slurs_profanities(new_flair, None) user = get_account(user.id) - user.customtitle=new_name + user.customtitle = new_flair if request.values.get("locked"): user.flairchanged = int(time.time()) + 2629746 badge_grant(user=user, badge_id=96) @@ -932,7 +932,7 @@ def admin_title_change(user_id, v): kind=kind, user_id=v.id, target_user_id=user.id, - _note=f'"{new_name}"' + _note=f'"{new_flair}"' ) g.db.add(ma) diff --git a/files/routes/settings.py b/files/routes/settings.py index 813835e42..25efb68cc 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -891,13 +891,13 @@ def process_settings_plaintext(value, current, length, default_value): return value -@app.post("/settings/title_change") +@app.post("/settings/change_flair") @limiter.limit('1/second', scope=rpath) @limiter.limit('1/second', scope=rpath, key_func=get_ID) @limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400) @limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID) @auth_required -def settings_title_change(v): +def settings_change_flair(v): if v.flairchanged: abort(403) customtitleplain = process_settings_plaintext("title", v.customtitleplain, 100, None) diff --git a/files/templates/settings/personal.html b/files/templates/settings/personal.html index f7edf4823..ccd2cae73 100644 --- a/files/templates/settings/personal.html +++ b/files/templates/settings/personal.html @@ -202,7 +202,7 @@ {{common.line_text_section('pronouns', '/settings/pronouns_change', 'pronouns', 'Pronouns', v.pronouns, 'Limit of 15 characters', 'Enter pronouns here', 'Change Pronouns', false, 3, 15, '([a-zA-Z]{1,7})/[a-zA-Z]{1,7}(/[a-zA-Z]{1,7})?', false)}} {% endif %} - {{common.line_text_section('flair', '/settings/title_change', 'title', 'Flair', v.customtitleplain, 'Limit of 100 characters', 'Enter a flair here', 'Change Flair', true, 0, 100, '.*', v.flairchanged)}} + {{common.line_text_section('flair', '/settings/change_flair', 'title', 'Flair', v.customtitleplain, 'Limit of 100 characters', 'Enter a flair here', 'Change Flair', true, 0, 100, '.*', v.flairchanged)}} {{common.color_section('flaircolor', '/settings/titlecolor', 'titlecolor', 'Flair Color', v.titlecolor)}} diff --git a/files/templates/userpage/admintools.html b/files/templates/userpage/admintools.html index 98a738e67..2cf2176b0 100644 --- a/files/templates/userpage/admintools.html +++ b/files/templates/userpage/admintools.html @@ -33,10 +33,10 @@ {% macro userAdminTools(deviceType) %} {% if v and v.id != u.id and v.admin_level >= PERMS['USER_MODERATION_TOOLS_VISIBLE'] %}
- {% if v.admin_level >= PERMS['USER_TITLE_CHANGE'] %} + {% if v.admin_level >= PERMS['USER_CHANGE_FLAIR'] %}
-
+