rename customtitle to flair

pull/211/head
Aevann 2023-10-05 13:39:12 +03:00
parent 3dc652f867
commit 0867c47d9c
10 changed files with 32 additions and 29 deletions

View File

@ -56,8 +56,8 @@ class User(Base):
namecolor = Column(String, default=DEFAULT_COLOR)
background = Column(String)
profile_background = Column(String)
customtitle = Column(String)
customtitleplain = deferred(Column(String))
flair = deferred(Column(String))
flair_html = Column(String)
titlecolor = Column(String, default=DEFAULT_COLOR)
theme = Column(String, default=DEFAULT_THEME)
themecolor = Column(String, default=DEFAULT_COLOR)
@ -412,7 +412,7 @@ class User(Base):
if self.patron: return True
if self.is_permabanned or self.shadowbanned: return False
if self.chud: return False
if self.profile_url.startswith('/e/') and not self.customtitle and self.namecolor == DEFAULT_COLOR: return False
if self.profile_url.startswith('/e/') and not self.flair_html and self.namecolor == DEFAULT_COLOR: return False
return True
@lazy
@ -1026,7 +1026,8 @@ class User(Base):
'bannerurl': self.banner_url,
'bio': self.bio,
'bio_html': self.bio_html_eager,
'flair': self.customtitle,
'flair': self.flair,
'flair_html': self.flair_html,
'badges': [x.json for x in self.ordered_badges],
'coins': self.coins,
'post_count': self.real_post_count(g.v),

View File

@ -909,12 +909,12 @@ def admin_change_flair(user_id, v):
new_flair = request.values.get("title")[:256].strip()
user.customtitleplain = new_flair
user.flair = 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_flair
user.flair_html = new_flair
if request.values.get("locked"):
user.flairchanged = int(time.time()) + 2629746
badge_grant(user=user, badge_id=96)
@ -937,9 +937,9 @@ def admin_change_flair(user_id, v):
g.db.add(ma)
if user.flairchanged:
message = f"@{v.username} (a site admin) has locked your flair to `{user.customtitleplain}`."
message = f"@{v.username} (a site admin) has locked your flair to `{user.flair}`."
else:
message = f"@{v.username} (a site admin) has changed your flair to `{user.customtitleplain}`. You can change it back in the settings."
message = f"@{v.username} (a site admin) has changed your flair to `{user.flair}`. You can change it back in the settings."
send_repeatable_notification(user.id, message)

View File

@ -390,11 +390,11 @@ def award_thing(v, thing_type, id):
if not new_name and author.flairchanged:
author.flairchanged += 86400
else:
author.customtitleplain = new_name
author.flair = new_name
new_name = filter_emojis_only(new_name)
new_name = censor_slurs_profanities(new_name, None)
if len(new_name) > 1000: abort(403)
author.customtitle = new_name
author.flair_html = new_name
author.flairchanged = int(time.time()) + 86400
badge_grant(user=author, badge_id=96)
elif kind == "namelock":

View File

@ -899,19 +899,19 @@ def process_settings_plaintext(value, current, length, default_value):
def settings_change_flair(v):
if v.flairchanged: abort(403)
customtitleplain = process_settings_plaintext("title", v.customtitleplain, 100, None)
flair = process_settings_plaintext("title", v.flair, 100, None)
if customtitleplain:
customtitle = filter_emojis_only(customtitleplain)
customtitle = censor_slurs_profanities(customtitle, None)
if flair:
flair_html = filter_emojis_only(flair)
flair_html = censor_slurs_profanities(flair_html, None)
if len(customtitle) > 1000:
if len(flair_html) > 1000:
abort(400, "Flair too long!")
else:
customtitle = None
flair_html = None
v.customtitleplain = customtitleplain
v.customtitle = customtitle
v.flair = flair
v.flair_html = flair_html
g.db.add(v)
return {"message": "Flair successfully updated!"}

View File

@ -176,8 +176,8 @@
{% if FEATURES['PRONOUNS'] %}
<span class="pronouns" style="color:#{{c.author.titlecolor}};border-color:#{{c.author.titlecolor}}">{{c.author.pronouns_display}}</span>
{% endif %}
{% if c.author.customtitle %}
&nbsp;<bdi class="text-break" style="color: #{{c.author.titlecolor}}">&nbsp;{{c.author.customtitle | safe}}</bdi>
{% if c.author.flair_html %}
&nbsp;<bdi class="text-break" style="color: #{{c.author.titlecolor}}">&nbsp;{{c.author.flair_html | safe}}</bdi>
{% endif %}
{% endif %}

View File

@ -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/change_flair', '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.flair, '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)}}

View File

@ -38,9 +38,9 @@
<div class="w-lg-100">
<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 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="flair_htmlbody-{{deviceType}}" type="text" name="title" class="form-control" placeholder='Enter a flair here' value="{% if u.flair %}{{u.flair}}{% endif %}">
<div class="d-flex">
<div class="format pl-0"><i class="btn btn-secondary format d-inline-block m-0 fas fa-smile-beam" data-nonce="{{g.nonce}}" data-onclick="loadEmojis('customtitlebody-{{deviceType}}')" data-bs-toggle="modal" data-bs-target="#emojiModal" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Add Emoji"></i></div>
<div class="format pl-0"><i class="btn btn-secondary format d-inline-block m-0 fas fa-smile-beam" data-nonce="{{g.nonce}}" data-onclick="loadEmojis('flair_htmlbody-{{deviceType}}')" data-bs-toggle="modal" data-bs-target="#emojiModal" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Add Emoji"></i></div>
<div class="custom-control custom-checkbox ml-2 mt-1">
<input autocomplete="off" type="checkbox" class="custom-control-input" id="locked-{{deviceType}}" name="locked" {% if u.flairchanged %}checked{% endif %}>
<label class="custom-control-label" for="locked-{{deviceType}}">locked</label>

View File

@ -67,8 +67,8 @@
<p class="font-weight-bolder" id="profile--pronouns" style="color: #{{u.titlecolor}}">{{u.pronouns_display}}</p>
{% endif %}
{% if u.customtitle and can_see(v, u) %}
<p class="font-weight-bolder" id="profile--flair" style="color: #{{u.titlecolor}}">{{u.customtitle | safe}}</p>
{% if u.flair_html and can_see(v, u) %}
<p class="font-weight-bolder" id="profile--flair" style="color: #{{u.titlecolor}}">{{u.flair_html | safe}}</p>
{% endif %}
<div class="font-weight-bolder mb-2" id="profile--simphate">
@ -346,8 +346,8 @@
<p style="color: #{{u.titlecolor}}" id="profile-mobile--pronouns">{{u.pronouns_display}}</p>
{% endif %}
{% if u.customtitle and can_see(v, u) %}
<p style="color: #{{u.titlecolor}}" id="profile-mobile--flair">{{u.customtitle | safe}}</p>
{% if u.flair_html and can_see(v, u) %}
<p style="color: #{{u.titlecolor}}" id="profile-mobile--flair">{{u.flair_html | safe}}</p>
{% endif %}
<div class="font-weight-bolder mb-2" id="profile-mobile--simphate">

View File

@ -85,8 +85,8 @@
{% if FEATURES['PRONOUNS'] %}
<span class="pronouns" style="color:#{{p.author.titlecolor}};border-color:#{{p.author.titlecolor}}">{{p.author.pronouns_display}}</span>
{% endif %}
{% if p.author.customtitle %}
<bdi class="text-break ml-2" style="color: #{{p.author.titlecolor}}">{{p.author.customtitle | safe}}</bdi>
{% if p.author.flair_html %}
<bdi class="text-break ml-2" style="color: #{{p.author.titlecolor}}">{{p.author.flair_html | safe}}</bdi>
{% endif %}
{% endif %}
<span class="ml-2 d-inline-block" data-bs-toggle="tooltip" data-bs-placement="bottom" data-nonce="{{g.nonce}}" data-onmouseover="timestamp(this, '{{p.created_utc}}')" id="timestamp-{{p.id}}">&nbsp;{{p.age_string}}</span>

View File

@ -0,0 +1,2 @@
alter table users rename column customtitleplain to flair;
alter table users rename column customtitle to flair_html;