From be490f85627ee6679f3e7cd47fe4a82ee30d7b56 Mon Sep 17 00:00:00 2001 From: Aevann Date: Sun, 18 Feb 2024 18:27:33 +0200 Subject: [PATCH] do this https://rdrama.net/notification/5961029#context --- files/classes/user.py | 13 ++++++++----- files/templates/settings/personal.html | 5 ++++- files/templates/userpage/banner.html | 4 ++-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/files/classes/user.py b/files/classes/user.py index 24d22219f..02ab9877e 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -1025,7 +1025,7 @@ class User(Base): 'marseybux': self.marseybux, 'post_count': self.real_post_count(v), 'comment_count': self.real_comment_count(v), - 'badges': [[x.path, x.text, x.until] for x in self.ordered_badges], + 'badges': [[x.path, x.text, x.until] for x in self.ordered_badges(v)], 'created_date': self.created_date, 'original_usernames': self.original_usernames_popover, } @@ -1060,7 +1060,6 @@ class User(Base): 'bio_html': self.bio_html_eager, '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), 'comment_count': self.real_comment_count(g.v), @@ -1341,10 +1340,14 @@ class User(Base): return output - @property @lazy - def ordered_badges(self): - return sorted(self.badges, key=badge_ordering_func) + def ordered_badges(self, v): + badges = self.badges + + if not self.lifetimedonated_visible and not (v.id == self.id or v.admin_level >= PERMS['VIEW_PATRONS']): + badges = [x for x in badges if badge.id not in {22, 23, 24, 25, 26, 27, 28, 257, 258, 259, 260, 261}] + + return sorted(badges, key=badge_ordering_func) @lazy def rendered_sig(self, v): diff --git a/files/templates/settings/personal.html b/files/templates/settings/personal.html index 8b669d129..ccd5e16f9 100644 --- a/files/templates/settings/personal.html +++ b/files/templates/settings/personal.html @@ -252,11 +252,14 @@ {{common.text_area_section('profile-signature', '/settings/personal', 'sig', 'Signature', v.sig, 'Limit of 200 characters', 'Enter a signature...', true, 200)}} {{common.toggle_section('Private Mode', 'privateswitch', 'private', v.is_private, 'This will hide your profile page from other users.', false)}} - {{common.toggle_section('Lifetime Donated and Total Award Discount Visiblity', 'lifetimedonated_visibleswitch', 'lifetimedonated_visible', v.lifetimedonated_visible, 'Make the "lifetime donated" field and the "total award discount" field in your profile visible to everyone instead of just you.', false)}} + + {{common.toggle_section('Donation Visiblity', 'lifetimedonated_visibleswitch', 'lifetimedonated_visible', v.lifetimedonated_visible, 'Make your donation badges, your lifetime-donated amount, and your total award discount visible to everyone instead of just you.', false)}} {{common.toggle_section('Cursor Marsey', 'cursormarseyswitch', 'cursormarsey', v.cursormarsey, 'Have a cute marsey accompany you during your journey on the site.', false)}} + {{common.toggle_section('Spider', 'spiderswitch', 'spider', v.spider, 'Have a spider friend accompany you during your journey on the site.', v.spider > 1)}} + {{common.toggle_section('Marsify', 'marsifyswitch', 'marsify', v.marsify, 'Automatically insert relevant marseys into your future comments.', v.marsify > 1)}} diff --git a/files/templates/userpage/banner.html b/files/templates/userpage/banner.html index 4a157a5ad..db04fcf91 100644 --- a/files/templates/userpage/banner.html +++ b/files/templates/userpage/banner.html @@ -308,7 +308,7 @@ {% if FEATURES['BADGES'] -%}
- {% for b in u.ordered_badges %} + {% for b in u.ordered_badges(v) %} {% if b.url %} {{b.name}} @@ -485,7 +485,7 @@ {% endif %}