This commit is contained in:
Aevann1 2021-09-17 10:29:05 +02:00
parent 62a5278af4
commit 6cc19ce02a
21 changed files with 194 additions and 194 deletions

View file

@ -103,15 +103,15 @@ def post_id(pid, anything=None, v=None):
if post.club and not (v and v.paid_dues): abort(403)
if v:
votes = g.db.query(CommentVote).filter_by(user_id=v.id).subquery()
votes = g.db.query(CommentVote).options(lazyload('*')).filter_by(user_id=v.id).subquery()
blocking = v.blocking.subquery()
blocked = v.blocked.subquery()
if not (v and v.shadowbanned) and not (v and v.admin_level == 6):
shadowbanned = g.db.query(User.id).filter(User.shadowbanned == True).subquery()
comments = g.db.query(Comment).filter(Comment.author_id.notin_(shadowbanned))
shadowbanned = g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned == True).subquery()
comments = g.db.query(Comment).options(lazyload('*')).filter(Comment.author_id.notin_(shadowbanned))
comments = g.db.query(
Comment,
@ -121,7 +121,7 @@ def post_id(pid, anything=None, v=None):
)
if not (v and v.shadowbanned) and not (v and v.admin_level == 6):
shadowbanned = g.db.query(User.id).filter(User.shadowbanned == True).subquery()
shadowbanned = g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned == True).subquery()
comments = comments.filter(Comment.author_id.notin_(shadowbanned))
if v.admin_level >=4:
@ -170,9 +170,9 @@ def post_id(pid, anything=None, v=None):
post.preloaded_comments = output
else:
shadowbanned = g.db.query(User.id).filter(User.shadowbanned == True).subquery()
shadowbanned = g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned == True).subquery()
comments = g.db.query(Comment).filter(Comment.parent_submission == post.id, Comment.author_id.notin_(shadowbanned))
comments = g.db.query(Comment).options(lazyload('*')).filter(Comment.parent_submission == post.id, Comment.author_id.notin_(shadowbanned))
if sort == "top":
comments = sorted(comments.all(), key=lambda x: x.score, reverse=True)
@ -202,8 +202,8 @@ def post_id(pid, anything=None, v=None):
# g.db.add(vote)
# try: g.db.flush()
# except: g.db.rollback()
# comment.upvotes = g.db.query(CommentVote).filter_by(comment_id=comment.id, vote_type=1).count()
# comment.downvotes = g.db.query(CommentVote).filter_by(comment_id=comment.id, vote_type=-1).count()
# comment.upvotes = g.db.query(CommentVote).options(lazyload('*')).filter_by(comment_id=comment.id, vote_type=1).count()
# comment.downvotes = g.db.query(CommentVote).options(lazyload('*')).filter_by(comment_id=comment.id, vote_type=-1).count()
# g.db.add(comment)
post.preloaded_comments = comments
@ -285,7 +285,7 @@ def edit_post(pid, v):
fragment='')
check_url = urlunparse(check_url)
badlink = g.db.query(BadLink).filter(
badlink = g.db.query(BadLink).options(lazyload('*')).filter(
literal(check_url).contains(
BadLink.link)).first()
if badlink:
@ -379,7 +379,7 @@ def edit_post(pid, v):
soup = BeautifulSoup(body_html, features="html.parser")
for mention in soup.find_all("a", href=re.compile("^/@(\w+)")):
username = mention["href"].split("@")[1]
user = g.db.query(User).filter_by(username=username).first()
user = g.db.query(User).options(lazyload('*')).filter_by(username=username).first()
if user and not v.any_block_exists(user) and user.id != v.id: notify_users.add(user)
for x in notify_users: send_notification(NOTIFICATIONS_ACCOUNT, x, f"@{v.username} has mentioned you: https://{site}{p.permalink}")
@ -622,7 +622,7 @@ def submit_post(v):
url = url.replace(".png", "_d.png").replace(".jpg", "_d.jpg").replace(".jpeg", "_d.jpeg")
if "_d." in url: url += "?maxwidth=9999"
repost = g.db.query(Submission).join(Submission.submission_aux).filter(
repost = g.db.query(Submission).join(Submission.submission_aux).options(lazyload('*')).filter(
SubmissionAux.url.ilike(url),
Submission.deleted_utc == 0,
Submission.is_banned == False
@ -665,7 +665,7 @@ def submit_post(v):
body = request.form.get("body", "")
# check for duplicate
dup = g.db.query(Submission).join(Submission.submission_aux).filter(
dup = g.db.query(Submission).join(Submission.submission_aux).options(lazyload('*')).filter(
Submission.author_id == v.id,
Submission.deleted_utc == 0,
@ -843,7 +843,7 @@ def submit_post(v):
fragment='')
check_url = urlunparse(check_url)
badlink = g.db.query(BadLink).filter(
badlink = g.db.query(BadLink).options(lazyload('*')).filter(
literal(check_url).contains(
BadLink.link)).first()
if badlink:
@ -966,7 +966,7 @@ def submit_post(v):
soup = BeautifulSoup(body_html, features="html.parser")
for mention in soup.find_all("a", href=re.compile("^/@(\w+)")):
username = mention["href"].split("@")[1]
user = g.db.query(User).filter_by(username=username).first()
user = g.db.query(User).options(lazyload('*')).filter_by(username=username).first()
if user and not v.any_block_exists(user) and user.id != v.id: notify_users.add(user)
for x in notify_users: send_notification(NOTIFICATIONS_ACCOUNT, x, f"@{v.username} has mentioned you: https://{site}{new_post.permalink}")
@ -1150,7 +1150,7 @@ def undelete_post_pid(pid, v):
@validate_formkey
def toggle_comment_nsfw(cid, v):
comment = g.db.query(Comment).filter_by(id=cid).first()
comment = g.db.query(Comment).options(lazyload('*')).filter_by(id=cid).first()
if not comment.author_id == v.id and not v.admin_level >= 3: abort(403)
comment.over_18 = not comment.over_18
g.db.add(comment)
@ -1209,7 +1209,7 @@ def unsave_post(pid, v):
post=get_post(pid)
save=g.db.query(SaveRelationship).filter_by(user_id=v.id, submission_id=post.id, type=1).first()
save=g.db.query(SaveRelationship).options(lazyload('*')).filter_by(user_id=v.id, submission_id=post.id, type=1).first()
if save: g.db.delete(save)