less go
This commit is contained in:
parent
40bac27091
commit
b30567affb
2 changed files with 19 additions and 4 deletions
|
@ -185,14 +185,11 @@ def api_comment(v):
|
||||||
if parent_fullname.startswith("t2_"):
|
if parent_fullname.startswith("t2_"):
|
||||||
parent = parent_post
|
parent = parent_post
|
||||||
parent_comment_id = None
|
parent_comment_id = None
|
||||||
top_comment_id = None
|
|
||||||
level = 1
|
level = 1
|
||||||
elif parent_fullname.startswith("t3_"):
|
elif parent_fullname.startswith("t3_"):
|
||||||
parent = get_comment(parent_fullname.split("_")[1], v=v)
|
parent = get_comment(parent_fullname.split("_")[1], v=v)
|
||||||
parent_comment_id = parent.id
|
parent_comment_id = parent.id
|
||||||
level = parent.level + 1
|
level = parent.level + 1
|
||||||
if level == 2: top_comment_id = parent.id
|
|
||||||
else: top_comment_id = parent.top_comment_id
|
|
||||||
if parent.author_id == v.id: rts = True
|
if parent.author_id == v.id: rts = True
|
||||||
else: abort(400)
|
else: abort(400)
|
||||||
|
|
||||||
|
@ -397,7 +394,6 @@ def api_comment(v):
|
||||||
c = Comment(author_id=v.id,
|
c = Comment(author_id=v.id,
|
||||||
parent_submission=parent_submission,
|
parent_submission=parent_submission,
|
||||||
parent_comment_id=parent_comment_id,
|
parent_comment_id=parent_comment_id,
|
||||||
top_comment_id=top_comment_id,
|
|
||||||
level=level,
|
level=level,
|
||||||
over_18=parent_post.over_18 or request.values.get("over_18")=="true",
|
over_18=parent_post.over_18 or request.values.get("over_18")=="true",
|
||||||
is_bot=is_bot,
|
is_bot=is_bot,
|
||||||
|
@ -411,6 +407,9 @@ def api_comment(v):
|
||||||
g.db.add(c)
|
g.db.add(c)
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
|
|
||||||
|
if c.level == 1: c.top_comment_id = c.id
|
||||||
|
else: c.top_comment_id = parent.top_comment_id
|
||||||
|
|
||||||
for option in options:
|
for option in options:
|
||||||
c_option = Comment(author_id=AUTOPOLLER_ID,
|
c_option = Comment(author_id=AUTOPOLLER_ID,
|
||||||
parent_submission=parent_submission,
|
parent_submission=parent_submission,
|
||||||
|
|
|
@ -543,6 +543,8 @@ def edit_post(pid, v):
|
||||||
g.db.add(c_jannied)
|
g.db.add(c_jannied)
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
|
|
||||||
|
c_jannied.top_comment_id = c_jannied.id
|
||||||
|
|
||||||
n = Notification(comment_id=c_jannied.id, user_id=v.id)
|
n = Notification(comment_id=c_jannied.id, user_id=v.id)
|
||||||
g.db.add(n)
|
g.db.add(n)
|
||||||
|
|
||||||
|
@ -725,6 +727,9 @@ def thumbnail_thread(pid):
|
||||||
db.add(new_comment)
|
db.add(new_comment)
|
||||||
db.flush()
|
db.flush()
|
||||||
|
|
||||||
|
new_comment.top_comment_id = new_comment.id
|
||||||
|
|
||||||
|
|
||||||
admins = db.query(User).filter(User.admin_level > 0).all()
|
admins = db.query(User).filter(User.admin_level > 0).all()
|
||||||
for admin in admins:
|
for admin in admins:
|
||||||
notif = Notification(comment_id=new_comment.id, user_id=admin.id)
|
notif = Notification(comment_id=new_comment.id, user_id=admin.id)
|
||||||
|
@ -751,6 +756,9 @@ def thumbnail_thread(pid):
|
||||||
db.add(new_comment)
|
db.add(new_comment)
|
||||||
db.flush()
|
db.flush()
|
||||||
|
|
||||||
|
new_comment.top_comment_id = new_comment.id
|
||||||
|
|
||||||
|
|
||||||
notif = Notification(comment_id=new_comment.id, user_id=val)
|
notif = Notification(comment_id=new_comment.id, user_id=val)
|
||||||
db.add(notif)
|
db.add(notif)
|
||||||
|
|
||||||
|
@ -777,6 +785,9 @@ def thumbnail_thread(pid):
|
||||||
db.add(new_comment)
|
db.add(new_comment)
|
||||||
db.flush()
|
db.flush()
|
||||||
|
|
||||||
|
new_comment.top_comment_id = new_comment.id
|
||||||
|
|
||||||
|
|
||||||
admins = db.query(User).filter(User.admin_level > 2).all()
|
admins = db.query(User).filter(User.admin_level > 2).all()
|
||||||
for admin in admins:
|
for admin in admins:
|
||||||
notif = Notification(comment_id=new_comment.id, user_id=admin.id)
|
notif = Notification(comment_id=new_comment.id, user_id=admin.id)
|
||||||
|
@ -1187,6 +1198,8 @@ def submit_post(v, sub=None):
|
||||||
g.db.add(c_jannied)
|
g.db.add(c_jannied)
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
|
|
||||||
|
c_jannied.top_comment_id = c_jannied.id
|
||||||
|
|
||||||
n = Notification(comment_id=c_jannied.id, user_id=v.id)
|
n = Notification(comment_id=c_jannied.id, user_id=v.id)
|
||||||
g.db.add(n)
|
g.db.add(n)
|
||||||
|
|
||||||
|
@ -1282,6 +1295,9 @@ def submit_post(v, sub=None):
|
||||||
check_for_slots_command(body, snappy, c)
|
check_for_slots_command(body, snappy, c)
|
||||||
|
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
|
|
||||||
|
c.top_comment_id = c.id
|
||||||
|
|
||||||
post.comment_count += 1
|
post.comment_count += 1
|
||||||
post.replies = [c]
|
post.replies = [c]
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue