forked from rDrama/rDrama
use sets with in statements
parent
fef11e7ea6
commit
a63b02470d
|
@ -74,7 +74,7 @@ class Badge(Base):
|
|||
def text(self):
|
||||
if self.until:
|
||||
text = self.badge.description + " until"
|
||||
elif self.badge_id in (28, 170, 179):
|
||||
elif self.badge_id in {28, 170, 179}:
|
||||
text = self.badge.description + " permanently"
|
||||
elif self.description:
|
||||
text = self.description
|
||||
|
|
|
@ -284,7 +284,7 @@ class Comment(Base):
|
|||
|
||||
if v:
|
||||
sub = self.post.sub
|
||||
if sub in ('furry','vampire','racist','femboy') and not 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()"'''
|
||||
|
|
|
@ -221,7 +221,7 @@ class Submission(Base):
|
|||
if v and v.poor:
|
||||
return 0
|
||||
elif self.distinguish_level:
|
||||
if SITE_NAME == 'rDrama' and kind in ('glowie', 'tilt',):
|
||||
if SITE_NAME == 'rDrama' and kind in {'glowie', 'tilt',}:
|
||||
return 0
|
||||
elif SITE_NAME == 'WPD':
|
||||
return 0
|
||||
|
@ -306,7 +306,7 @@ class Submission(Base):
|
|||
|
||||
if v:
|
||||
sub = self.sub
|
||||
if sub in ('furry','vampire','racist','femboy') and not 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()"'''
|
||||
|
|
|
@ -318,7 +318,7 @@ class User(Base):
|
|||
@lazy
|
||||
def mods(self, sub):
|
||||
if self.is_suspended_permanently or self.shadowbanned: return False
|
||||
if self.id in (AEVANN_ID, SNAKES_ID): return True
|
||||
if self.id in {AEVANN_ID, SNAKES_ID}: return True
|
||||
try:
|
||||
return any(map(lambda x: x.sub == sub, self.sub_mods))
|
||||
except:
|
||||
|
@ -970,7 +970,7 @@ class User(Base):
|
|||
if other.sentto != user.id: return user.admin_level >= PERMS['POST_COMMENT_MODERATION'] # type: ignore
|
||||
elif isinstance(other, Sub):
|
||||
if other.name == 'chudrama': return bool(user) and user.can_see_chudrama
|
||||
if other.name in ('countryclub','splash_mountain'): return bool(user) and user.can_see_countryclub
|
||||
if other.name in {'countryclub','splash_mountain'}: return bool(user) and user.can_see_countryclub
|
||||
if other.name == 'masterbaiters': return bool(user) and user.can_see_masterbaiters
|
||||
elif isinstance(other, User):
|
||||
return (user and user.id == other.id) or (user and user.can_see_shadowbanned) or not other.shadowbanned
|
||||
|
|
|
@ -389,7 +389,7 @@ def execute_blackjack(v, target, body, type):
|
|||
extra_info = f"reports on {target.permalink}"
|
||||
elif type == 'modmail':
|
||||
extra_info = "modmail"
|
||||
elif type in ('comment', 'message'):
|
||||
elif type in {'comment', 'message'}:
|
||||
for id in (CARP_ID, AEVANN_ID):
|
||||
n = Notification(comment_id=target.id, user_id=id)
|
||||
g.db.add(n)
|
||||
|
|
|
@ -174,11 +174,11 @@ def process_image(filename:str, v, resize=0, trim=False, uploader_id:Optional[in
|
|||
path = filename.rsplit('/', 1)[0]
|
||||
kind = path.split('/')[-1]
|
||||
|
||||
if kind in ('banners','sidebar'):
|
||||
if kind in {'banners','sidebar'}:
|
||||
hashes = {}
|
||||
|
||||
for img in os.listdir(path):
|
||||
if resize == 400 and img in ('256.webp','585.webp'): continue
|
||||
if resize == 400 and img in {'256.webp','585.webp'}: continue
|
||||
img_path = f'{path}/{img}'
|
||||
if img_path == filename: continue
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ def allowed_attributes(tag, name, value):
|
|||
if name == 'preload' and value == 'none': return True
|
||||
|
||||
if tag == 'p':
|
||||
if name == 'class' and value in ('mb-0','resizable'): return True
|
||||
if name == 'class' and value in {'mb-0','resizable'}: return True
|
||||
|
||||
if tag == 'span':
|
||||
if name == 'data-bs-toggle' and value == 'tooltip': return True
|
||||
|
|
|
@ -246,7 +246,7 @@ def handle_payout(gambler, state, game):
|
|||
gambler.pay_account(game.currency, payout)
|
||||
|
||||
if game.currency == 'coins':
|
||||
if status in (BlackjackStatus.BLACKJACK, BlackjackStatus.WON):
|
||||
if status in {BlackjackStatus.BLACKJACK, BlackjackStatus.WON}:
|
||||
distribute_wager_badges(gambler, game.wager, won=True)
|
||||
elif status == BlackjackStatus.LOST:
|
||||
distribute_wager_badges(gambler, game.wager, won=False)
|
||||
|
|
|
@ -165,7 +165,7 @@ def award_thing(v, thing_type, id):
|
|||
note = request.values.get("note", "").strip()
|
||||
|
||||
|
||||
if SITE == 'rdrama.net' and author.id in (PIZZASHILL_ID,) and v.id not in (AEVANN_ID, SNAKES_ID):
|
||||
if SITE == 'rdrama.net' and author.id == PIZZASHILL_ID and v.id not in {AEVANN_ID, SNAKES_ID}:
|
||||
abort(403, f"@{author.username} is immune to awards.")
|
||||
|
||||
if kind == "benefactor" and author.id == v.id:
|
||||
|
|
|
@ -89,7 +89,7 @@ def pull_slots(v:User):
|
|||
|
||||
try:
|
||||
currency = request.values.get("currency", "").lower()
|
||||
if currency not in ('coins', 'marseybux'): raise ValueError()
|
||||
if currency not in {'coins', 'marseybux'}: raise ValueError()
|
||||
except:
|
||||
abort(400, "Invalid currency (expected 'coins' or 'marseybux').")
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ def comment(v:User):
|
|||
if posting_to_submission:
|
||||
sub = post_target.sub
|
||||
if sub and v.exiled_from(sub): abort(403, f"You're exiled from /h/{sub}")
|
||||
if sub in ('furry','vampire','racist','femboy') and not v.client and not v.house.lower().startswith(sub):
|
||||
if sub in {'furry','vampire','racist','femboy'} and not v.client and not v.house.lower().startswith(sub):
|
||||
abort(403, f"You need to be a member of House {sub.capitalize()} to comment in /h/{sub}")
|
||||
|
||||
if level > COMMENT_MAX_DEPTH: abort(400, f"Max comment level is {COMMENT_MAX_DEPTH}")
|
||||
|
|
|
@ -16,7 +16,7 @@ def vote_option(option_id, v):
|
|||
if not option: abort(404)
|
||||
sub = option.post.sub
|
||||
|
||||
if sub in ('furry','vampire','racist','femboy') and not v.house.lower().startswith(sub):
|
||||
if sub in {'furry','vampire','racist','femboy'} and not v.house.lower().startswith(sub):
|
||||
abort(403, f"You need to be a member of House {sub.capitalize()} to vote on polls in /h/{sub}")
|
||||
|
||||
if option.exclusive == 2:
|
||||
|
@ -92,7 +92,7 @@ def vote_option_comment(option_id, v):
|
|||
option = g.db.get(CommentOption, option_id)
|
||||
if not option: abort(404)
|
||||
sub = option.comment.post.sub
|
||||
if sub in ('furry','vampire','racist','femboy') and not v.house.lower().startswith(sub):
|
||||
if sub in {'furry','vampire','racist','femboy'} and not v.house.lower().startswith(sub):
|
||||
abort(403, f"You need to be a member of House {sub.capitalize()} to vote on polls in /h/{sub}")
|
||||
|
||||
if option.exclusive:
|
||||
|
|
|
@ -493,7 +493,7 @@ def is_repost():
|
|||
parsed_url = urlparse(url)
|
||||
|
||||
domain = parsed_url.netloc
|
||||
if domain in ('old.reddit.com','twitter.com','instagram.com','tiktok.com') and '/search' not in url:
|
||||
if domain in {'old.reddit.com','twitter.com','instagram.com','tiktok.com'} and '/search' not in url:
|
||||
new_url = ParseResult(scheme="https",
|
||||
netloc=parsed_url.netloc,
|
||||
path=parsed_url.path,
|
||||
|
@ -561,7 +561,7 @@ def submit_post(v:User, sub=None):
|
|||
allowed = [x[0] for x in allowed]
|
||||
if v.id not in allowed: return error("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.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':
|
||||
|
@ -590,7 +590,7 @@ def submit_post(v:User, sub=None):
|
|||
parsed_url = urlparse(url)
|
||||
|
||||
domain = parsed_url.netloc
|
||||
if domain in ('old.reddit.com','twitter.com','instagram.com','tiktok.com') and '/search' not in url:
|
||||
if domain in {'old.reddit.com','twitter.com','instagram.com','tiktok.com'} and '/search' not in url:
|
||||
new_url = ParseResult(scheme="https",
|
||||
netloc=parsed_url.netloc,
|
||||
path=parsed_url.path,
|
||||
|
|
|
@ -152,7 +152,7 @@ def move_post(post:Submission, v:User, reason:str) -> Union[bool, str]:
|
|||
if post.author.exiled_from(sub_to):
|
||||
abort(403, 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.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:
|
||||
abort(403, f"You need to be a member of House {sub_to.capitalize()} to post in /h/{sub_to}")
|
||||
else:
|
||||
|
|
|
@ -106,7 +106,8 @@ def daily_chart(v:User):
|
|||
@app.get("/paypigs")
|
||||
@admin_level_required(PERMS['VIEW_PATRONS'])
|
||||
def patrons(v):
|
||||
if AEVANN_ID and v.id not in (AEVANN_ID, CARP_ID, SNAKES_ID): abort(404)
|
||||
if AEVANN_ID and v.id not in {AEVANN_ID, CARP_ID, SNAKES_ID}:
|
||||
abort(404)
|
||||
|
||||
users = g.db.query(User).filter(User.patron > 0).order_by(User.patron.desc(), User.id).all()
|
||||
|
||||
|
|
|
@ -239,7 +239,7 @@ def add_mod(v:User, sub):
|
|||
|
||||
user = get_user(user, v=v, include_shadowbanned=False)
|
||||
|
||||
if sub in ('furry','vampire','racist','femboy') and not v.client and not user.house.lower().startswith(sub):
|
||||
if sub in {'furry','vampire','racist','femboy'} and not v.client and not user.house.lower().startswith(sub):
|
||||
abort(403, 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()
|
||||
|
|
|
@ -544,7 +544,7 @@ def messagereply(v:User):
|
|||
execute_blackjack(v, c, c.body_html, 'message')
|
||||
execute_under_siege(v, c, c.body_html, 'message')
|
||||
|
||||
if user_id and user_id not in (v.id, MODMAIL_ID, bots):
|
||||
if user_id and user_id not in {v.id, MODMAIL_ID, bots}:
|
||||
notif = g.db.query(Notification).filter_by(comment_id=c.id, user_id=user_id).one_or_none()
|
||||
if not notif:
|
||||
notif = Notification(comment_id=c.id, user_id=user_id)
|
||||
|
|
Loading…
Reference in New Issue