From 04e47017c10c7df3e3339ba69836877f337a94f5 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Wed, 31 Aug 2022 18:49:31 +0200 Subject: [PATCH] fix chudrama for paypigs --- files/classes/comment.py | 4 +--- files/classes/submission.py | 4 +--- files/classes/user.py | 10 +++++++++- files/routes/comments.py | 2 +- files/routes/front.py | 2 +- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/files/classes/comment.py b/files/classes/comment.py index 536b85217e..4f241a2847 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -90,9 +90,7 @@ class Comment(Base): if not self.parent_submission: return True if self.post.sub != 'chudrama': return True if v: - if v.truecoins >= 5000: return True - if v.agendaposter: return True - if v.patron: return True + if v.can_see_chudrama: return True if v.id == self.author_id: return True if v.id == self.post.author_id: return True return False diff --git a/files/classes/submission.py b/files/classes/submission.py index 61786d012e..85f9a28975 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -82,9 +82,7 @@ class Submission(Base): if SITE != 'rdrama.net': return True if self.sub != 'chudrama': return True if v: - if v.truecoins >= 5000: return True - if v.agendaposter: return True - if v.patron: return True + if v.can_see_chudrama: return True if v.id == self.author_id: return True return False diff --git a/files/classes/user.py b/files/classes/user.py index 1405308855..8473911e45 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -822,4 +822,12 @@ class User(Base): return 'Contributed at least $50' if self.patron == 5: return 'Contributed at least $100' - return '' \ No newline at end of file + return '' + + @property + @lazy + def can_see_chudrama(self): + if self.truecoins >= 5000: return True + if self.agendaposter: return True + if self.patron: return True + return False \ No newline at end of file diff --git a/files/routes/comments.py b/files/routes/comments.py index 462b20419b..b1e0a220f9 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -300,7 +300,7 @@ def comment(v): body_html = sanitize(body_for_sanitize, limit_pings=5) - if parent_post.id not in ADMIGGERS and '!slots' not in body.lower() and '!blackjack' not in body.lower() and '!wordle' not in body.lower() and AGENDAPOSTER_PHRASE not in body.lower() and parent_post.sub != 'chudrama': + if parent_post.id not in ADMIGGERS and '!slots' not in body.lower() and '!blackjack' not in body.lower() and '!wordle' not in body.lower() and AGENDAPOSTER_PHRASE not in body.lower(): existing = g.db.query(Comment.id).filter(Comment.author_id == v.id, Comment.deleted_utc == 0, Comment.parent_comment_id == parent_comment_id, diff --git a/files/routes/front.py b/files/routes/front.py index 70e40918f6..d53cf91bef 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -29,7 +29,7 @@ def front_all(v, sub=None, subdomain=None): if sub: sub = sub.strip().lower() - if sub == 'chudrama' and not (v and v.truecoins >= 5000): abort(403) + if sub == 'chudrama' and not (v and v.can_see_chudrama): abort(403) sub = g.db.query(Sub).filter_by(name=sub).one_or_none() if (request.path.startswith('/h/') or request.path.startswith('/s/')) and not sub: abort(404)