From ae90eb1cf2f83ff84574241e80ad777f9c8f6fbc Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sun, 11 Sep 2022 03:53:16 +0200 Subject: [PATCH] simplify house checking logic --- files/classes/comment.py | 2 +- files/classes/submission.py | 2 +- files/classes/user.py | 2 +- files/routes/comments.py | 2 +- files/routes/polls.py | 4 ++-- files/routes/posts.py | 2 +- files/routes/reporting.py | 2 +- files/routes/subs.py | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/files/classes/comment.py b/files/classes/comment.py index dc0a43927..4d4592eaf 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -376,7 +376,7 @@ class Comment(Base): if v: sub = self.post.sub - if sub in ('furry','vampire','racist','femboy') and not (v.house and v.house.lower().startswith(sub)): body += ' disabled ' + if sub in ('furry','vampire','racist','femboy') and not v.house.lower().startswith(sub): body += ' disabled ' body += f''' onchange="poll_vote_{o.exclusive}('{o.id}', '{self.id}', 'comment')"''' else: body += f''' onchange="poll_vote_no_v()"''' diff --git a/files/classes/submission.py b/files/classes/submission.py index b1ffcad51..f82fec74b 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -387,7 +387,7 @@ class Submission(Base): if v: sub = self.sub - if sub in ('furry','vampire','racist','femboy') and not (v.house and v.house.lower().startswith(sub)): body += ' disabled ' + if sub in ('furry','vampire','racist','femboy') and not v.house.lower().startswith(sub): body += ' disabled ' body += f''' onchange="poll_vote_{o.exclusive}('{o.id}', '{self.id}', 'post')"''' else: body += f''' onchange="poll_vote_no_v()"''' diff --git a/files/classes/user.py b/files/classes/user.py index 505233464..268bac9a4 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -49,7 +49,7 @@ class User(Base): highres = Column(String) profileurl = Column(String) bannerurl = Column(String) - house = Column(String) + house = Column(String, default='') old_house = Column(String) patron = Column(Integer, default=0) patron_utc = Column(Integer, default=0) diff --git a/files/routes/comments.py b/files/routes/comments.py index 6c7b6d9dc..eaabce1da 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -148,7 +148,7 @@ def comment(v): sub = parent_post.sub if sub and v.exiled_from(sub): return {"error": f"You're exiled from /h/{sub}"}, 403 - if sub in ('furry','vampire','racist','femboy') and not v.client and not (v.house and v.house.lower().startswith(sub)): + if sub in ('furry','vampire','racist','femboy') and not v.client and not v.house.lower().startswith(sub): return {"error": f"You need to be a member of House {sub.capitalize()} to comment in /h/{sub}"} if parent_post.club and not (v and (v.paid_dues or v.id == parent_post.author_id)): abort(403) diff --git a/files/routes/polls.py b/files/routes/polls.py index 4239bffc9..b681215d9 100644 --- a/files/routes/polls.py +++ b/files/routes/polls.py @@ -18,7 +18,7 @@ def vote_option(option_id, v): sub = option.post.sub - if sub in ('furry','vampire','racist','femboy') and not (v.house and v.house.lower().startswith(sub)): + if sub in ('furry','vampire','racist','femboy') and not v.house.lower().startswith(sub): return {"error": f"You need to be a member of House {sub.capitalize()} to vote on polls in /h/{sub}"} if option.exclusive == 2: @@ -84,7 +84,7 @@ def vote_option_comment(option_id, v): sub = option.comment.post.sub - if sub in ('furry','vampire','racist','femboy') and not (v.house and v.house.lower().startswith(sub)): + if sub in ('furry','vampire','racist','femboy') and not v.house.lower().startswith(sub): return {"error": f"You need to be a member of House {sub.capitalize()} to vote on polls in /h/{sub}"} if option.exclusive: diff --git a/files/routes/posts.py b/files/routes/posts.py index 3b82f7ccc..9d67fb8ad 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -695,7 +695,7 @@ def submit_post(v, sub=None): allowed = [x[0] for x in allowed] if v.id not in allowed: return error(f"You don't have sufficient permissions to post in /h/changelog") - if sub in ('furry','vampire','racist','femboy') and not v.client and not (v.house and v.house.lower().startswith(sub)): + if sub in ('furry','vampire','racist','femboy') and not v.client and not v.house.lower().startswith(sub): return error(f"You need to be a member of House {sub.capitalize()} to post in /h/{sub}") if sub and sub != 'none': diff --git a/files/routes/reporting.py b/files/routes/reporting.py index a3c465aae..84636c175 100644 --- a/files/routes/reporting.py +++ b/files/routes/reporting.py @@ -52,7 +52,7 @@ def flag_post(pid, v): if post.author.exiled_from(sub_to): return {"error": f"User is exiled from this {HOLE_NAME}!"} - if sub_to in ('furry','vampire','racist','femboy') and not v.client and not (post.author.house and post.author.house.lower().startswith(sub_to)): + if sub_to in ('furry','vampire','racist','femboy') and not v.client and not post.author.house.lower().startswith(sub_to): if v.id == post.author_id: return {"error": f"You need to be a member of House {sub.capitalize()} to post in /h/{sub}"} else: diff --git a/files/routes/subs.py b/files/routes/subs.py index 13ed232e2..5128f843b 100644 --- a/files/routes/subs.py +++ b/files/routes/subs.py @@ -243,7 +243,7 @@ def add_mod(v, sub): user = get_user(user) - if sub in ('furry','vampire','racist','femboy') and not v.client and not (user.house and user.house.lower().startswith(sub)): + if sub in ('furry','vampire','racist','femboy') and not v.client and not user.house.lower().startswith(sub): return {"error": f"@{user.username} needs to be a member of House {sub.capitalize()} to be added as a mod there!"} existing = g.db.query(Mod).filter_by(user_id=user.id, sub=sub).one_or_none()