From d6cbbc05c69da9b79bace53fc0137b5b36212ae9 Mon Sep 17 00:00:00 2001 From: Aevann Date: Thu, 31 Aug 2023 13:46:07 +0300 Subject: [PATCH] simplar syntax --- files/classes/user.py | 2 +- files/helpers/alerts.py | 2 +- files/helpers/sanitize.py | 2 +- files/routes/comments.py | 4 ++-- files/routes/posts.py | 4 ++-- files/routes/users.py | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/files/classes/user.py b/files/classes/user.py index 62d6e5897..5590745c6 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -1043,7 +1043,7 @@ class User(Base): raise TypeError("Relationships supported is SaveRelationship, Subscription, CommentSaveRelationship") query = g.db.query(query).join(join).filter(relationship_cls.user_id == self.id) - if not self.admin_level >= PERMS['POST_COMMENT_MODERATION']: + if self.admin_level < PERMS['POST_COMMENT_MODERATION']: query = query.filter(cls.is_banned == False, cls.deleted_utc == 0) return query.count() diff --git a/files/helpers/alerts.py b/files/helpers/alerts.py index 5a0a785ae..8dee5305d 100644 --- a/files/helpers/alerts.py +++ b/files/helpers/alerts.py @@ -208,7 +208,7 @@ def NOTIFY_USERS(text, v, oldtext=None, ghost=False, log_cost=None, followers_pi if SITE == 'rdrama.net' and v.id in {256, 9287, 10489, 18701}: notify_users.discard(AEVANN_ID) - if len(notify_users) > 400 and not v.admin_level >= PERMS['POST_COMMENT_INFINITE_PINGS']: + if len(notify_users) > 400 and v.admin_level < PERMS['POST_COMMENT_INFINITE_PINGS']: abort(403, "You can only notify a maximum of 400 users.") return notify_users - BOT_IDs - {v.id, 0} - v.all_twoway_blocks diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index daa761873..a2eca2779 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -453,7 +453,7 @@ def sanitize(sanitized, golden=True, limit_pings=0, showmore=False, count_emojis names = set(m.group(1) for m in mention_regex.finditer(sanitized)) - if limit_pings and len(names) > limit_pings and not v.admin_level >= PERMS['POST_COMMENT_INFINITE_PINGS']: + if limit_pings and len(names) > limit_pings and v.admin_level < PERMS['POST_COMMENT_INFINITE_PINGS']: error("Max ping limit is 5 for comments and 50 for posts!") users_list = get_users(names, graceful=True) diff --git a/files/routes/comments.py b/files/routes/comments.py index be8ed6bea..3716fdb42 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -174,7 +174,7 @@ def comment(v): if not body and not request.files.get('file'): abort(400, "You need to actually write something!") - if not v.admin_level >= PERMS['POST_COMMENT_MODERATION'] and parent_user.any_block_exists(v): + if v.admin_level < PERMS['POST_COMMENT_MODERATION'] and parent_user.any_block_exists(v): abort(403, "You can't reply to users who have blocked you or users that you have blocked!") if request.files.get("file") and not g.is_tor: @@ -591,7 +591,7 @@ def diff_words(answer, guess): def toggle_comment_nsfw(cid, v): comment = get_comment(cid) - if comment.author_id != v.id and not v.admin_level >= PERMS['POST_COMMENT_MODERATION'] and not (comment.post.sub and v.mods(comment.post.sub)): + if comment.author_id != v.id and v.admin_level < PERMS['POST_COMMENT_MODERATION'] and not (comment.post.sub and v.mods(comment.post.sub)): abort(403) if comment.over_18 and v.is_permabanned: diff --git a/files/routes/posts.py b/files/routes/posts.py index a5d4c0a54..d26dc4d81 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -747,7 +747,7 @@ def undelete_post_pid(pid, v): def mark_post_nsfw(pid, v): p = get_post(pid) - if p.author_id != v.id and not v.admin_level >= PERMS['POST_COMMENT_MODERATION'] and not (p.sub and v.mods(p.sub)): + if p.author_id != v.id and v.admin_level < PERMS['POST_COMMENT_MODERATION'] and not (p.sub and v.mods(p.sub)): abort(403) if p.over_18 and v.is_permabanned: @@ -786,7 +786,7 @@ def mark_post_nsfw(pid, v): def unmark_post_nsfw(pid, v): p = get_post(pid) - if p.author_id != v.id and not v.admin_level >= PERMS['POST_COMMENT_MODERATION'] and not (p.sub and v.mods(p.sub)): + if p.author_id != v.id and v.admin_level < PERMS['POST_COMMENT_MODERATION'] and not (p.sub and v.mods(p.sub)): abort(403) if p.over_18 and v.is_permabanned: diff --git a/files/routes/users.py b/files/routes/users.py index fd97f33f7..aed9fd852 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -1293,7 +1293,7 @@ def get_saves_and_subscribes(v, template, relationship_cls, page, standalone=Fal ids = [x[0] for x in listing] extra = None - if not v.admin_level >= PERMS['POST_COMMENT_MODERATION']: + if v.admin_level < PERMS['POST_COMMENT_MODERATION']: extra = lambda q:q.filter(cls.is_banned == False, cls.deleted_utc == 0) if cls is Post: