diff --git a/files/classes/post.py b/files/classes/post.py
index 11a1a03ac..b46e23cf6 100644
--- a/files/classes/post.py
+++ b/files/classes/post.py
@@ -420,4 +420,4 @@ class Post(Base):
if self.hole == 'chudrama':
return v.admin_level >= PERMS['POST_COMMENT_MODERATION']
else:
- return v.admin_level >= PERMS['POST_COMMENT_MODERATION'] or (self.hole and v.mods_hole(self.hole)) or self.author_id == v.id
+ return v.admin_level >= PERMS['POST_COMMENT_MODERATION'] or (v.mods_hole(self.hole)) or self.author_id == v.id
diff --git a/files/classes/user.py b/files/classes/user.py
index 1b79dbf72..fc2291bad 100644
--- a/files/classes/user.py
+++ b/files/classes/user.py
@@ -429,6 +429,7 @@ class User(Base):
@lazy
def mods_hole(self, hole):
+ if not hole: return False
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 6146be1bf..7e53c0f96 100644
--- a/files/routes/comments.py
+++ b/files/routes/comments.py
@@ -611,7 +611,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_hole(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 v.mods_hole(comment.post.hole)) and comment.wall_user_id != v.id:
abort(403)
comment.nsfw = not comment.nsfw
@@ -625,7 +625,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_hole(comment.post.hole):
+ elif comment.post 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 99257d307..5a7e322fb 100644
--- a/files/routes/holes.py
+++ b/files/routes/holes.py
@@ -901,7 +901,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_hole(comment.post.hole)): abort(403)
+ if not v.mods_hole(comment.post.hole): abort(403)
comment.stickied = v.username + " (Mod)"
@@ -934,7 +934,7 @@ def unpin_comment_mod(cid, v):
comment = get_comment(cid, v=v)
if comment.stickied:
- if not (comment.post.hole and v.mods_hole(comment.post.hole)): abort(403)
+ if not 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 b89a416e9..bbf6b674a 100644
--- a/files/routes/posts.py
+++ b/files/routes/posts.py
@@ -795,7 +795,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_hole(p.hole)):
+ if p.author_id != v.id and v.admin_level < PERMS['POST_COMMENT_MODERATION'] and not v.mods_hole(p.hole):
abort(403)
p.nsfw = True
@@ -834,7 +834,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_hole(p.hole)):
+ if p.author_id != v.id and v.admin_level < PERMS['POST_COMMENT_MODERATION'] and not 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 9473fe4d4..15fcd02a7 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, "Rendered report reason is too long!")
- if reason.startswith('!') and (v.admin_level >= PERMS['POST_COMMENT_MODERATION'] or post.hole and v.mods_hole(post.hole)):
+ if reason.startswith('!') and (v.admin_level >= PERMS['POST_COMMENT_MODERATION'] or v.mods_hole(post.hole)):
post.flair = reason_html[1:]
g.db.add(post)
if v.admin_level >= PERMS['POST_COMMENT_MODERATION']:
diff --git a/files/templates/comments.html b/files/templates/comments.html
index 434db764d..c47b330d6 100644
--- a/files/templates/comments.html
+++ b/files/templates/comments.html
@@ -434,7 +434,7 @@
{% set url = "sticky_comment" %}
{% elif v.id == c.post.author_id %}
{% set url = "pin_comment" %}
- {% elif c.post.hole and v.mods_hole(c.post.hole) %}
+ {% elif v.mods_hole(c.post.hole) %}
{% set url = "pin_comment_mod" %}
{% endif %}
@@ -465,7 +465,7 @@
{% if c.parent_post %}
{% set hole = c.post.hole %}
- {% if hole and v.mods_hole(hole) and not c.author.mods_hole(hole) %}
+ {% if v.mods_hole(hole) and not c.author.mods_hole(hole) %}
{% endif %}
@@ -476,7 +476,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_hole(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 v.mods_hole(c.post.hole)) or c.wall_user_id == v.id %}
{% endif %}
@@ -634,7 +634,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_hole(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 v.mods_hole(c.post.hole)) or c.wall_user_id == v.id %}
@@ -644,7 +644,7 @@
{% if c.parent_post and v.id == c.post.author_id %}
- {% elif c.post.hole and v.mods_hole(c.post.hole) %}
+ {% elif v.mods_hole(c.post.hole) %}
{% endif %}
@@ -652,7 +652,7 @@
{% if c.parent_post %}
{% set hole = c.post.hole %}
- {% if hole and v.mods_hole(hole) and not c.author.mods_hole(hole) %}
+ {% if v.mods_hole(hole) and not c.author.mods_hole(hole) %}
{% endif %}
diff --git a/files/templates/post_actions.html b/files/templates/post_actions.html
index 0b773f6ea..8ef355fa7 100644
--- a/files/templates/post_actions.html
+++ b/files/templates/post_actions.html
@@ -68,7 +68,7 @@
{% endif %}
- {% if p.hole and v.mods_hole(p.hole) %}
+ {% if v.mods_hole(p.hole) %}
{% endif %}
@@ -83,7 +83,7 @@
{% endif %}
- {% if p.hole and v.mods_hole(p.hole) %}
+ {% if v.mods_hole(p.hole) %}
{% if not p.author.mods_hole(p.hole) %}
@@ -91,7 +91,7 @@
{% endif %}
{% endif %}
- {% if (v.id == p.author_id or v.admin_level >= PERMS['POST_COMMENT_MODERATION'] or (p.hole and v.mods_hole(p.hole))) %}
+ {% if (v.id == p.author_id or v.admin_level >= PERMS['POST_COMMENT_MODERATION'] or v.mods_hole(p.hole)) %}
{% if FEATURES['NSFW_MARKING'] %}
diff --git a/files/templates/post_actions_mobile.html b/files/templates/post_actions_mobile.html
index 8b6da3c0d..80882afea 100644
--- a/files/templates/post_actions_mobile.html
+++ b/files/templates/post_actions_mobile.html
@@ -35,7 +35,7 @@
{% endif %}
-{% if p.hole and v.mods_hole(p.hole) %}
+{% if v.mods_hole(p.hole) %}
{% endif %}
@@ -54,7 +54,7 @@
{% endif %}
{% endif %}
-{% if v.id == p.author_id or (p.hole and v.mods_hole(p.hole)) %}
+{% if v.id == p.author_id or v.mods_hole(p.hole) %}
{% if FEATURES['NSFW_MARKING'] %}
@@ -66,7 +66,7 @@
{% endif %}
{% endif %}
-{% if p.hole and v.mods_hole(p.hole) %}
+{% if v.mods_hole(p.hole) %}
{% if not p.author.mods_hole(p.hole) %}