From 6a19105bdc74fe78306f6907d42dd93ef951006e Mon Sep 17 00:00:00 2001 From: Aevann Date: Sat, 22 Jul 2023 20:30:55 +0300 Subject: [PATCH] do this https://rdrama.net/post/18459/marseycapywalking-megathread-for-bugs-and-suggestions/4541135#context --- files/classes/comment.py | 3 --- files/classes/post.py | 5 +---- files/classes/user.py | 24 +++++++++++------------- files/templates/comments.html | 5 +++++ files/templates/post.html | 3 +++ files/templates/post_listing.html | 8 ++++---- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/files/classes/comment.py b/files/classes/comment.py index c9ba3d7cd..efd89a286 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -359,9 +359,6 @@ class Comment(Base): body = body.replace(f'"{url}"', f'"{url_noquery}?{urlencode(p, True)}"') body = body.replace(f'>{url}<', f'>{url_noquery}?{urlencode(p, True)}<') - if not self.ghost and self.author.show_sig(v): - body += f'

{self.author.sig_html}
' - return body @lazy diff --git a/files/classes/post.py b/files/classes/post.py index 8025a0aee..8512b5807 100644 --- a/files/classes/post.py +++ b/files/classes/post.py @@ -296,7 +296,7 @@ class Post(Base): return False @lazy - def realbody(self, v, listing=False): + def realbody(self, v): if self.deleted_utc != 0 and not (v and (v.admin_level >= PERMS['POST_COMMENT_MODERATION'] or v.id == self.author.id)): return "[Deleted by user]" if self.is_banned and not (v and v.admin_level >= PERMS['POST_COMMENT_MODERATION']) and not (v and v.id == self.author.id): return "" @@ -309,9 +309,6 @@ class Post(Base): body = normalize_urls_runtime(body, v) - if not listing and not self.ghost and self.author.show_sig(v): - body += f'

{self.author.sig_html}
' - return body @lazy diff --git a/files/classes/user.py b/files/classes/user.py index 75f44544f..9b2956b02 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -1177,19 +1177,6 @@ class User(Base): def winnings(self): return g.db.query(func.sum(CasinoGame.winnings)).filter(CasinoGame.user_id == self.id).one()[0] or 0 - @lazy - def show_sig(self, v): - if not self.sig_html: - return False - - if not self.patron: - return False - - if v and (v.sigs_disabled or v.poor): - return False - - return True - @property @lazy def user_name(self): @@ -1311,6 +1298,17 @@ class User(Base): x = sorted(self.badges, key=badge_ordering_func) return x + @lazy + def rendered_sig(self, v): + if not self.sig_html or not self.patron: + return '' + + if v and (v.sigs_disabled or v.poor): + return '' + + return f'

{self.sig_html}
' + + badge_ordering_tuple = ( 22, 23, 24, 25, 26, 27, 28, #paypig 257, 258, 259, 260, 261, #lifetime donation diff --git a/files/templates/comments.html b/files/templates/comments.html index fc74c1803..4ea7e0b67 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -249,6 +249,11 @@
{{realbody | safe}}
+ + {% if not c.ghost %} + {{c.author.rendered_sig(v) | safe}} + {% endif %} + {% if c.parent_post or c.wall_user_id %} {% if v and v.id==c.author_id %} diff --git a/files/templates/post.html b/files/templates/post.html index 83c770884..44ed66cc6 100644 --- a/files/templates/post.html +++ b/files/templates/post.html @@ -147,6 +147,9 @@
removed by @{{p.ban_reason}} (Admin)
{% endif %} + {% if not p.ghost %} + {{p.author.rendered_sig(v) | safe}} + {% endif %} {% else %} diff --git a/files/templates/post_listing.html b/files/templates/post_listing.html index 375475139..e383b4308 100644 --- a/files/templates/post_listing.html +++ b/files/templates/post_listing.html @@ -106,7 +106,7 @@