forked from rDrama/rDrama
new_name->new_flair, title->flair
parent
a44ffb8f4a
commit
b24be481d7
|
@ -342,7 +342,7 @@ PERMS = { # Minimum admin_level to perform action.
|
||||||
'IS_PERMA_PROGSTACKED': 2,
|
'IS_PERMA_PROGSTACKED': 2,
|
||||||
'USER_BADGES': 2,
|
'USER_BADGES': 2,
|
||||||
'USER_LINK': 2,
|
'USER_LINK': 2,
|
||||||
'USER_TITLE_CHANGE': 2,
|
'USER_CHANGE_FLAIR': 2,
|
||||||
'LOTTERY_VIEW_PARTICIPANTS': 2,
|
'LOTTERY_VIEW_PARTICIPANTS': 2,
|
||||||
'POST_COMMENT_INFINITE_PINGS': 2,
|
'POST_COMMENT_INFINITE_PINGS': 2,
|
||||||
'IGNORE_1WEEk_EDITING_LIMIT': 2,
|
'IGNORE_1WEEk_EDITING_LIMIT': 2,
|
||||||
|
|
|
@ -897,24 +897,24 @@ def unshadowban(user_id, v):
|
||||||
return {"message": f"@{user.username} has been unshadowbanned!"}
|
return {"message": f"@{user.username} has been unshadowbanned!"}
|
||||||
|
|
||||||
|
|
||||||
@app.post("/admin/title_change/<int:user_id>")
|
@app.post("/admin/change_flair/<int:user_id>")
|
||||||
@limiter.limit('1/second', scope=rpath)
|
@limiter.limit('1/second', scope=rpath)
|
||||||
@limiter.limit('1/second', scope=rpath, key_func=get_ID)
|
@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)
|
||||||
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
|
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
|
||||||
@admin_level_required(PERMS['USER_TITLE_CHANGE'])
|
@admin_level_required(PERMS['USER_CHANGE_FLAIR'])
|
||||||
def admin_title_change(user_id, v):
|
def admin_change_flair(user_id, v):
|
||||||
|
|
||||||
user = get_account(user_id)
|
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
|
user.customtitleplain = new_flair
|
||||||
new_name = filter_emojis_only(new_name)
|
new_flair = filter_emojis_only(new_flair)
|
||||||
new_name = censor_slurs_profanities(new_name, None)
|
new_flair = censor_slurs_profanities(new_flair, None)
|
||||||
|
|
||||||
user = get_account(user.id)
|
user = get_account(user.id)
|
||||||
user.customtitle=new_name
|
user.customtitle = new_flair
|
||||||
if request.values.get("locked"):
|
if request.values.get("locked"):
|
||||||
user.flairchanged = int(time.time()) + 2629746
|
user.flairchanged = int(time.time()) + 2629746
|
||||||
badge_grant(user=user, badge_id=96)
|
badge_grant(user=user, badge_id=96)
|
||||||
|
@ -932,7 +932,7 @@ def admin_title_change(user_id, v):
|
||||||
kind=kind,
|
kind=kind,
|
||||||
user_id=v.id,
|
user_id=v.id,
|
||||||
target_user_id=user.id,
|
target_user_id=user.id,
|
||||||
_note=f'"{new_name}"'
|
_note=f'"{new_flair}"'
|
||||||
)
|
)
|
||||||
g.db.add(ma)
|
g.db.add(ma)
|
||||||
|
|
||||||
|
|
|
@ -891,13 +891,13 @@ def process_settings_plaintext(value, current, length, default_value):
|
||||||
return 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)
|
||||||
@limiter.limit('1/second', scope=rpath, key_func=get_ID)
|
@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)
|
||||||
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
|
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
|
||||||
@auth_required
|
@auth_required
|
||||||
def settings_title_change(v):
|
def settings_change_flair(v):
|
||||||
if v.flairchanged: abort(403)
|
if v.flairchanged: abort(403)
|
||||||
|
|
||||||
customtitleplain = process_settings_plaintext("title", v.customtitleplain, 100, None)
|
customtitleplain = process_settings_plaintext("title", v.customtitleplain, 100, None)
|
||||||
|
|
|
@ -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)}}
|
{{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 %}
|
{% 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)}}
|
{{common.color_section('flaircolor', '/settings/titlecolor', 'titlecolor', 'Flair Color', v.titlecolor)}}
|
||||||
|
|
||||||
|
|
|
@ -33,10 +33,10 @@
|
||||||
{% macro userAdminTools(deviceType) %}
|
{% macro userAdminTools(deviceType) %}
|
||||||
{% if v and v.id != u.id and v.admin_level >= PERMS['USER_MODERATION_TOOLS_VISIBLE'] %}
|
{% if v and v.id != u.id and v.admin_level >= PERMS['USER_MODERATION_TOOLS_VISIBLE'] %}
|
||||||
<div class="admintools-user-lower-{{deviceType}}">
|
<div class="admintools-user-lower-{{deviceType}}">
|
||||||
{% if v.admin_level >= PERMS['USER_TITLE_CHANGE'] %}
|
{% if v.admin_level >= PERMS['USER_CHANGE_FLAIR'] %}
|
||||||
<div class="body d-lg-flex border-bottom mt-4 mb-2">
|
<div class="body d-lg-flex border-bottom mt-4 mb-2">
|
||||||
<div class="w-lg-100">
|
<div class="w-lg-100">
|
||||||
<form action="/admin/title_change/{{u.id}}" method="post" data-nonce="{{g.nonce}}" data-onsubmit="sendFormXHR(this)">
|
<form action="/admin/change_flair/{{u.id}}" method="post" data-nonce="{{g.nonce}}" data-onsubmit="sendFormXHR(this)">
|
||||||
<input hidden name="formkey" value="{{v|formkey}}">
|
<input hidden name="formkey" value="{{v|formkey}}">
|
||||||
<input maxlength=100 autocomplete="off" id="customtitlebody-{{deviceType}}" type="text" name="title" class="form-control" placeholder='Enter a flair here' value="{% if u.customtitleplain %}{{u.customtitleplain}}{% endif %}">
|
<input maxlength=100 autocomplete="off" id="customtitlebody-{{deviceType}}" type="text" name="title" class="form-control" placeholder='Enter a flair here' value="{% if u.customtitleplain %}{{u.customtitleplain}}{% endif %}">
|
||||||
<div class="d-flex">
|
<div class="d-flex">
|
||||||
|
|
Loading…
Reference in New Issue