diff --git a/files/classes/comment.py b/files/classes/comment.py index 470682851..564c6f1f5 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -115,7 +115,7 @@ class Comment(CreatedBase): @lazy def flags(self, v): flags = self.reports - if not (v and (v.shadowbanned or v.admin_level > 2)): + if not (v and (v.shadowbanned or v.admin_level >= 3)): for flag in flags: if flag.user.shadowbanned: flags.remove(flag) diff --git a/files/classes/submission.py b/files/classes/submission.py index b911d6cac..d24bf205c 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -142,7 +142,7 @@ class Submission(CreatedBase): @lazy def flags(self, v): flags = g.db.query(Flag).filter_by(post_id=self.id).order_by(Flag.created_utc).all() - if not (v and (v.shadowbanned or v.admin_level > 2)): + if not (v and (v.shadowbanned or v.admin_level >= 3)): for flag in flags: if flag.user.shadowbanned: flags.remove(flag) diff --git a/files/classes/user.py b/files/classes/user.py index c381259e5..104b1cd65 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -425,8 +425,8 @@ class User(CreatedBase): 'profile_url': self.profile_url, 'bannerurl': self.banner_url, 'bio_html': self.bio_html_eager, - 'post_count': 0 if self.shadowbanned and not (v and (v.shadowbanned or v.admin_level > 1)) else self.post_count, - 'comment_count': 0 if self.shadowbanned and not (v and (v.shadowbanned or v.admin_level > 1)) else self.comment_count, + 'post_count': 0 if self.shadowbanned and not (v and (v.shadowbanned or v.admin_level >= 2)) else self.post_count, + 'comment_count': 0 if self.shadowbanned and not (v and (v.shadowbanned or v.admin_level >= 2)) else self.comment_count, 'badges': [x.path for x in self.badges], } diff --git a/files/helpers/comments.py b/files/helpers/comments.py index 88c31a6df..c268803d6 100644 --- a/files/helpers/comments.py +++ b/files/helpers/comments.py @@ -223,7 +223,7 @@ def comment_on_unpublish(comment:Comment): def comment_filter_moderated(q: Query, v: Optional[User]) -> Query: - if not (v and v.shadowbanned) and not (v and v.admin_level > 2): + if not (v and v.shadowbanned) and not (v and v.admin_level >= 3): q = q.join(User, User.id == Comment.author_id) \ .filter(User.shadowbanned == None) if not v or v.admin_level < 2: diff --git a/files/helpers/get.py b/files/helpers/get.py index 69b57b67f..bce165f3a 100644 --- a/files/helpers/get.py +++ b/files/helpers/get.py @@ -262,7 +262,7 @@ def get_comments( blocked.c.target_id, ).filter(Comment.id.in_(cids)) - if not (v and (v.shadowbanned or v.admin_level > 1)): + if not (v and (v.shadowbanned or v.admin_level >= 2)): comments = comments.join(User, User.id == Comment.author_id) \ .filter(User.shadowbanned == None) diff --git a/files/helpers/listing.py b/files/helpers/listing.py index 64c74c09b..091fc9433 100644 --- a/files/helpers/listing.py +++ b/files/helpers/listing.py @@ -101,11 +101,11 @@ def frontlist(v=None, sort='new', page=1, t="all", ids_only=True, ccmode="false" @cache.memoize(timeout=USERPAGELISTING_TIMEOUT_SECS) def userpagelisting(u:User, v=None, page=1, sort="new", t="all"): - if u.shadowbanned and not (v and (v.admin_level > 1 or v.id == u.id)): return [] + if u.shadowbanned and not (v and (v.admin_level >= 2 or v.id == u.id)): return [] posts = g.db.query(Submission.id).filter_by(author_id=u.id, is_pinned=False) - if not (v and (v.admin_level > 1 or v.id == u.id)): + if not (v and (v.admin_level >= 2 or v.id == u.id)): posts = posts.filter_by(deleted_utc=0, is_banned=False, private=False, ghost=False) posts = apply_time_filter(posts, t, Submission) diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 9961c829c..127b42618 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -232,7 +232,7 @@ def sanitize(sanitized, alert=False, comment=False, edit=False): if not u: continue m = [ m for m in matches if u.username == m.group(2) or u.original_username == m.group(2) ] for i in m: - if not (g.v and g.v.any_block_exists(u)) or g.v.admin_level > 1: + if not (g.v and g.v.any_block_exists(u)) or g.v.admin_level >= 2: sanitized = sanitized.replace(i.group(0), f'''{i.group(1)}@{u.username}''', 1) soup = BeautifulSoup(sanitized, 'lxml') diff --git a/files/routes/admin/admin.py b/files/routes/admin/admin.py index db8708d2b..d4340c71d 100644 --- a/files/routes/admin/admin.py +++ b/files/routes/admin/admin.py @@ -222,7 +222,7 @@ def club_ban(v, username): @limiter.exempt @auth_required def shadowbanned(v): - if not (v and v.admin_level > 1): abort(404) + if not (v and v.admin_level >= 2): abort(404) users = [x for x in g.db.query(User).filter(User.shadowbanned != None).order_by(User.shadowbanned).all()] return render_template("shadowbanned.html", v=v, users=users) @@ -1189,7 +1189,7 @@ def sticky_post(post_id, v): if post and not post.stickied: pins = g.db.query(Submission.id).filter(Submission.stickied != None, Submission.is_banned == False).count() if pins > 2: - if v.admin_level > 1: + if v.admin_level >= 2: post.stickied = v.username post.stickied_utc = int(time.time()) + 3600 else: abort(403, "Can't exceed 3 pinned posts limit!") diff --git a/files/routes/chat.py b/files/routes/chat.py index 0728286cc..5983e2a4d 100644 --- a/files/routes/chat.py +++ b/files/routes/chat.py @@ -70,7 +70,7 @@ def speak(data, v): total += 1 - if v.admin_level > 1: + if v.admin_level >= 2: text = text.lower() for i in mute_regex.finditer(text): username = i.group(1) diff --git a/files/routes/comments.py b/files/routes/comments.py index 41f80aef7..973ab9eb6 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -23,9 +23,9 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None): if comment.post and comment.post.club and not (v and (v.paid_dues or v.id in [comment.author_id, comment.post.author_id])): abort(403) - if comment.post and comment.post.private and not (v and (v.admin_level > 1 or v.id == comment.post.author.id)): abort(403) + if comment.post and comment.post.private and not (v and (v.admin_level >= 2 or v.id == comment.post.author.id)): abort(403) - if not comment.parent_submission and not (v and (comment.author.id == v.id or comment.sentto == v.id)) and not (v and v.admin_level > 1) : abort(403) + if not comment.parent_submission and not (v and (comment.author.id == v.id or comment.sentto == v.id)) and not (v and v.admin_level >= 2) : abort(403) if not pid: if comment.parent_submission: pid = comment.parent_submission @@ -65,7 +65,7 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None): blocked.c.target_id, ) - if not (v and v.shadowbanned) and not (v and v.admin_level > 2): + if not (v and v.shadowbanned) and not (v and v.admin_level >= 3): comments = comments.join(User, User.id == Comment.author_id).filter(User.shadowbanned == None) comments=comments.filter( @@ -96,7 +96,7 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None): if request.headers.get("Authorization"): return top_comment.json else: - if post.is_banned and not (v and (v.admin_level > 1 or post.author_id == v.id)): template = "submission_banned.html" + if post.is_banned and not (v and (v.admin_level >= 2 or post.author_id == v.id)): template = "submission_banned.html" else: template = "submission.html" return render_template(template, v=v, p=post, sort=sort, comment_info=comment_info, render_replies=True) diff --git a/files/routes/front.py b/files/routes/front.py index 3764ba1e0..75800883f 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -49,12 +49,12 @@ def notifications(v): modmail = request.values.get('modmail') posts = request.values.get('posts') reddit = request.values.get('reddit') - if modmail and v.admin_level > 1: + if modmail and v.admin_level >= 2: comments = g.db.query(Comment).filter(Comment.sentto == MODMAIL_ID).order_by(Comment.id.desc()).offset(25*(page-1)).limit(26).all() next_exists = (len(comments) > 25) listing = comments[:25] elif messages: - if v and (v.shadowbanned or v.admin_level > 2): + if v and (v.shadowbanned or v.admin_level >= 3): comments = g.db.query(Comment).filter(Comment.sentto != None, or_(Comment.author_id==v.id, Comment.sentto==v.id), Comment.parent_submission == None, Comment.level == 1).order_by(Comment.id.desc()).offset(25*(page-1)).limit(26).all() else: comments = g.db.query(Comment).join(User, User.id == Comment.author_id).filter(User.shadowbanned == None, Comment.sentto != None, or_(Comment.author_id==v.id, Comment.sentto==v.id), Comment.parent_submission == None, Comment.level == 1).order_by(Comment.id.desc()).offset(25*(page-1)).limit(26).all() @@ -106,7 +106,7 @@ def notifications(v): Comment.body_html.notlike('%

New site mention: 1 or post.author_id == v.id)): template = "submission_banned.html" + if post.is_banned and not (v and (v.admin_level >= 2 or post.author_id == v.id)): template = "submission_banned.html" else: template = "submission.html" return render_template(template, v=v, p=post, ids=list(ids), sort=sort, render_replies=True, offset=offset) @@ -636,7 +636,7 @@ def undelete_post_pid(pid, v): @auth_required def toggle_comment_nsfw(cid, v): comment = g.db.query(Comment).filter_by(id=cid).one_or_none() - if comment.author_id != v.id and not v.admin_level > 1: abort(403) + if comment.author_id != v.id and not v.admin_level >= 2: abort(403) comment.over_18 = not comment.over_18 g.db.add(comment) @@ -650,7 +650,7 @@ def toggle_comment_nsfw(cid, v): def toggle_post_nsfw(pid, v): post = get_post(pid) - if post.author_id != v.id and not v.admin_level > 1: + if post.author_id != v.id and not v.admin_level >= 2: abort(403) post.over_18 = not post.over_18 diff --git a/files/routes/reporting.py b/files/routes/reporting.py index 84af36f07..0c9cf7dc7 100644 --- a/files/routes/reporting.py +++ b/files/routes/reporting.py @@ -14,7 +14,7 @@ def api_flag_post(pid, v): reason = request.values.get("reason", "").strip()[:100] reason = filter_emojis_only(reason) - if reason.startswith('!') and v.admin_level > 1: + if reason.startswith('!') and v.admin_level >= 2: post.flair = reason[1:] g.db.add(post) ma=ModAction( diff --git a/files/routes/static.py b/files/routes/static.py index d21a7f965..9458d916f 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -197,7 +197,7 @@ def patrons(v): @app.get("/admins") @auth_desired def admins(v): - if v and v.admin_level > 2: + if v and v.admin_level >= 3: admins = g.db.query(User).filter(User.admin_level>1).order_by(User.truecoins.desc()).all() admins += g.db.query(User).filter(User.admin_level==1).order_by(User.truecoins.desc()).all() else: admins = g.db.query(User).filter(User.admin_level>0).order_by(User.truecoins.desc()).all() @@ -217,7 +217,7 @@ def log(v): kind = request.values.get("kind") - if v and v.admin_level > 1: + if v and v.admin_level >= 2: types = ACTIONTYPES else: types = ACTIONTYPES2 @@ -225,7 +225,7 @@ def log(v): if kind not in types: kind = None actions = g.db.query(ModAction) - if not (v and v.admin_level > 1): + if not (v and v.admin_level >= 2): actions = actions.filter(ModAction.kind.notin_(["shadowban","unshadowban","flair_post","edit_post"])) if admin_id: @@ -258,7 +258,7 @@ def log_item(v, id): admins = [x[0] for x in g.db.query(User.username).filter(User.admin_level > 1).all()] - if v and v.admin_level > 1: types = ACTIONTYPES + if v and v.admin_level >= 2: types = ACTIONTYPES else: types = ACTIONTYPES2 return render_template("log.html", v=v, actions=[action], next_exists=False, page=1, action=action, admins=admins, types=types) diff --git a/files/templates/mobile_navigation_bar.html b/files/templates/mobile_navigation_bar.html index 2a155be37..636d90435 100644 --- a/files/templates/mobile_navigation_bar.html +++ b/files/templates/mobile_navigation_bar.html @@ -27,7 +27,7 @@ - {% if v and v.admin_level > 1 %} + {% if v and v.admin_level >= 2 %} @@ -477,7 +477,7 @@


 
-						{% if v and v.admin_level > 2 %}
+						{% if v and v.admin_level >= 3 %}
 							Verify
 							Unverify
 						{% endif %}