forked from rDrama/rDrama
parent
cff34fb3a4
commit
a1b137447e
|
@ -27,7 +27,7 @@ services:
|
||||||
|
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:12.3
|
image: postgres:12.3
|
||||||
command: ["postgres", "-c", "log_statement=all"]
|
# command: ["postgres", "-c", "log_statement=all"]
|
||||||
# uncomment this if u wanna output all SQL queries to the console
|
# uncomment this if u wanna output all SQL queries to the console
|
||||||
volumes:
|
volumes:
|
||||||
- "./schema.sql:/docker-entrypoint-initdb.d/00-schema.sql"
|
- "./schema.sql:/docker-entrypoint-initdb.d/00-schema.sql"
|
||||||
|
|
|
@ -107,6 +107,13 @@ class Comment(Base):
|
||||||
flags.remove(flag)
|
flags.remove(flag)
|
||||||
return flags
|
return flags
|
||||||
|
|
||||||
|
@lazy
|
||||||
|
def poll_voted(self, v):
|
||||||
|
if v:
|
||||||
|
vote = g.db.query(CommentVote.vote_type).filter_by(user_id=v.id, comment_id=self.id).one_or_none()
|
||||||
|
if vote: return vote[0]
|
||||||
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@lazy
|
@lazy
|
||||||
def options(self):
|
def options(self):
|
||||||
|
@ -121,13 +128,13 @@ class Comment(Base):
|
||||||
def total_poll_voted(self, v):
|
def total_poll_voted(self, v):
|
||||||
if v:
|
if v:
|
||||||
for option in self.options:
|
for option in self.options:
|
||||||
if option.voted: return True
|
if option.poll_voted(v): return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@lazy
|
@lazy
|
||||||
def total_choice_voted(self, v):
|
def total_choice_voted(self, v):
|
||||||
if v:
|
if v:
|
||||||
return g.db.query(CommentVote).filter(CommentVote.user_id == v.id, CommentVote.comment_id.in_([x.id for x in self.choices])).count()
|
return g.db.query(CommentVote).filter(CommentVote.user_id == v.id, CommentVote.comment_id.in_([x.id for x in self.choices])).all()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -240,7 +247,7 @@ class Comment(Base):
|
||||||
if not self.parent_submission:
|
if not self.parent_submission:
|
||||||
return [x for x in self.child_comments.order_by(Comment.id) if not x.author.shadowbanned]
|
return [x for x in self.child_comments.order_by(Comment.id) if not x.author.shadowbanned]
|
||||||
|
|
||||||
comments = self.child_comments.filter(Comment.author_id.notin_(poll_bots))
|
comments = self.child_comments.filter(Comment.author_id.notin_((AUTOPOLLER_ID, AUTOBETTER_ID, AUTOCHOICE_ID)))
|
||||||
comments = sort_comments(sort, comments)
|
comments = sort_comments(sort, comments)
|
||||||
return [x for x in comments if not x.author.shadowbanned]
|
return [x for x in comments if not x.author.shadowbanned]
|
||||||
|
|
||||||
|
@ -251,7 +258,7 @@ class Comment(Base):
|
||||||
if not self.parent_submission:
|
if not self.parent_submission:
|
||||||
return self.child_comments.order_by(Comment.id).all()
|
return self.child_comments.order_by(Comment.id).all()
|
||||||
|
|
||||||
comments = self.child_comments.filter(Comment.author_id.notin_(poll_bots))
|
comments = self.child_comments.filter(Comment.author_id.notin_((AUTOPOLLER_ID, AUTOBETTER_ID, AUTOCHOICE_ID)))
|
||||||
return sort_comments(sort, comments).all()
|
return sort_comments(sort, comments).all()
|
||||||
|
|
||||||
|
|
||||||
|
@ -407,7 +414,7 @@ class Comment(Base):
|
||||||
|
|
||||||
for c in self.options:
|
for c in self.options:
|
||||||
body += f'<div class="custom-control"><input type="checkbox" class="custom-control-input" id="{c.id}" name="option"'
|
body += f'<div class="custom-control"><input type="checkbox" class="custom-control-input" id="{c.id}" name="option"'
|
||||||
if c.voted: body += " checked"
|
if c.poll_voted(v): body += " checked"
|
||||||
if v: body += f''' onchange="poll_vote('{c.id}', '{self.id}')"'''
|
if v: body += f''' onchange="poll_vote('{c.id}', '{self.id}')"'''
|
||||||
else: body += f''' onchange="poll_vote_no_v('{c.id}', '{self.id}')"'''
|
else: body += f''' onchange="poll_vote_no_v('{c.id}', '{self.id}')"'''
|
||||||
body += f'''><label class="custom-control-label" for="{c.id}">{c.body_html}<span class="presult-{self.id}'''
|
body += f'''><label class="custom-control-label" for="{c.id}">{c.body_html}<span class="presult-{self.id}'''
|
||||||
|
@ -422,7 +429,7 @@ class Comment(Base):
|
||||||
|
|
||||||
for c in self.choices:
|
for c in self.choices:
|
||||||
body += f'''<div class="custom-control"><input name="choice-{self.id}" autocomplete="off" class="custom-control-input" type="radio" id="{c.id}" onchange="choice_vote('{c.id}','{self.id}')"'''
|
body += f'''<div class="custom-control"><input name="choice-{self.id}" autocomplete="off" class="custom-control-input" type="radio" id="{c.id}" onchange="choice_vote('{c.id}','{self.id}')"'''
|
||||||
if c.voted: body += " checked "
|
if c.poll_voted(v): body += " checked "
|
||||||
body += f'''><label class="custom-control-label" for="{c.id}">{c.body_html}<span class="presult-{self.id}'''
|
body += f'''><label class="custom-control-label" for="{c.id}">{c.body_html}<span class="presult-{self.id}'''
|
||||||
if not self.total_choice_voted(v): body += ' d-none'
|
if not self.total_choice_voted(v): body += ' d-none'
|
||||||
body += f'"> - <a href="/votes?link=t3_{c.id}"><span id="choice-{c.id}">{c.upvotes}</span> votes</a></span></label></div>'
|
body += f'"> - <a href="/votes?link=t3_{c.id}"><span id="choice-{c.id}">{c.upvotes}</span> votes</a></span></label></div>'
|
||||||
|
|
|
@ -122,13 +122,13 @@ class Submission(Base):
|
||||||
def total_poll_voted(self, v):
|
def total_poll_voted(self, v):
|
||||||
if v:
|
if v:
|
||||||
for option in self.options:
|
for option in self.options:
|
||||||
if option.voted: return True
|
if option.poll_voted(v): return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@lazy
|
@lazy
|
||||||
def total_choice_voted(self, v):
|
def total_choice_voted(self, v):
|
||||||
if v and self.choices:
|
if v and self.choices:
|
||||||
return g.db.query(CommentVote).filter(CommentVote.user_id == v.id, CommentVote.comment_id.in_([x.id for x in self.choices])).count()
|
return g.db.query(CommentVote).filter(CommentVote.user_id == v.id, CommentVote.comment_id.in_([x.id for x in self.choices])).all()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@lazy
|
@lazy
|
||||||
|
@ -136,7 +136,7 @@ class Submission(Base):
|
||||||
if "closed" in self.body.lower(): return True
|
if "closed" in self.body.lower(): return True
|
||||||
if v:
|
if v:
|
||||||
for option in self.bet_options:
|
for option in self.bet_options:
|
||||||
if option.voted: return True
|
if option.poll_voted(v): return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -387,7 +387,7 @@ class Submission(Base):
|
||||||
return url
|
return url
|
||||||
|
|
||||||
@lazy
|
@lazy
|
||||||
def realbody(self, v, show_polls=False):
|
def realbody(self, v):
|
||||||
if self.club and not (v and (v.paid_dues or v.id == self.author_id)): return f"<p>{CC} ONLY</p>"
|
if self.club and not (v and (v.paid_dues or v.id == self.author_id)): return f"<p>{CC} ONLY</p>"
|
||||||
|
|
||||||
body = self.body_html or ""
|
body = self.body_html or ""
|
||||||
|
@ -407,43 +407,43 @@ class Submission(Base):
|
||||||
self.upvotes += amount
|
self.upvotes += amount
|
||||||
g.db.add(self)
|
g.db.add(self)
|
||||||
|
|
||||||
if show_polls:
|
for c in self.options:
|
||||||
for c in self.options:
|
body += f'<div class="custom-control"><input type="checkbox" class="custom-control-input" id="{c.id}" name="option"'
|
||||||
body += f'<div class="custom-control"><input type="checkbox" class="custom-control-input" id="{c.id}" name="option"'
|
if c.poll_voted(v): body += " checked"
|
||||||
if c.voted: body += " checked"
|
if v: body += f''' onchange="poll_vote('{c.id}', '{self.id}')"'''
|
||||||
if v: body += f''' onchange="poll_vote('{c.id}', '{self.id}')"'''
|
else: body += f''' onchange="poll_vote_no_v('{c.id}', '{self.id}')"'''
|
||||||
else: body += f''' onchange="poll_vote_no_v('{c.id}', '{self.id}')"'''
|
body += f'''><label class="custom-control-label" for="{c.id}">{c.body_html}<span class="presult-{self.id}'''
|
||||||
body += f'''><label class="custom-control-label" for="{c.id}">{c.body_html}<span class="presult-{self.id}'''
|
if not self.total_poll_voted(v): body += ' d-none'
|
||||||
if not self.total_poll_voted(v): body += ' d-none'
|
body += f'"> - <a href="/votes?link=t3_{c.id}"><span id="poll-{c.id}">{c.upvotes}</span> votes</a></span></label></div>'
|
||||||
body += f'"> - <a href="/votes?link=t3_{c.id}"><span id="poll-{c.id}">{c.upvotes}</span> votes</a></span></label></div>'
|
|
||||||
|
|
||||||
if self.choices:
|
if self.choices:
|
||||||
curr = self.total_choice_voted(v)
|
curr = self.total_choice_voted(v)
|
||||||
if curr: curr = " value=" + str(curr[0].comment_id)
|
if curr: curr = " value=" + str(curr[0].comment_id)
|
||||||
else: curr = ''
|
else: curr = ''
|
||||||
body += f'<input class="d-none" id="current-{self.id}"{curr}>'
|
body += f'<input class="d-none" id="current-{self.id}"{curr}>'
|
||||||
|
|
||||||
for c in self.choices:
|
for c in self.choices:
|
||||||
body += f'''<div class="custom-control"><input name="choice-{self.id}" autocomplete="off" class="custom-control-input" type="radio" id="{c.id}" onchange="choice_vote('{c.id}','{self.id}')"'''
|
body += f'''<div class="custom-control"><input name="choice-{self.id}" autocomplete="off" class="custom-control-input" type="radio" id="{c.id}" onchange="choice_vote('{c.id}','{self.id}')"'''
|
||||||
if c.voted: body += " checked "
|
if c.poll_voted(v): body += " checked "
|
||||||
body += f'''><label class="custom-control-label" for="{c.id}">{c.body_html}<span class="presult-{self.id}'''
|
body += f'''><label class="custom-control-label" for="{c.id}">{c.body_html}<span class="presult-{self.id}'''
|
||||||
if not self.total_choice_voted(v): body += ' d-none'
|
if not self.total_choice_voted(v): body += ' d-none'
|
||||||
body += f'"> - <a href="/votes?link=t3_{c.id}"><span id="choice-{c.id}">{c.upvotes}</span> votes</a></span></label></div>'
|
body += f'"> - <a href="/votes?link=t3_{c.id}"><span id="choice-{c.id}">{c.upvotes}</span> votes</a></span></label></div>'
|
||||||
|
|
||||||
for c in self.bet_options:
|
for c in self.bet_options:
|
||||||
body += f'''<div class="custom-control mt-3"><input autocomplete="off" class="custom-control-input bet" type="radio" id="{c.id}" onchange="bet_vote('{c.id}')"'''
|
body += f'''<div class="custom-control mt-3"><input autocomplete="off" class="custom-control-input bet" type="radio" id="{c.id}" onchange="bet_vote('{c.id}')"'''
|
||||||
if c.voted: body += " checked "
|
if c.poll_voted(v): body += " checked "
|
||||||
if not (v and v.coins > 200) or self.total_bet_voted(v) or not v.can_gamble: body += " disabled "
|
if not (v and v.coins > 200) or self.total_bet_voted(v) or not v.can_gamble: body += " disabled "
|
||||||
body += f'''><label class="custom-control-label" for="{c.id}">{c.body_html} - <a href="/votes?link=t3_{c.id}"><span id="bet-{c.id}">{c.upvotes}</span> bets</a>'''
|
body += f'''><label class="custom-control-label" for="{c.id}">{c.body_html} - <a href="/votes?link=t3_{c.id}"><span id="bet-{c.id}">{c.upvotes}</span> bets</a>'''
|
||||||
if not self.total_bet_voted(v):
|
if not self.total_bet_voted(v):
|
||||||
body += '''<span class="cost"> (cost of entry: 200 coins)</span>'''
|
body += '''<span class="cost"> (cost of entry: 200 coins)</span>'''
|
||||||
body += "</label>"
|
body += "</label>"
|
||||||
if v and v.admin_level > 2:
|
if v and v.admin_level > 2:
|
||||||
body += f'''<button class="btn btn-primary px-2 mx-2" style="font-size:10px;padding:2px" onclick="post_toast(this,'/distribute/{c.id}')">Declare winner</button>'''
|
body += f'''<button class="btn btn-primary px-2 mx-2" style="font-size:10px;padding:2px" onclick="post_toast(this,'/distribute/{c.id}')">Declare winner</button>'''
|
||||||
body += "</div>"
|
body += "</div>"
|
||||||
|
|
||||||
if self.author.sig_html and (self.author_id == MOOSE_ID or (not self.ghost and not (v and v.sigs_disabled))):
|
|
||||||
body += f"<hr>{self.author.sig_html}"
|
if self.author.sig_html and (self.author_id == MOOSE_ID or (not self.ghost and not (v and v.sigs_disabled))):
|
||||||
|
body += f"<hr>{self.author.sig_html}"
|
||||||
|
|
||||||
return body
|
return body
|
||||||
|
|
||||||
|
|
|
@ -480,7 +480,6 @@ class User(Base):
|
||||||
@property
|
@property
|
||||||
@lazy
|
@lazy
|
||||||
def modaction_notifications_count(self):
|
def modaction_notifications_count(self):
|
||||||
if not self.admin_level: return 0
|
|
||||||
return g.db.query(Notification).join(Comment).filter(
|
return g.db.query(Notification).join(Comment).filter(
|
||||||
Notification.user_id == self.id, Notification.read == False,
|
Notification.user_id == self.id, Notification.read == False,
|
||||||
Comment.is_banned == False, Comment.deleted_utc == 0,
|
Comment.is_banned == False, Comment.deleted_utc == 0,
|
||||||
|
@ -490,7 +489,6 @@ class User(Base):
|
||||||
@property
|
@property
|
||||||
@lazy
|
@lazy
|
||||||
def reddit_notifications_count(self):
|
def reddit_notifications_count(self):
|
||||||
if not self.can_view_offsitementions: return 0
|
|
||||||
return g.db.query(Notification).join(Comment).filter(
|
return g.db.query(Notification).join(Comment).filter(
|
||||||
Notification.user_id == self.id, Notification.read == False,
|
Notification.user_id == self.id, Notification.read == False,
|
||||||
Comment.is_banned == False, Comment.deleted_utc == 0,
|
Comment.is_banned == False, Comment.deleted_utc == 0,
|
||||||
|
@ -705,9 +703,6 @@ class User(Base):
|
||||||
def saved_idlist(self, page=1):
|
def saved_idlist(self, page=1):
|
||||||
|
|
||||||
saved = [x[0] for x in g.db.query(SaveRelationship.submission_id).filter_by(user_id=self.id).all()]
|
saved = [x[0] for x in g.db.query(SaveRelationship.submission_id).filter_by(user_id=self.id).all()]
|
||||||
|
|
||||||
if not saved: return []
|
|
||||||
|
|
||||||
posts = g.db.query(Submission.id).filter(Submission.id.in_(saved), Submission.is_banned == False, Submission.deleted_utc == 0)
|
posts = g.db.query(Submission.id).filter(Submission.id.in_(saved), Submission.is_banned == False, Submission.deleted_utc == 0)
|
||||||
|
|
||||||
if self.admin_level < 2:
|
if self.admin_level < 2:
|
||||||
|
@ -719,9 +714,6 @@ class User(Base):
|
||||||
def saved_comment_idlist(self, page=1):
|
def saved_comment_idlist(self, page=1):
|
||||||
|
|
||||||
saved = [x[0] for x in g.db.query(CommentSaveRelationship.comment_id).filter_by(user_id=self.id).all()]
|
saved = [x[0] for x in g.db.query(CommentSaveRelationship.comment_id).filter_by(user_id=self.id).all()]
|
||||||
|
|
||||||
if not saved: return []
|
|
||||||
|
|
||||||
comments = g.db.query(Comment.id).filter(Comment.id.in_(saved), Comment.is_banned == False, Comment.deleted_utc == 0)
|
comments = g.db.query(Comment.id).filter(Comment.id.in_(saved), Comment.is_banned == False, Comment.deleted_utc == 0)
|
||||||
|
|
||||||
if self.admin_level < 2:
|
if self.admin_level < 2:
|
||||||
|
|
|
@ -120,8 +120,8 @@ def get_post(i, v=None, graceful=False):
|
||||||
else: abort(404)
|
else: abort(404)
|
||||||
|
|
||||||
if v:
|
if v:
|
||||||
vt = g.db.query(Vote.vote_type, Vote.submission_id).filter_by(user_id=v.id, submission_id=i).subquery()
|
vt = g.db.query(Vote).filter_by(
|
||||||
|
user_id=v.id, submission_id=i).subquery()
|
||||||
blocking = v.blocking.subquery()
|
blocking = v.blocking.subquery()
|
||||||
|
|
||||||
post = g.db.query(
|
post = g.db.query(
|
||||||
|
@ -166,7 +166,7 @@ def get_posts(pids, v=None):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
if v:
|
if v:
|
||||||
vt = g.db.query(Vote.vote_type, Vote.submission_id).filter(
|
vt = g.db.query(Vote).filter(
|
||||||
Vote.submission_id.in_(pids),
|
Vote.submission_id.in_(pids),
|
||||||
Vote.user_id==v.id
|
Vote.user_id==v.id
|
||||||
).subquery()
|
).subquery()
|
||||||
|
@ -228,7 +228,8 @@ def get_comment(i, v=None, graceful=False):
|
||||||
)
|
)
|
||||||
).first()
|
).first()
|
||||||
|
|
||||||
vt = g.db.query(CommentVote.vote_type).filter_by(user_id=v.id, comment_id=comment.id).one_or_none()
|
vts = g.db.query(CommentVote).filter_by(user_id=v.id, comment_id=comment.id)
|
||||||
|
vt = g.db.query(CommentVote).filter_by(user_id=v.id, comment_id=comment.id).one_or_none()
|
||||||
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
|
||||||
|
@ -241,7 +242,7 @@ def get_comments(cids, v=None, load_parent=False):
|
||||||
if not cids: return []
|
if not cids: return []
|
||||||
|
|
||||||
if v:
|
if v:
|
||||||
votes = g.db.query(CommentVote.vote_type, CommentVote.comment_id).filter_by(user_id=v.id).subquery()
|
votes = g.db.query(CommentVote).filter_by(user_id=v.id).subquery()
|
||||||
|
|
||||||
blocking = v.blocking.subquery()
|
blocking = v.blocking.subquery()
|
||||||
|
|
||||||
|
|
|
@ -117,7 +117,7 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None, sub=None):
|
||||||
sort=request.values.get("sort", defaultsortingcomments)
|
sort=request.values.get("sort", defaultsortingcomments)
|
||||||
|
|
||||||
if v:
|
if v:
|
||||||
votes = g.db.query(CommentVote.vote_type, CommentVote.comment_id).filter_by(user_id=v.id).subquery()
|
votes = g.db.query(CommentVote).filter_by(user_id=v.id).subquery()
|
||||||
|
|
||||||
blocking = v.blocking.subquery()
|
blocking = v.blocking.subquery()
|
||||||
|
|
||||||
|
@ -134,7 +134,8 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None, sub=None):
|
||||||
comments = comments.join(User, User.id == Comment.author_id).filter(User.shadowbanned == None)
|
comments = comments.join(User, User.id == Comment.author_id).filter(User.shadowbanned == None)
|
||||||
|
|
||||||
comments=comments.filter(
|
comments=comments.filter(
|
||||||
Comment.top_comment_id == c.top_comment_id
|
Comment.parent_submission == post.id,
|
||||||
|
Comment.author_id.notin_((AUTOPOLLER_ID, AUTOBETTER_ID, AUTOCHOICE_ID))
|
||||||
).join(
|
).join(
|
||||||
votes,
|
votes,
|
||||||
votes.c.comment_id == Comment.id,
|
votes.c.comment_id == Comment.id,
|
||||||
|
|
|
@ -147,7 +147,7 @@ def post_id(pid, anything=None, v=None, sub=None):
|
||||||
if post.club and not (v and (v.paid_dues or v.id == post.author_id)): abort(403)
|
if post.club and not (v and (v.paid_dues or v.id == post.author_id)): abort(403)
|
||||||
|
|
||||||
if v:
|
if v:
|
||||||
votes = g.db.query(CommentVote.vote_type, CommentVote.comment_id).filter_by(user_id=v.id).subquery()
|
votes = g.db.query(CommentVote).filter_by(user_id=v.id).subquery()
|
||||||
|
|
||||||
blocking = v.blocking.subquery()
|
blocking = v.blocking.subquery()
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@ def post_id(pid, anything=None, v=None, sub=None):
|
||||||
if not (v and v.shadowbanned) and not (v and v.admin_level >= 2):
|
if not (v and v.shadowbanned) and not (v and v.admin_level >= 2):
|
||||||
comments = comments.join(User, User.id == Comment.author_id).filter(User.shadowbanned == None)
|
comments = comments.join(User, User.id == Comment.author_id).filter(User.shadowbanned == None)
|
||||||
|
|
||||||
comments=comments.filter(Comment.parent_submission == post.id).join(
|
comments=comments.filter(Comment.parent_submission == post.id, Comment.author_id.notin_((AUTOPOLLER_ID, AUTOBETTER_ID, AUTOCHOICE_ID))).join(
|
||||||
votes,
|
votes,
|
||||||
votes.c.comment_id == Comment.id,
|
votes.c.comment_id == Comment.id,
|
||||||
isouter=True
|
isouter=True
|
||||||
|
@ -187,7 +187,7 @@ def post_id(pid, anything=None, v=None, sub=None):
|
||||||
|
|
||||||
pinned = [c[0] for c in comments.filter(Comment.stickied != None).all()]
|
pinned = [c[0] for c in comments.filter(Comment.stickied != None).all()]
|
||||||
|
|
||||||
comments = comments.filter(Comment.level == 1, Comment.stickied == None, Comment.author_id.notin_(poll_bots))
|
comments = comments.filter(Comment.level == 1, Comment.stickied == None)
|
||||||
|
|
||||||
comments = sort_comments(sort, comments)
|
comments = sort_comments(sort, comments)
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ def post_id(pid, anything=None, v=None, sub=None):
|
||||||
else:
|
else:
|
||||||
pinned = g.db.query(Comment).filter(Comment.parent_submission == post.id, Comment.stickied != None).all()
|
pinned = g.db.query(Comment).filter(Comment.parent_submission == post.id, Comment.stickied != None).all()
|
||||||
|
|
||||||
comments = g.db.query(Comment).join(User, User.id == Comment.author_id).filter(User.shadowbanned == None, Comment.parent_submission == post.id, Comment.author_id.notin_(poll_bots), Comment.level == 1, Comment.stickied == None)
|
comments = g.db.query(Comment).join(User, User.id == Comment.author_id).filter(User.shadowbanned == None, Comment.parent_submission == post.id, Comment.author_id.notin_((AUTOPOLLER_ID, AUTOBETTER_ID, AUTOCHOICE_ID)), Comment.level == 1, Comment.stickied == None)
|
||||||
|
|
||||||
comments = sort_comments(sort, comments)
|
comments = sort_comments(sort, comments)
|
||||||
|
|
||||||
|
@ -259,7 +259,7 @@ def viewmore(v, pid, sort, offset):
|
||||||
except: abort(400)
|
except: abort(400)
|
||||||
|
|
||||||
if v:
|
if v:
|
||||||
votes = g.db.query(CommentVote.vote_type, CommentVote.comment_id).filter_by(user_id=v.id).subquery()
|
votes = g.db.query(CommentVote).filter_by(user_id=v.id).subquery()
|
||||||
|
|
||||||
blocking = v.blocking.subquery()
|
blocking = v.blocking.subquery()
|
||||||
|
|
||||||
|
@ -270,7 +270,7 @@ def viewmore(v, pid, sort, offset):
|
||||||
votes.c.vote_type,
|
votes.c.vote_type,
|
||||||
blocking.c.target_id,
|
blocking.c.target_id,
|
||||||
blocked.c.target_id,
|
blocked.c.target_id,
|
||||||
).filter(Comment.parent_submission == pid, Comment.stickied == None, Comment.id.notin_(ids))
|
).filter(Comment.parent_submission == pid, Comment.author_id.notin_((AUTOPOLLER_ID, AUTOBETTER_ID, AUTOCHOICE_ID)), Comment.stickied == None, Comment.id.notin_(ids))
|
||||||
|
|
||||||
if not (v and v.shadowbanned) and not (v and v.admin_level >= 2):
|
if not (v and v.shadowbanned) and not (v and v.admin_level >= 2):
|
||||||
comments = comments.join(User, User.id == Comment.author_id).filter(User.shadowbanned == None)
|
comments = comments.join(User, User.id == Comment.author_id).filter(User.shadowbanned == None)
|
||||||
|
@ -297,7 +297,7 @@ def viewmore(v, pid, sort, offset):
|
||||||
comment.is_blocked = c[3] or 0
|
comment.is_blocked = c[3] or 0
|
||||||
output.append(comment)
|
output.append(comment)
|
||||||
|
|
||||||
comments = comments.filter(Comment.level == 1, Comment.author_id.notin_(poll_bots))
|
comments = comments.filter(Comment.level == 1)
|
||||||
|
|
||||||
comments = sort_comments(sort, comments)
|
comments = sort_comments(sort, comments)
|
||||||
|
|
||||||
|
@ -305,7 +305,7 @@ def viewmore(v, pid, sort, offset):
|
||||||
second = [c[0] for c in comments.filter(or_(Comment.slots_result != None, Comment.blackjack_result != None, Comment.wordle_result != None), func.length(Comment.body_html) <= 100).all()]
|
second = [c[0] for c in comments.filter(or_(Comment.slots_result != None, Comment.blackjack_result != None, Comment.wordle_result != None), func.length(Comment.body_html) <= 100).all()]
|
||||||
comments = first + second
|
comments = first + second
|
||||||
else:
|
else:
|
||||||
comments = g.db.query(Comment).join(User, User.id == Comment.author_id).filter(User.shadowbanned == None, Comment.parent_submission == pid, Comment.author_id.notin_(poll_bots), Comment.level == 1, Comment.stickied == None, Comment.id.notin_(ids))
|
comments = g.db.query(Comment).join(User, User.id == Comment.author_id).filter(User.shadowbanned == None, Comment.parent_submission == pid, Comment.author_id.notin_((AUTOPOLLER_ID, AUTOBETTER_ID, AUTOCHOICE_ID)), Comment.level == 1, Comment.stickied == None, Comment.id.notin_(ids))
|
||||||
|
|
||||||
comments = sort_comments(sort, comments)
|
comments = sort_comments(sort, comments)
|
||||||
|
|
||||||
|
@ -346,7 +346,7 @@ def morecomments(v, cid):
|
||||||
tcid = g.db.query(Comment.top_comment_id).filter_by(id=cid).one_or_none()[0]
|
tcid = g.db.query(Comment.top_comment_id).filter_by(id=cid).one_or_none()[0]
|
||||||
|
|
||||||
if v:
|
if v:
|
||||||
votes = g.db.query(CommentVote.vote_type, CommentVote.comment_id).filter_by(user_id=v.id).subquery()
|
votes = g.db.query(CommentVote).filter_by(user_id=v.id).subquery()
|
||||||
|
|
||||||
blocking = v.blocking.subquery()
|
blocking = v.blocking.subquery()
|
||||||
|
|
||||||
|
|
|
@ -877,7 +877,7 @@
|
||||||
lastCount = comments['{{p.id}}']
|
lastCount = comments['{{p.id}}']
|
||||||
if (lastCount)
|
if (lastCount)
|
||||||
{
|
{
|
||||||
{% for c in p.replies %}
|
{% for c in p.comments %}
|
||||||
{% if not (v and v.id==c.author_id) and not c.voted %}
|
{% if not (v and v.id==c.author_id) and not c.voted %}
|
||||||
if ({{c.created_utc*1000}} > lastCount.t)
|
if ({{c.created_utc*1000}} > lastCount.t)
|
||||||
try {document.getElementById("comment-{{c.id}}-only").classList.add('unread')}
|
try {document.getElementById("comment-{{c.id}}-only").classList.add('unread')}
|
||||||
|
@ -908,7 +908,7 @@
|
||||||
lastCount = comments['{{p.id}}']
|
lastCount = comments['{{p.id}}']
|
||||||
if (lastCount)
|
if (lastCount)
|
||||||
{
|
{
|
||||||
{% for c in p.replies %}
|
{% for c in p.comments %}
|
||||||
{% if not (v and v.id==c.author_id) and not c.voted %}
|
{% if not (v and v.id==c.author_id) and not c.voted %}
|
||||||
if ({{c.created_utc*1000}} > lastCount.t)
|
if ({{c.created_utc*1000}} > lastCount.t)
|
||||||
try {document.getElementById("comment-{{c.id}}-only").classList.add('unread')}
|
try {document.getElementById("comment-{{c.id}}-only").classList.add('unread')}
|
||||||
|
|
|
@ -733,6 +733,10 @@
|
||||||
{% if p.private %}<span class="badge border-warning border-1 text-small-extra">Draft</span>{% endif %}
|
{% if p.private %}<span class="badge border-warning border-1 text-small-extra">Draft</span>{% endif %}
|
||||||
{% if p.active_flags(v) %}<a class="btn btn-primary" role="button" style="padding:1px 5px; font-size:10px"onclick="document.getElementById('flaggers').classList.toggle('d-none')">{{p.active_flags(v)}} Report{{ help.plural(p.active_flags(v)) }}</a>{% endif %}
|
{% if p.active_flags(v) %}<a class="btn btn-primary" role="button" style="padding:1px 5px; font-size:10px"onclick="document.getElementById('flaggers').classList.toggle('d-none')">{{p.active_flags(v)}} Report{{ help.plural(p.active_flags(v)) }}</a>{% endif %}
|
||||||
|
|
||||||
|
{% if not p.author %}
|
||||||
|
{{p.print()}}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if p.ghost %}
|
{% if p.ghost %}
|
||||||
<span {% if p.distinguish_level %}class="mod"{% endif %}>👻</span>
|
<span {% if p.distinguish_level %}class="mod"{% endif %}>👻</span>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
@ -791,7 +795,7 @@
|
||||||
{% if p.realurl(v) %}
|
{% if p.realurl(v) %}
|
||||||
{% if not p.embed_url and not p.is_image and not p.is_video and not p.is_audio %}
|
{% if not p.embed_url and not p.is_image and not p.is_video and not p.is_audio %}
|
||||||
<a rel="nofollow noopener noreferrer" href="{{p.realurl(v)}}" {% if not v or v.newtabexternal %}target="_blank"{% endif %}>
|
<a rel="nofollow noopener noreferrer" href="{{p.realurl(v)}}" {% if not v or v.newtabexternal %}target="_blank"{% endif %}>
|
||||||
<div class="d-flex d-md-none justify-content-between align-items-center border rounded p-2{% if p.realbody(v, show_pols=True) %} mb-3{% endif %}">
|
<div class="d-flex d-md-none justify-content-between align-items-center border rounded p-2{% if p.realbody(v) %} mb-3{% endif %}">
|
||||||
<span>{{p.domain|truncate(30, True)}}</span>
|
<span>{{p.domain|truncate(30, True)}}</span>
|
||||||
<i class="fas fa-external-link-alt text-small"></i>
|
<i class="fas fa-external-link-alt text-small"></i>
|
||||||
</div>
|
</div>
|
||||||
|
@ -841,7 +845,7 @@
|
||||||
</div>
|
</div>
|
||||||
<pre></pre>
|
<pre></pre>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{{p.realbody(v, show_polls=True) | safe}}
|
{{p.realbody(v) | safe}}
|
||||||
|
|
||||||
{% if p.is_banned and p.ban_reason %}
|
{% if p.is_banned and p.ban_reason %}
|
||||||
<div class="text-removed mb-0">removed by @{{p.ban_reason}}</div>
|
<div class="text-removed mb-0">removed by @{{p.ban_reason}}</div>
|
||||||
|
@ -1123,7 +1127,7 @@
|
||||||
lastCount = comments['{{p.id}}']
|
lastCount = comments['{{p.id}}']
|
||||||
if (lastCount)
|
if (lastCount)
|
||||||
{
|
{
|
||||||
{% for c in p.replies %}
|
{% for c in p.comments %}
|
||||||
{% if not (v and v.id==c.author_id) and not c.voted %}
|
{% if not (v and v.id==c.author_id) and not c.voted %}
|
||||||
if ({{c.created_utc*1000}} > lastCount.t)
|
if ({{c.created_utc*1000}} > lastCount.t)
|
||||||
try {document.getElementById("comment-{{c.id}}-only").classList.add('unread')}
|
try {document.getElementById("comment-{{c.id}}-only").classList.add('unread')}
|
||||||
|
|
|
@ -94,7 +94,7 @@
|
||||||
lastCount = comments['{{p.id}}']
|
lastCount = comments['{{p.id}}']
|
||||||
if (lastCount)
|
if (lastCount)
|
||||||
{
|
{
|
||||||
{% for c in p.replies %}
|
{% for c in p.comments %}
|
||||||
{% if not (v and v.id==c.author_id) and not c.voted %}
|
{% if not (v and v.id==c.author_id) and not c.voted %}
|
||||||
if ({{c.created_utc*1000}} > lastCount.t)
|
if ({{c.created_utc*1000}} > lastCount.t)
|
||||||
try {document.getElementById("comment-{{c.id}}-only").classList.add('unread')}
|
try {document.getElementById("comment-{{c.id}}-only").classList.add('unread')}
|
||||||
|
|
Loading…
Reference in New Issue