forked from MarseyWorld/MarseyWorld
add def can_see(v)
parent
a88b9d59c4
commit
e1e7258e7a
|
@ -84,6 +84,17 @@ class Comment(Base):
|
||||||
|
|
||||||
return f"<Comment(id={self.id})>"
|
return f"<Comment(id={self.id})>"
|
||||||
|
|
||||||
|
@lazy
|
||||||
|
def can_see(self, v):
|
||||||
|
if not self.parent_submission: return True
|
||||||
|
if self.post.sub != 'chudrama': return True
|
||||||
|
if v:
|
||||||
|
if v.id == self.author_id: return True
|
||||||
|
if v.id == self.post.author_id: return True
|
||||||
|
if v and v.truecoins >= 20000: return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@lazy
|
@lazy
|
||||||
def top_comment(self):
|
def top_comment(self):
|
||||||
|
|
|
@ -77,6 +77,14 @@ class Submission(Base):
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f"<Submission(id={self.id})>"
|
return f"<Submission(id={self.id})>"
|
||||||
|
|
||||||
|
@lazy
|
||||||
|
def can_see(self, v):
|
||||||
|
if self.sub != 'chudrama': return True
|
||||||
|
if v:
|
||||||
|
if v.id == self.author_id: return True
|
||||||
|
if v and v.truecoins >= 20000: return True
|
||||||
|
return False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@lazy
|
@lazy
|
||||||
def controversial(self):
|
def controversial(self):
|
||||||
|
|
|
@ -45,6 +45,8 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None, sub=None):
|
||||||
|
|
||||||
comment = get_comment(cid, v=v)
|
comment = get_comment(cid, v=v)
|
||||||
|
|
||||||
|
if not comment.can_see(v): abort(403)
|
||||||
|
|
||||||
if comment.author.shadowbanned and not (v and v.shadowbanned) and not (v and v.admin_level >= 2):
|
if comment.author.shadowbanned and not (v and v.shadowbanned) and not (v and v.admin_level >= 2):
|
||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
|
|
|
@ -118,6 +118,8 @@ def post_id(pid, anything=None, v=None, sub=None):
|
||||||
|
|
||||||
post = get_post(pid, v=v)
|
post = get_post(pid, v=v)
|
||||||
|
|
||||||
|
if not post.can_see(v): abort(403)
|
||||||
|
|
||||||
if post.over_18 and not (v and v.over_18) and session.get('over_18', 0) < int(time.time()):
|
if post.over_18 and not (v and v.over_18) and session.get('over_18', 0) < int(time.time()):
|
||||||
if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error":"Must be 18+ to view"}, 451
|
if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error":"Must be 18+ to view"}, 451
|
||||||
return render_template("errors/nsfw.html", v=v)
|
return render_template("errors/nsfw.html", v=v)
|
||||||
|
|
|
@ -90,7 +90,7 @@
|
||||||
{% if render_replies %}
|
{% if render_replies %}
|
||||||
{% if level<9 or request.path.startswith('/notifications') or request.headers.get("xhr") %}
|
{% if level<9 or request.path.startswith('/notifications') or request.headers.get("xhr") %}
|
||||||
<div id="replies-of-{{c.fullname}}">
|
<div id="replies-of-{{c.fullname}}">
|
||||||
{% for reply in replies if not reply.parent_submission or reply.post.sub != 'chudrama' or (v and v.truecoins >= 20000) %}
|
{% for reply in replies %}
|
||||||
{{single_comment(reply, level=level+1)}}
|
{{single_comment(reply, level=level+1)}}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
@ -601,7 +601,7 @@
|
||||||
{% if render_replies %}
|
{% if render_replies %}
|
||||||
{% if level<9 or request.path.startswith('/notifications') or request.headers.get("xhr") %}
|
{% if level<9 or request.path.startswith('/notifications') or request.headers.get("xhr") %}
|
||||||
<div id="replies-of-{{c.fullname}}">
|
<div id="replies-of-{{c.fullname}}">
|
||||||
{% for reply in replies if not reply.parent_submission or reply.post.sub != 'chudrama' or (v and v.truecoins >= 20000) %}
|
{% for reply in replies %}
|
||||||
{{single_comment(reply, level=level+1)}}
|
{{single_comment(reply, level=level+1)}}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
@ -785,7 +785,7 @@
|
||||||
|
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
{% for comment in comments if not comment.parent_submission or comment.post.sub != 'chudrama' or (v and v.truecoins >= 20000) %}
|
{% for comment in comments if comment.can_see(v) %}
|
||||||
|
|
||||||
{{single_comment(comment)}}
|
{{single_comment(comment)}}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% for p in listing if p.sub != 'chudrama' or (v and v.truecoins >= 20000) %}
|
{% for p in listing if p.can_see(v) %}
|
||||||
|
|
||||||
{% set ups=p.upvotes %}
|
{% set ups=p.upvotes %}
|
||||||
{% set downs=p.downvotes %}
|
{% set downs=p.downvotes %}
|
||||||
|
|
Loading…
Reference in New Issue