forked from rDrama/rDrama
sex
parent
3ecebe643a
commit
fdb50fc88d
|
@ -296,16 +296,6 @@ class Comment(Base):
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@property
|
|
||||||
@lazy
|
|
||||||
def is_blocking(self):
|
|
||||||
return self.__dict__.get('_is_blocking', 0)
|
|
||||||
|
|
||||||
@property
|
|
||||||
@lazy
|
|
||||||
def is_blocked(self):
|
|
||||||
return self.__dict__.get('_is_blocked', 0)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def body(self):
|
def body(self):
|
||||||
if self.comment_aux: return self.comment_aux.body
|
if self.comment_aux: return self.comment_aux.body
|
||||||
|
|
|
@ -212,18 +212,9 @@ class Submission(Base):
|
||||||
@lazy
|
@lazy
|
||||||
def rendered_page(self, sort=None, last_view_utc=None, comment=None, comment_info=None, v=None):
|
def rendered_page(self, sort=None, last_view_utc=None, comment=None, comment_info=None, v=None):
|
||||||
|
|
||||||
# check for banned
|
if self.is_banned and not (v and (v.admin_level >= 3 or self.author_id == v.id)): template = "submission_banned.html"
|
||||||
if v and (v.admin_level >= 3 or self.author_id == v.id):
|
else: template = "submission.html"
|
||||||
template = "submission.html"
|
|
||||||
elif self.is_banned:
|
|
||||||
template = "submission_banned.html"
|
|
||||||
else:
|
|
||||||
template = "submission.html"
|
|
||||||
|
|
||||||
# load and tree comments
|
|
||||||
# calling this function with a comment object will do a comment
|
|
||||||
# permalink thing
|
|
||||||
if "replies" not in self.__dict__ and "preloaded_comments" in self.__dict__:
|
|
||||||
self.tree_comments(comment=comment)
|
self.tree_comments(comment=comment)
|
||||||
|
|
||||||
return render_template(template,
|
return render_template(template,
|
||||||
|
@ -233,7 +224,6 @@ class Submission(Base):
|
||||||
sort=sort,
|
sort=sort,
|
||||||
linked_comment=comment,
|
linked_comment=comment,
|
||||||
comment_info=comment_info,
|
comment_info=comment_info,
|
||||||
render_replies=True,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -247,9 +237,8 @@ class Submission(Base):
|
||||||
|
|
||||||
def tree_comments(self, comment=None, v=None):
|
def tree_comments(self, comment=None, v=None):
|
||||||
|
|
||||||
comments = self.__dict__.get('preloaded_comments',[])
|
comments = self.__dict__.get('preloaded_comments', [])
|
||||||
if not comments:
|
if not comments: return
|
||||||
return
|
|
||||||
|
|
||||||
pinned_comment=[]
|
pinned_comment=[]
|
||||||
|
|
||||||
|
@ -257,21 +246,16 @@ class Submission(Base):
|
||||||
for c in comments:
|
for c in comments:
|
||||||
|
|
||||||
if c.is_pinned and c.parent_fullname==self.fullname:
|
if c.is_pinned and c.parent_fullname==self.fullname:
|
||||||
pinned_comment+=[c]
|
pinned_comment += [c]
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if c.parent_fullname in index:
|
if c.parent_fullname in index: index[c.parent_fullname].append(c)
|
||||||
index[c.parent_fullname].append(c)
|
else: index[c.parent_fullname] = [c]
|
||||||
else:
|
|
||||||
index[c.parent_fullname] = [c]
|
|
||||||
|
|
||||||
for c in comments:
|
for c in comments: c.__dict__["replies"] = index.get(c.fullname, [])
|
||||||
c.__dict__["replies"] = index.get(c.fullname, [])
|
|
||||||
|
|
||||||
if comment:
|
if comment: self.__dict__["replies"] = [comment]
|
||||||
self.__dict__["replies"] = [comment]
|
else: self.__dict__["replies"] = pinned_comment + index.get(self.fullname, [])
|
||||||
else:
|
|
||||||
self.__dict__["replies"] = pinned_comment + index.get(self.fullname, [])
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@lazy
|
@lazy
|
||||||
|
@ -468,20 +452,6 @@ class Submission(Base):
|
||||||
self.submission_aux.embed_url = x
|
self.submission_aux.embed_url = x
|
||||||
g.db.add(self.submission_aux)
|
g.db.add(self.submission_aux)
|
||||||
|
|
||||||
@property
|
|
||||||
@lazy
|
|
||||||
def is_blocked(self):
|
|
||||||
return self.__dict__.get('_is_blocked', False)
|
|
||||||
|
|
||||||
@property
|
|
||||||
@lazy
|
|
||||||
def is_blocking(self):
|
|
||||||
return self.__dict__.get('_is_blocking', False)
|
|
||||||
|
|
||||||
#@property
|
|
||||||
#def award_count(self):
|
|
||||||
#return len(self.awards)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@lazy
|
@lazy
|
||||||
def is_image(self):
|
def is_image(self):
|
||||||
|
|
|
@ -533,16 +533,6 @@ class User(Base):
|
||||||
def is_suspended(self):
|
def is_suspended(self):
|
||||||
return (self.is_banned and (not self.unban_utc or self.unban_utc > time.time()))
|
return (self.is_banned and (not self.unban_utc or self.unban_utc > time.time()))
|
||||||
|
|
||||||
@property
|
|
||||||
@lazy
|
|
||||||
def is_blocking(self):
|
|
||||||
return self.__dict__.get('_is_blocking', 0)
|
|
||||||
|
|
||||||
@property
|
|
||||||
@lazy
|
|
||||||
def is_blocked(self):
|
|
||||||
return self.__dict__.get('_is_blocked', 0)
|
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@lazy
|
@lazy
|
||||||
|
|
|
@ -36,8 +36,8 @@ def get_user(username, v=None, graceful=False):
|
||||||
)
|
)
|
||||||
).first()
|
).first()
|
||||||
|
|
||||||
user._is_blocking = block and block.user_id == v.id
|
user.is_blocking = block and block.user_id == v.id
|
||||||
user._is_blocked = block and block.target_id == v.id
|
user.is_blocked = block and block.target_id == v.id
|
||||||
|
|
||||||
return user
|
return user
|
||||||
|
|
||||||
|
@ -64,8 +64,8 @@ def get_account(id, v=None):
|
||||||
)
|
)
|
||||||
).first()
|
).first()
|
||||||
|
|
||||||
user._is_blocking = block and block.user_id == v.id
|
user.is_blocking = block and block.user_id == v.id
|
||||||
user._is_blocked = block and block.target_id == v.id
|
user.is_blocked = block and block.target_id == v.id
|
||||||
|
|
||||||
return user
|
return user
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ def get_post(i, v=None, graceful=False, **kwargs):
|
||||||
abort(404)
|
abort(404)
|
||||||
x = items[0]
|
x = items[0]
|
||||||
x.voted = items[1] or 0
|
x.voted = items[1] or 0
|
||||||
x._is_blocking = items[2] or 0
|
x.is_blocking = items[2] or 0
|
||||||
else:
|
else:
|
||||||
items = g.db.query(
|
items = g.db.query(
|
||||||
Submission
|
Submission
|
||||||
|
@ -152,8 +152,8 @@ def get_posts(pids, v=None):
|
||||||
output = [p[0] for p in query]
|
output = [p[0] for p in query]
|
||||||
for i in range(len(output)):
|
for i in range(len(output)):
|
||||||
output[i].voted = query[i][1] or 0
|
output[i].voted = query[i][1] or 0
|
||||||
output[i]._is_blocking = query[i][2] or 0
|
output[i].is_blocking = query[i][2] or 0
|
||||||
output[i]._is_blocked = query[i][3] or 0
|
output[i].is_blocked = query[i][3] or 0
|
||||||
else:
|
else:
|
||||||
output = g.db.query(Submission,).options(lazyload('*')).filter(Submission.id.in_(pids)).all()
|
output = g.db.query(Submission,).options(lazyload('*')).filter(Submission.id.in_(pids)).all()
|
||||||
|
|
||||||
|
@ -181,8 +181,8 @@ def get_comment(i, v=None, graceful=False, **kwargs):
|
||||||
|
|
||||||
vts = g.db.query(CommentVote).options(lazyload('*')).filter_by(user_id=v.id, comment_id=comment.id)
|
vts = g.db.query(CommentVote).options(lazyload('*')).filter_by(user_id=v.id, comment_id=comment.id)
|
||||||
vt = g.db.query(CommentVote).options(lazyload('*')).filter_by(user_id=v.id, comment_id=comment.id).first()
|
vt = g.db.query(CommentVote).options(lazyload('*')).filter_by(user_id=v.id, comment_id=comment.id).first()
|
||||||
comment._is_blocking = block and block.user_id == v.id
|
comment.is_blocking = block and block.user_id == v.id
|
||||||
comment._is_blocked = block and block.target_id == v.id
|
comment.is_blocked = block and block.target_id == v.id
|
||||||
comment.voted = vt.vote_type if vt else 0
|
comment.voted = vt.vote_type if vt else 0
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
@ -233,8 +233,8 @@ def get_comments(cids, v=None, load_parent=False):
|
||||||
for c in comments:
|
for c in comments:
|
||||||
comment = c[0]
|
comment = c[0]
|
||||||
comment.voted = c[1] or 0
|
comment.voted = c[1] or 0
|
||||||
comment._is_blocking = c[2] or 0
|
comment.is_blocking = c[2] or 0
|
||||||
comment._is_blocked = c[3] or 0
|
comment.is_blocked = c[3] or 0
|
||||||
output.append(comment)
|
output.append(comment)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -1156,7 +1156,6 @@ def admin_distinguish_comment(c_id, v):
|
||||||
"comments.html",
|
"comments.html",
|
||||||
v=v,
|
v=v,
|
||||||
comments=[comment],
|
comments=[comment],
|
||||||
render_replies=False,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
html=str(BeautifulSoup(html, features="html.parser").find(id=f"comment-{comment.id}-only"))
|
html=str(BeautifulSoup(html, features="html.parser").find(id=f"comment-{comment.id}-only"))
|
||||||
|
|
|
@ -55,20 +55,12 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None):
|
||||||
if request.headers.get("Authorization"): return {'error': f'This content is not suitable for some users and situations.'}
|
if request.headers.get("Authorization"): return {'error': f'This content is not suitable for some users and situations.'}
|
||||||
else: render_template("errors/nsfw.html", v=v)
|
else: render_template("errors/nsfw.html", v=v)
|
||||||
|
|
||||||
post._preloaded_comments = [comment]
|
|
||||||
|
|
||||||
# context improver
|
|
||||||
try: context = int(request.values.get("context", 0))
|
try: context = int(request.values.get("context", 0))
|
||||||
except: context = 0
|
except: context = 0
|
||||||
comment_info = comment
|
comment_info = comment
|
||||||
c = comment
|
c = comment
|
||||||
while context > 0 and c.level > 1:
|
while context > 0 and c.level > 1:
|
||||||
|
c = c.parent_comment
|
||||||
parent = get_comment(c.parent_comment_id, v=v)
|
|
||||||
|
|
||||||
post._preloaded_comments += [parent]
|
|
||||||
|
|
||||||
c = parent
|
|
||||||
context -= 1
|
context -= 1
|
||||||
top_comment = c
|
top_comment = c
|
||||||
|
|
||||||
|
@ -114,11 +106,15 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None):
|
||||||
isouter=True
|
isouter=True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
output = []
|
||||||
for c in comments:
|
for c in comments:
|
||||||
comment = c[0]
|
comment = c[0]
|
||||||
comment.voted = c[1] or 0
|
comment.voted = c[1] or 0
|
||||||
comment._is_blocking = c[2] or 0
|
comment.is_blocking = c[2] or 0
|
||||||
comment._is_blocked = c[3] or 0
|
comment.is_blocked = c[3] or 0
|
||||||
|
output.append(comment)
|
||||||
|
|
||||||
|
post.preloaded_comments = output
|
||||||
|
|
||||||
if request.headers.get("Authorization"): return top_comment.json
|
if request.headers.get("Authorization"): return top_comment.json
|
||||||
else: return post.rendered_page(v=v, sort=sort, comment=top_comment, comment_info=comment_info)
|
else: return post.rendered_page(v=v, sort=sort, comment=top_comment, comment_info=comment_info)
|
||||||
|
@ -593,7 +589,6 @@ def api_comment(v):
|
||||||
else: return jsonify({"html": render_template("comments.html",
|
else: return jsonify({"html": render_template("comments.html",
|
||||||
v=v,
|
v=v,
|
||||||
comments=[c],
|
comments=[c],
|
||||||
render_replies=False,
|
|
||||||
)})
|
)})
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -72,8 +72,8 @@ def notifications(v):
|
||||||
if not posts:
|
if not posts:
|
||||||
listing = []
|
listing = []
|
||||||
for c in comments:
|
for c in comments:
|
||||||
c._is_blocked = False
|
c.is_blocked = False
|
||||||
c._is_blocking = False
|
c.is_blocking = False
|
||||||
if c.parent_submission and c.parent_comment and c.parent_comment.author_id == v.id:
|
if c.parent_submission and c.parent_comment and c.parent_comment.author_id == v.id:
|
||||||
c.replies = []
|
c.replies = []
|
||||||
while c.parent_comment and c.parent_comment.author_id == v.id:
|
while c.parent_comment and c.parent_comment.author_id == v.id:
|
||||||
|
@ -104,7 +104,6 @@ def notifications(v):
|
||||||
next_exists=next_exists,
|
next_exists=next_exists,
|
||||||
page=page,
|
page=page,
|
||||||
standalone=True,
|
standalone=True,
|
||||||
render_replies=True,
|
|
||||||
is_notification_page=True)
|
is_notification_page=True)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -167,8 +167,8 @@ def post_id(pid, anything=None, v=None):
|
||||||
for c in comments:
|
for c in comments:
|
||||||
comment = c[0]
|
comment = c[0]
|
||||||
comment.voted = c[1] or 0
|
comment.voted = c[1] or 0
|
||||||
comment._is_blocking = c[2] or 0
|
comment.is_blocking = c[2] or 0
|
||||||
comment._is_blocked = c[3] or 0
|
comment.is_blocked = c[3] or 0
|
||||||
output.append(comment)
|
output.append(comment)
|
||||||
|
|
||||||
post.preloaded_comments = output
|
post.preloaded_comments = output
|
||||||
|
|
|
@ -295,7 +295,6 @@ def messagereply(v):
|
||||||
return jsonify({"html": render_template("comments.html",
|
return jsonify({"html": render_template("comments.html",
|
||||||
v=v,
|
v=v,
|
||||||
comments=[new_comment],
|
comments=[new_comment],
|
||||||
render_replies=False,
|
|
||||||
)})
|
)})
|
||||||
|
|
||||||
@app.get("/2faqr/<secret>")
|
@app.get("/2faqr/<secret>")
|
||||||
|
|
|
@ -65,7 +65,6 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{% if render_replies %}
|
|
||||||
{% if level<7 %}
|
{% if level<7 %}
|
||||||
<div id="replies-of-{{c.id}}" class="">
|
<div id="replies-of-{{c.id}}" class="">
|
||||||
{% set standalone=False %}
|
{% set standalone=False %}
|
||||||
|
@ -84,7 +83,6 @@
|
||||||
<a {% if v %}href="{{c.permalink}}?context=5#context"{% else %}href="/logged_out{{c.permalink}}?context=5#context"{% endif %}>More comments <i class="fas fa-long-arrow-right ml-1"></i></a>
|
<a {% if v %}href="{{c.permalink}}?context=5#context"{% else %}href="/logged_out{{c.permalink}}?context=5#context"{% endif %}>More comments <i class="fas fa-long-arrow-right ml-1"></i></a>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -417,7 +415,6 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
{% if render_replies %}
|
|
||||||
{% if level<7 %}
|
{% if level<7 %}
|
||||||
<div id="replies-of-{{c.id}}">
|
<div id="replies-of-{{c.id}}">
|
||||||
{% for reply in replies %}
|
{% for reply in replies %}
|
||||||
|
@ -434,7 +431,6 @@
|
||||||
<a {% if v %}href="{{c.permalink}}#context"{% else %}href="/logged_out{{c.permalink}}#context"{% endif %}>More comments <i class="fas fa-long-arrow-right ml-1"></i></a>
|
<a {% if v %}href="{{c.permalink}}#context"{% else %}href="/logged_out{{c.permalink}}#context"{% endif %}>More comments <i class="fas fa-long-arrow-right ml-1"></i></a>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue