From 0867c47d9c9b8ed0f0b65dc840d028405068f60e Mon Sep 17 00:00:00 2001 From: Aevann Date: Thu, 5 Oct 2023 13:39:12 +0300 Subject: [PATCH] rename customtitle to flair --- files/classes/user.py | 9 +++++---- files/routes/admin.py | 8 ++++---- files/routes/awards.py | 4 ++-- files/routes/settings.py | 16 ++++++++-------- files/templates/comments.html | 4 ++-- files/templates/settings/personal.html | 2 +- files/templates/userpage/admintools.html | 4 ++-- files/templates/userpage/banner.html | 8 ++++---- files/templates/util/macros.html | 4 ++-- .../20231005-rename-customtitle-to-flair.sql | 2 ++ 10 files changed, 32 insertions(+), 29 deletions(-) create mode 100644 migrations/20231005-rename-customtitle-to-flair.sql diff --git a/files/classes/user.py b/files/classes/user.py index 1b1acaf18..397ace338 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -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), diff --git a/files/routes/admin.py b/files/routes/admin.py index 3f832cc93..81a490dfa 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -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) diff --git a/files/routes/awards.py b/files/routes/awards.py index 522195576..0d246bf6f 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -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": diff --git a/files/routes/settings.py b/files/routes/settings.py index 1fe9a594a..8395d883c 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -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!"} diff --git a/files/templates/comments.html b/files/templates/comments.html index 4660466cc..d2d5d1e8b 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -176,8 +176,8 @@ {% if FEATURES['PRONOUNS'] %} {{c.author.pronouns_display}} {% endif %} - {% if c.author.customtitle %} -   {{c.author.customtitle | safe}} + {% if c.author.flair_html %} +   {{c.author.flair_html | safe}} {% endif %} {% endif %} diff --git a/files/templates/settings/personal.html b/files/templates/settings/personal.html index 85b1fdf00..b4f1a7c83 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/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)}} diff --git a/files/templates/userpage/admintools.html b/files/templates/userpage/admintools.html index 39ef30f8d..9e2e503fb 100644 --- a/files/templates/userpage/admintools.html +++ b/files/templates/userpage/admintools.html @@ -38,9 +38,9 @@
- +
-
+
diff --git a/files/templates/userpage/banner.html b/files/templates/userpage/banner.html index 013356d22..eb3c82221 100644 --- a/files/templates/userpage/banner.html +++ b/files/templates/userpage/banner.html @@ -67,8 +67,8 @@

{{u.pronouns_display}}

{% endif %} - {% if u.customtitle and can_see(v, u) %} -

{{u.customtitle | safe}}

+ {% if u.flair_html and can_see(v, u) %} +

{{u.flair_html | safe}}

{% endif %}
@@ -346,8 +346,8 @@

{{u.pronouns_display}}

{% endif %} - {% if u.customtitle and can_see(v, u) %} -

{{u.customtitle | safe}}

+ {% if u.flair_html and can_see(v, u) %} +

{{u.flair_html | safe}}

{% endif %}
diff --git a/files/templates/util/macros.html b/files/templates/util/macros.html index 4ea8a7d18..d19f1c492 100644 --- a/files/templates/util/macros.html +++ b/files/templates/util/macros.html @@ -85,8 +85,8 @@ {% if FEATURES['PRONOUNS'] %} {{p.author.pronouns_display}} {% endif %} - {% if p.author.customtitle %} - {{p.author.customtitle | safe}} + {% if p.author.flair_html %} + {{p.author.flair_html | safe}} {% endif %} {% endif %}  {{p.age_string}} diff --git a/migrations/20231005-rename-customtitle-to-flair.sql b/migrations/20231005-rename-customtitle-to-flair.sql new file mode 100644 index 000000000..07e0c9219 --- /dev/null +++ b/migrations/20231005-rename-customtitle-to-flair.sql @@ -0,0 +1,2 @@ +alter table users rename column customtitleplain to flair; +alter table users rename column customtitle to flair_html;