diff --git a/files/classes/user.py b/files/classes/user.py index 63cb745ac..8934b5de0 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -407,7 +407,7 @@ class User(Base): return True @lazy - def mods(self, hole): + def mods_hole(self, hole): if self.is_permabanned or self.shadowbanned: return False if hole == 'test'and self.truescore >= TRUESCORE_MINIMUM: return True if self.admin_level >= PERMS['MODS_EVERY_HOLE']: return True diff --git a/files/routes/comments.py b/files/routes/comments.py index a864927db..0d19a9a3e 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -614,7 +614,7 @@ def diff_words(answer, guess): def toggle_comment_nsfw(cid, v): comment = get_comment(cid) - if comment.author_id != v.id and v.admin_level < PERMS['POST_COMMENT_MODERATION'] and not (comment.post and comment.post.hole and v.mods(comment.post.hole)) and comment.wall_user_id != v.id: + if comment.author_id != v.id and v.admin_level < PERMS['POST_COMMENT_MODERATION'] and not (comment.post and comment.post.hole and v.mods_hole(comment.post.hole)) and comment.wall_user_id != v.id: abort(403) comment.nsfw = not comment.nsfw @@ -628,7 +628,7 @@ def toggle_comment_nsfw(cid, v): target_comment_id = comment.id, ) g.db.add(ma) - elif comment.post and comment.post.hole and v.mods(comment.post.hole): + elif comment.post and comment.post.hole and v.mods_hole(comment.post.hole): ma = HoleAction( hole = comment.post.hole, kind = "set_nsfw_comment" if comment.nsfw else "unset_nsfw_comment", diff --git a/files/routes/holes.py b/files/routes/holes.py index 609a4699f..d79549399 100644 --- a/files/routes/holes.py +++ b/files/routes/holes.py @@ -19,11 +19,11 @@ def exile_post(v, pid): hole = p.hole if not hole: abort(400) - if not v.mods(hole): abort(403) + if not v.mods_hole(hole): abort(403) u = p.author - if u.mods(hole): abort(403) + if u.mods_hole(hole): abort(403) if not u.exiler_username(hole): exile = Exile(user_id=u.id, hole=hole, exiler_id=v.id) @@ -53,11 +53,11 @@ def exile_comment(v, cid): hole = c.post.hole if not hole: abort(400) - if not v.mods(hole): abort(403) + if not v.mods_hole(hole): abort(403) u = c.author - if u.mods(hole): abort(403) + if u.mods_hole(hole): abort(403) if not u.exiler_username(hole): exile = Exile(user_id=u.id, hole=hole, exiler_id=v.id) @@ -85,7 +85,7 @@ def exile_comment(v, cid): def unexile(v, hole, uid): u = get_account(uid) - if not v.mods(hole): abort(403) + if not v.mods_hole(hole): abort(403) if u.exiler_username(hole): exile = g.db.query(Exile).filter_by(user_id=u.id, hole=hole).one_or_none() @@ -201,7 +201,7 @@ def unfollow_sub(v, hole): @limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400) @limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID) @auth_required -def mods(v, hole): +def mods_hole(v, hole): if hole == 'test': return redirect('/users') @@ -273,7 +273,7 @@ def add_mod(v, hole): abort(403, "Everyone is already a mod of this hole!") hole = get_hole(hole).name - if not v.mods(hole): abort(403) + if not v.mods_hole(hole): abort(403) user = request.values.get('user') @@ -312,7 +312,7 @@ def add_mod(v, hole): def remove_mod(v, hole): hole = get_hole(hole).name - if not v.mods(hole): abort(403) + if not v.mods_hole(hole): abort(403) uid = request.values.get('uid') @@ -405,7 +405,7 @@ def kick(v, pid): post = get_post(pid) if not post.hole: abort(403) - if not v.mods(post.hole): abort(403) + if not v.mods_hole(post.hole): abort(403) old = post.hole post.hole = None @@ -435,7 +435,7 @@ def kick(v, pid): @auth_required def hole_settings(v, hole): hole = get_hole(hole) - if not v.mods(hole.name): abort(403) + if not v.mods_hole(hole.name): abort(403) return render_template('hole/settings.html', v=v, sidebar=hole.sidebar, hole=hole, css=hole.css) @@ -447,7 +447,7 @@ def hole_settings(v, hole): @auth_required def post_hole_sidebar(v, hole): hole = get_hole(hole) - if not v.mods(hole.name): abort(403) + if not v.mods_hole(hole.name): abort(403) if v.shadowbanned: abort(400) sidebar = request.values.get('sidebar', '').strip() @@ -485,7 +485,7 @@ def post_hole_css(v, hole): css = request.values.get('css', '').strip() if not hole: abort(404) - if not v.mods(hole.name): abort(403) + if not v.mods_hole(hole.name): abort(403) if v.shadowbanned: abort(400) if len(css) > CSS_LENGTH_LIMIT: @@ -526,7 +526,7 @@ def upload_hole_sidebar(v, hole): if g.is_tor: abort(403, "Image uploads are not allowed through Tor") hole = get_hole(hole) - if not v.mods(hole.name): abort(403) + if not v.mods_hole(hole.name): abort(403) if v.shadowbanned: abort(500) file = request.files["sidebar"] @@ -554,7 +554,7 @@ def upload_hole_sidebar(v, hole): @auth_required def delete_hole_sidebar(v, hole, index): hole = get_hole(hole) - if not v.mods(hole.name): abort(403) + if not v.mods_hole(hole.name): abort(403) if not hole.sidebarurls: abort(404, f"Sidebar image not found (/h/{hole.name} has no sidebar images)") @@ -584,7 +584,7 @@ def delete_hole_sidebar(v, hole, index): @auth_required def delete_all_hole_sidebars(v, hole): hole = get_hole(hole) - if not v.mods(hole.name): abort(403) + if not v.mods_hole(hole.name): abort(403) for sidebar in hole.sidebarurls: try: @@ -614,7 +614,7 @@ def upload_hole_banner(v, hole): if g.is_tor: abort(403, "Image uploads are not allowed through Tor") hole = get_hole(hole) - if not v.mods(hole.name): abort(403) + if not v.mods_hole(hole.name): abort(403) if v.shadowbanned: abort(500) file = request.files["banner"] @@ -642,7 +642,7 @@ def upload_hole_banner(v, hole): @auth_required def delete_hole_banner(v, hole, index): hole = get_hole(hole) - if not v.mods(hole.name): abort(403) + if not v.mods_hole(hole.name): abort(403) if not hole.bannerurls: abort(404, f"Banner not found (/h/{hole.name} has no banners)") @@ -672,7 +672,7 @@ def delete_hole_banner(v, hole, index): @auth_required def delete_all_hole_banners(v, hole): hole = get_hole(hole) - if not v.mods(hole.name): abort(403) + if not v.mods_hole(hole.name): abort(403) for banner in hole.bannerurls: try: @@ -702,7 +702,7 @@ def hole_marsey(v, hole): if g.is_tor: abort(403, "Image uploads are not allowed through TOR!") hole = get_hole(hole) - if not v.mods(hole.name): abort(403) + if not v.mods_hole(hole.name): abort(403) if v.shadowbanned: abort(500) file = request.files["marsey"] @@ -746,7 +746,7 @@ def hole_pin(v, pid): if not p.hole: abort(403) - if not v.mods(p.hole): abort(403) + if not v.mods_hole(p.hole): abort(403) num = g.db.query(Post).filter(Post.hole == p.hole, Post.hole_pinned != None).count() if num >= 2: @@ -782,7 +782,7 @@ def hole_unpin(v, pid): if not p.hole: abort(403) - if not v.mods(p.hole): abort(403) + if not v.mods_hole(p.hole): abort(403) p.hole_pinned = None g.db.add(p) @@ -814,7 +814,7 @@ def hole_stealth(v, hole): hole = get_hole(hole) if hole.name in {'braincels','smuggies','mnn','glory'} and v.admin_level < PERMS["MODS_EVERY_HOLE"]: abort(403) - if not v.mods(hole.name): abort(403) + if not v.mods_hole(hole.name): abort(403) hole.stealth = not hole.stealth g.db.add(hole) @@ -851,7 +851,7 @@ def pin_comment_mod(cid, v): comment = get_comment(cid, v=v) if not comment.stickied: - if not (comment.post.hole and v.mods(comment.post.hole)): abort(403) + if not (comment.post.hole and v.mods_hole(comment.post.hole)): abort(403) comment.stickied = v.username + " (Mod)" @@ -884,7 +884,7 @@ def unpin_comment_mod(cid, v): comment = get_comment(cid, v=v) if comment.stickied: - if not (comment.post.hole and v.mods(comment.post.hole)): abort(403) + if not (comment.post.hole and v.mods_hole(comment.post.hole)): abort(403) comment.stickied = None comment.stickied_utc = None diff --git a/files/routes/posts.py b/files/routes/posts.py index 2c8f08dde..989fd5fea 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -767,7 +767,7 @@ def undelete_post_pid(pid, v): def mark_post_nsfw(pid, v): p = get_post(pid) - if p.author_id != v.id and v.admin_level < PERMS['POST_COMMENT_MODERATION'] and not (p.hole and v.mods(p.hole)): + if p.author_id != v.id and v.admin_level < PERMS['POST_COMMENT_MODERATION'] and not (p.hole and v.mods_hole(p.hole)): abort(403) if p.nsfw and v.is_permabanned: @@ -806,7 +806,7 @@ def mark_post_nsfw(pid, v): def unmark_post_nsfw(pid, v): p = get_post(pid) - if p.author_id != v.id and v.admin_level < PERMS['POST_COMMENT_MODERATION'] and not (p.hole and v.mods(p.hole)): + if p.author_id != v.id and v.admin_level < PERMS['POST_COMMENT_MODERATION'] and not (p.hole and v.mods_hole(p.hole)): abort(403) if p.nsfw and v.is_permabanned: diff --git a/files/routes/reporting.py b/files/routes/reporting.py index 2cec579cb..f5b8f56b5 100644 --- a/files/routes/reporting.py +++ b/files/routes/reporting.py @@ -31,7 +31,7 @@ def report_post(pid, v): if len(reason_html) > 350: abort(400, "Report reason too long!") - if reason.startswith('!') and (v.admin_level >= PERMS['POST_COMMENT_MODERATION'] or post.hole and v.mods(post.hole)): + if reason.startswith('!') and (v.admin_level >= PERMS['POST_COMMENT_MODERATION'] or post.hole and v.mods_hole(post.hole)): post.flair = reason_html[1:] g.db.add(post) if v.admin_level >= PERMS['POST_COMMENT_MODERATION']: @@ -166,7 +166,7 @@ def move_post(post, v, reason): hole_to = get_hole(reason, graceful=True) hole_to = hole_to.name if hole_to else None - can_move_post = v.admin_level >= PERMS['POST_COMMENT_MODERATION'] or (post.hole and v.mods(hole_from)) + can_move_post = v.admin_level >= PERMS['POST_COMMENT_MODERATION'] or (post.hole and v.mods_hole(hole_from)) if hole_from != 'chudrama': # posts can only be moved out of /h/chudrama by admins can_move_post = can_move_post or post.author_id == v.id if not can_move_post: return False diff --git a/files/templates/comments.html b/files/templates/comments.html index ed05028f6..a4f231518 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -433,7 +433,7 @@ {% set url = "sticky_comment" %} {% elif v.id == c.post.author_id %} {% set url = "pin_comment" %} - {% elif c.post.hole and v.mods(c.post.hole) %} + {% elif c.post.hole and v.mods_hole(c.post.hole) %} {% set url = "pin_comment_mod" %} {% endif %} @@ -464,7 +464,7 @@ {% if c.parent_post %} {% set hole = c.post.hole %} - {% if hole and v.mods(hole) and not c.author.mods(hole) %} + {% if hole and v.mods_hole(hole) and not c.author.mods_hole(hole) %} {% endif %} @@ -475,7 +475,7 @@ {% endif %} - {% if FEATURES['NSFW_MARKING'] and (c.parent_post or c.wall_user_id) and (c.author_id == v.id or v.admin_level >= PERMS['POST_COMMENT_MODERATION'] or (c.post.hole and v.mods(c.post.hole))) or c.wall_user_id == v.id %} + {% if FEATURES['NSFW_MARKING'] and (c.parent_post or c.wall_user_id) and (c.author_id == v.id or v.admin_level >= PERMS['POST_COMMENT_MODERATION'] or (c.post.hole and v.mods_hole(c.post.hole))) or c.wall_user_id == v.id %} {% endif %} @@ -633,7 +633,7 @@ {% endif %} {% endif %} - {% if FEATURES['NSFW_MARKING'] and v.admin_level < PERMS['POST_COMMENT_MODERATION'] and (c.author_id == v.id or (c.post.hole and v.mods(c.post.hole))) or c.wall_user_id == v.id %} + {% if FEATURES['NSFW_MARKING'] and v.admin_level < PERMS['POST_COMMENT_MODERATION'] and (c.author_id == v.id or (c.post.hole and v.mods_hole(c.post.hole))) or c.wall_user_id == v.id %} @@ -643,7 +643,7 @@ {% if c.parent_post and v.id == c.post.author_id %} - {% elif c.post.hole and v.mods(c.post.hole) %} + {% elif c.post.hole and v.mods_hole(c.post.hole) %} {% endif %} @@ -651,7 +651,7 @@ {% if c.parent_post %} {% set hole = c.post.hole %} - {% if hole and v.mods(hole) and not c.author.mods(hole) %} + {% if hole and v.mods_hole(hole) and not c.author.mods_hole(hole) %} {% endif %} diff --git a/files/templates/hole/exilees.html b/files/templates/hole/exilees.html index bab024637..9f9317822 100644 --- a/files/templates/hole/exilees.html +++ b/files/templates/hole/exilees.html @@ -24,7 +24,7 @@ - {% if v.mods(hole.name) %} + {% if v.mods_hole(hole.name) %}
diff --git a/files/templates/hole/mods.html b/files/templates/hole/mods.html index 97b967010..6898c573c 100644 --- a/files/templates/hole/mods.html +++ b/files/templates/hole/mods.html @@ -34,7 +34,7 @@ - {% if v.mods(hole.name) %} + {% if v.mods_hole(hole.name) %} diff --git a/files/templates/post_actions.html b/files/templates/post_actions.html index ff694a5dc..9bebb113c 100644 --- a/files/templates/post_actions.html +++ b/files/templates/post_actions.html @@ -60,7 +60,7 @@ {% endif %} - {% if p.hole and v.mods(p.hole) %} + {% if p.hole and v.mods_hole(p.hole) %} {% endif %} @@ -72,14 +72,14 @@ {% endif %} - {% if p.hole and v.mods(p.hole) %} + {% if p.hole and v.mods_hole(p.hole) %} - {% if not p.author.mods(p.hole) %} + {% if not p.author.mods_hole(p.hole) %} {% endif %} {% endif %} - {% if FEATURES['NSFW_MARKING'] and (v.id == p.author_id or v.admin_level >= PERMS['POST_COMMENT_MODERATION'] or (p.hole and v.mods(p.hole))) %} + {% if FEATURES['NSFW_MARKING'] and (v.id == p.author_id or v.admin_level >= PERMS['POST_COMMENT_MODERATION'] or (p.hole and v.mods_hole(p.hole))) %} {% endif %} diff --git a/files/templates/post_actions_mobile.html b/files/templates/post_actions_mobile.html index 695702628..d0639987a 100644 --- a/files/templates/post_actions_mobile.html +++ b/files/templates/post_actions_mobile.html @@ -31,7 +31,7 @@ {% endif %} -{% if p.hole and v.mods(p.hole) %} +{% if p.hole and v.mods_hole(p.hole) %} {% endif %} @@ -50,15 +50,15 @@ {% endif %} {% endif %} -{% if FEATURES['NSFW_MARKING'] and (v.id == p.author_id or (p.hole and v.mods(p.hole))) %} +{% if FEATURES['NSFW_MARKING'] and (v.id == p.author_id or (p.hole and v.mods_hole(p.hole))) %} {% endif %} -{% if p.hole and v.mods(p.hole) %} +{% if p.hole and v.mods_hole(p.hole) %} - {% if not p.author.mods(p.hole) %} + {% if not p.author.mods_hole(p.hole) %} {% endif %} diff --git a/files/templates/sidebar_rDrama.html b/files/templates/sidebar_rDrama.html index c305ea75e..c94672c49 100644 --- a/files/templates/sidebar_rDrama.html +++ b/files/templates/sidebar_rDrama.html @@ -65,7 +65,7 @@ {% if hole %}
- {% if v and v.mods(hole.name) %} + {% if v and v.mods_hole(hole.name) %} /h/{{hole}} SETTINGS {% endif %}