SQLA migration: fix RemovedIn20Warning
s
This commit is contained in:
parent
449e2557d0
commit
ff09ba4209
4 changed files with 11 additions and 15 deletions
|
@ -194,12 +194,9 @@ class Comment(Base):
|
|||
@property
|
||||
@lazy
|
||||
def parent(self):
|
||||
|
||||
if not self.parent_submission: return None
|
||||
|
||||
if self.level == 1: return self.post
|
||||
|
||||
else: return g.db.query(Comment).get(self.parent_comment_id)
|
||||
else: return g.db.get(Comment, self.parent_comment_id)
|
||||
|
||||
@property
|
||||
@lazy
|
||||
|
|
|
@ -141,13 +141,13 @@ def bulk_recompute_descendant_counts(predicate = None, db=None):
|
|||
True
|
||||
)
|
||||
.group_by(parent_comments.corresponding_column(Comment.id))
|
||||
.with_only_columns([
|
||||
.with_only_columns(
|
||||
parent_comments.corresponding_column(Comment.id),
|
||||
func.coalesce(
|
||||
func.sum(child_comments.corresponding_column(Comment.descendant_count) + text(str(1))),
|
||||
text(str(0))
|
||||
).label('descendant_count')
|
||||
])
|
||||
)
|
||||
.subquery(name='descendant_counts')
|
||||
),
|
||||
adapt_on_names=True
|
||||
|
|
|
@ -25,7 +25,7 @@ def get_logged_in_user():
|
|||
lo_user = session.get("lo_user")
|
||||
if lo_user:
|
||||
id = int(lo_user)
|
||||
v = g.db.query(User).get(id)
|
||||
v = g.db.get(User, id)
|
||||
if v:
|
||||
v.client = None
|
||||
nonce = session.get("login_nonce", 0)
|
||||
|
|
|
@ -273,12 +273,12 @@ def update_filter_status(v):
|
|||
return { 'result': f'Status of {new_status} is not permitted' }
|
||||
|
||||
if post_id:
|
||||
p = g.db.query(Submission).get(post_id)
|
||||
p = g.db.get(Submission, post_id)
|
||||
old_status = p.filter_state
|
||||
rows_updated = g.db.query(Submission).where(Submission.id == post_id) \
|
||||
.update({Submission.filter_state: new_status})
|
||||
elif comment_id:
|
||||
c = g.db.query(Comment).get(comment_id)
|
||||
c = g.db.get(Comment, comment_id)
|
||||
old_status = c.filter_state
|
||||
rows_updated = g.db.query(Comment).where(Comment.id == comment_id) \
|
||||
.update({Comment.filter_state: new_status})
|
||||
|
@ -732,13 +732,12 @@ def alt_votes_get(v):
|
|||
@limiter.exempt
|
||||
@admin_level_required(2)
|
||||
def admin_link_accounts(v):
|
||||
|
||||
u1 = int(request.values.get("u1"))
|
||||
u2 = int(request.values.get("u2"))
|
||||
u1 = get_account(request.values.get("u1", ''))
|
||||
u2 = get_account(request.values.get("u2", ''))
|
||||
|
||||
new_alt = Alt(
|
||||
user1=u1,
|
||||
user2=u2,
|
||||
user1=u1.id,
|
||||
user2=u2.id,
|
||||
is_manual=True
|
||||
)
|
||||
|
||||
|
@ -753,7 +752,7 @@ def admin_link_accounts(v):
|
|||
g.db.add(ma)
|
||||
|
||||
g.db.commit()
|
||||
return redirect(f"/admin/alt_votes?u1={g.db.query(User).get(u1).username}&u2={g.db.query(User).get(u2).username}")
|
||||
return redirect(f"/admin/alt_votes?u1={u1.id}&u2={u2.id}")
|
||||
|
||||
|
||||
@app.get("/admin/removed/posts")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue