sex
This commit is contained in:
parent
8a848c9f45
commit
7c0b0fc413
10 changed files with 66 additions and 128 deletions
|
@ -296,16 +296,6 @@ class Comment(Base):
|
|||
|
||||
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
|
||||
def body(self):
|
||||
if self.comment_aux: return self.comment_aux.body
|
||||
|
|
|
@ -212,19 +212,10 @@ class Submission(Base):
|
|||
@lazy
|
||||
def rendered_page(self, sort=None, last_view_utc=None, comment=None, comment_info=None, v=None):
|
||||
|
||||
# check for banned
|
||||
if v and (v.admin_level >= 3 or self.author_id == v.id):
|
||||
template = "submission.html"
|
||||
elif self.is_banned:
|
||||
template = "submission_banned.html"
|
||||
else:
|
||||
template = "submission.html"
|
||||
if self.is_banned and not (v and (v.admin_level >= 3 or self.author_id == v.id)): 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,
|
||||
v=v,
|
||||
|
@ -233,7 +224,6 @@ class Submission(Base):
|
|||
sort=sort,
|
||||
linked_comment=comment,
|
||||
comment_info=comment_info,
|
||||
render_replies=True,
|
||||
)
|
||||
|
||||
@property
|
||||
|
@ -247,9 +237,8 @@ class Submission(Base):
|
|||
|
||||
def tree_comments(self, comment=None, v=None):
|
||||
|
||||
comments = self.__dict__.get('preloaded_comments',[])
|
||||
if not comments:
|
||||
return
|
||||
comments = self.__dict__.get('preloaded_comments', [])
|
||||
if not comments: return
|
||||
|
||||
pinned_comment=[]
|
||||
|
||||
|
@ -257,21 +246,16 @@ class Submission(Base):
|
|||
for c in comments:
|
||||
|
||||
if c.is_pinned and c.parent_fullname==self.fullname:
|
||||
pinned_comment+=[c]
|
||||
pinned_comment += [c]
|
||||
continue
|
||||
|
||||
if c.parent_fullname in index:
|
||||
index[c.parent_fullname].append(c)
|
||||
else:
|
||||
index[c.parent_fullname] = [c]
|
||||
if c.parent_fullname in index: index[c.parent_fullname].append(c)
|
||||
else: index[c.parent_fullname] = [c]
|
||||
|
||||
for c in comments:
|
||||
c.__dict__["replies"] = index.get(c.fullname, [])
|
||||
for c in comments: c.__dict__["replies"] = index.get(c.fullname, [])
|
||||
|
||||
if comment:
|
||||
self.__dict__["replies"] = [comment]
|
||||
else:
|
||||
self.__dict__["replies"] = pinned_comment + index.get(self.fullname, [])
|
||||
if comment: self.__dict__["replies"] = [comment]
|
||||
else: self.__dict__["replies"] = pinned_comment + index.get(self.fullname, [])
|
||||
|
||||
@property
|
||||
@lazy
|
||||
|
@ -468,20 +452,6 @@ class Submission(Base):
|
|||
self.submission_aux.embed_url = x
|
||||
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
|
||||
@lazy
|
||||
def is_image(self):
|
||||
|
|
|
@ -533,16 +533,6 @@ class User(Base):
|
|||
def is_suspended(self):
|
||||
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
|
||||
@lazy
|
||||
|
|
|
@ -36,8 +36,8 @@ def get_user(username, v=None, graceful=False):
|
|||
)
|
||||
).first()
|
||||
|
||||
user._is_blocking = block and block.user_id == v.id
|
||||
user._is_blocked = block and block.target_id == v.id
|
||||
user.is_blocking = block and block.user_id == v.id
|
||||
user.is_blocked = block and block.target_id == v.id
|
||||
|
||||
return user
|
||||
|
||||
|
@ -64,8 +64,8 @@ def get_account(id, v=None):
|
|||
)
|
||||
).first()
|
||||
|
||||
user._is_blocking = block and block.user_id == v.id
|
||||
user._is_blocked = block and block.target_id == v.id
|
||||
user.is_blocking = block and block.user_id == v.id
|
||||
user.is_blocked = block and block.target_id == v.id
|
||||
|
||||
return user
|
||||
|
||||
|
@ -102,7 +102,7 @@ def get_post(i, v=None, graceful=False, **kwargs):
|
|||
abort(404)
|
||||
x = items[0]
|
||||
x.voted = items[1] or 0
|
||||
x._is_blocking = items[2] or 0
|
||||
x.is_blocking = items[2] or 0
|
||||
else:
|
||||
items = g.db.query(
|
||||
Submission
|
||||
|
@ -152,8 +152,8 @@ def get_posts(pids, v=None):
|
|||
output = [p[0] for p in query]
|
||||
for i in range(len(output)):
|
||||
output[i].voted = query[i][1] or 0
|
||||
output[i]._is_blocking = query[i][2] or 0
|
||||
output[i]._is_blocked = query[i][3] or 0
|
||||
output[i].is_blocking = query[i][2] or 0
|
||||
output[i].is_blocked = query[i][3] or 0
|
||||
else:
|
||||
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)
|
||||
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_blocked = block and block.target_id == v.id
|
||||
comment.is_blocking = block and block.user_id == v.id
|
||||
comment.is_blocked = block and block.target_id == v.id
|
||||
comment.voted = vt.vote_type if vt else 0
|
||||
|
||||
else:
|
||||
|
@ -233,8 +233,8 @@ def get_comments(cids, v=None, load_parent=False):
|
|||
for c in comments:
|
||||
comment = c[0]
|
||||
comment.voted = c[1] or 0
|
||||
comment._is_blocking = c[2] or 0
|
||||
comment._is_blocked = c[3] or 0
|
||||
comment.is_blocking = c[2] or 0
|
||||
comment.is_blocked = c[3] or 0
|
||||
output.append(comment)
|
||||
|
||||
else:
|
||||
|
|
|
@ -1156,7 +1156,6 @@ def admin_distinguish_comment(c_id, v):
|
|||
"comments.html",
|
||||
v=v,
|
||||
comments=[comment],
|
||||
render_replies=False,
|
||||
)
|
||||
|
||||
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.'}
|
||||
else: render_template("errors/nsfw.html", v=v)
|
||||
|
||||
post._preloaded_comments = [comment]
|
||||
|
||||
# context improver
|
||||
try: context = int(request.values.get("context", 0))
|
||||
except: context = 0
|
||||
comment_info = comment
|
||||
c = comment
|
||||
while context > 0 and c.level > 1:
|
||||
|
||||
parent = get_comment(c.parent_comment_id, v=v)
|
||||
|
||||
post._preloaded_comments += [parent]
|
||||
|
||||
c = parent
|
||||
c = c.parent_comment
|
||||
context -= 1
|
||||
top_comment = c
|
||||
|
||||
|
@ -114,11 +106,15 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None):
|
|||
isouter=True
|
||||
)
|
||||
|
||||
output = []
|
||||
for c in comments:
|
||||
comment = c[0]
|
||||
comment.voted = c[1] or 0
|
||||
comment._is_blocking = c[2] or 0
|
||||
comment._is_blocked = c[3] or 0
|
||||
comment.is_blocking = c[2] 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
|
||||
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",
|
||||
v=v,
|
||||
comments=[c],
|
||||
render_replies=False,
|
||||
)})
|
||||
|
||||
|
||||
|
|
|
@ -72,8 +72,8 @@ def notifications(v):
|
|||
if not posts:
|
||||
listing = []
|
||||
for c in comments:
|
||||
c._is_blocked = False
|
||||
c._is_blocking = False
|
||||
c.is_blocked = False
|
||||
c.is_blocking = False
|
||||
if c.parent_submission and c.parent_comment and c.parent_comment.author_id == v.id:
|
||||
c.replies = []
|
||||
while c.parent_comment and c.parent_comment.author_id == v.id:
|
||||
|
@ -104,7 +104,6 @@ def notifications(v):
|
|||
next_exists=next_exists,
|
||||
page=page,
|
||||
standalone=True,
|
||||
render_replies=True,
|
||||
is_notification_page=True)
|
||||
|
||||
|
||||
|
|
|
@ -167,8 +167,8 @@ def post_id(pid, anything=None, v=None):
|
|||
for c in comments:
|
||||
comment = c[0]
|
||||
comment.voted = c[1] or 0
|
||||
comment._is_blocking = c[2] or 0
|
||||
comment._is_blocked = c[3] or 0
|
||||
comment.is_blocking = c[2] or 0
|
||||
comment.is_blocked = c[3] or 0
|
||||
output.append(comment)
|
||||
|
||||
post.preloaded_comments = output
|
||||
|
|
|
@ -295,7 +295,6 @@ def messagereply(v):
|
|||
return jsonify({"html": render_template("comments.html",
|
||||
v=v,
|
||||
comments=[new_comment],
|
||||
render_replies=False,
|
||||
)})
|
||||
|
||||
@app.get("/2faqr/<secret>")
|
||||
|
|
|
@ -65,26 +65,24 @@
|
|||
|
||||
|
||||
|
||||
{% if render_replies %}
|
||||
{% if level<7 %}
|
||||
<div id="replies-of-{{c.id}}" class="">
|
||||
{% set standalone=False %}
|
||||
{% for reply in replies %}
|
||||
{{single_comment(reply, level=level+1)}}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% elif replies %}
|
||||
<div id="replies-of-{{c.id}}" class="d-none d-md-block">
|
||||
{% set standalone=False %}
|
||||
{% for reply in replies %}
|
||||
{{single_comment(reply, level=level+1)}}
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div id="morecomment-{{c.id}}" class="d-block d-md-none mt-2 more-comments text-small">
|
||||
<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>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if level<7 %}
|
||||
<div id="replies-of-{{c.id}}" class="">
|
||||
{% set standalone=False %}
|
||||
{% for reply in replies %}
|
||||
{{single_comment(reply, level=level+1)}}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% elif replies %}
|
||||
<div id="replies-of-{{c.id}}" class="d-none d-md-block">
|
||||
{% set standalone=False %}
|
||||
{% for reply in replies %}
|
||||
{{single_comment(reply, level=level+1)}}
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div id="morecomment-{{c.id}}" class="d-block d-md-none mt-2 more-comments text-small">
|
||||
<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>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -417,23 +415,21 @@
|
|||
</div>
|
||||
|
||||
|
||||
{% if render_replies %}
|
||||
{% if level<7 %}
|
||||
<div id="replies-of-{{c.id}}">
|
||||
{% for reply in replies %}
|
||||
{{single_comment(reply, level=level+1)}}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% elif replies %}
|
||||
<div id="replies-of-{{c.id}}" class="d-none d-md-block">
|
||||
{% for reply in replies %}
|
||||
{{single_comment(reply, level=level+1)}}
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div id="morecomment-{{c.id}}" class="d-block d-md-none mt-2 more-comments text-small">
|
||||
<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>
|
||||
{% endif %}
|
||||
{% if level<7 %}
|
||||
<div id="replies-of-{{c.id}}">
|
||||
{% for reply in replies %}
|
||||
{{single_comment(reply, level=level+1)}}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% elif replies %}
|
||||
<div id="replies-of-{{c.id}}" class="d-none d-md-block">
|
||||
{% for reply in replies %}
|
||||
{{single_comment(reply, level=level+1)}}
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div id="morecomment-{{c.id}}" class="d-block d-md-none mt-2 more-comments text-small">
|
||||
<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>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue