Revert "my OCD doesn't like unused code"

This reverts commit 7c80ea91c8.
master
Aevann1 2022-06-29 01:36:40 +02:00
parent 9b45220542
commit 8d4f25de44
1 changed files with 33 additions and 1 deletions

View File

@ -315,7 +315,39 @@ def kick(v, pid):
return {"message": "Post kicked successfully!"}
def on_post_hole_entered(post, v):
@app.post("/rehole/<pid>", defaults={'hole': ''})
@app.post("/rehole/<pid>/<hole>")
@admin_level_required(2)
def rehole_post(v, pid, hole):
post = get_post(pid)
sub_from = post.sub
sub_to = hole.strip().lower()
sub_to = g.db.query(Sub).filter_by(name=sub_to).one_or_none()
sub_to = sub_to.name if sub_to else None
if sub_from == sub_to:
abort(400)
post.sub = sub_to
g.db.add(post)
sub_from_str = 'frontpage' if sub_from is None else \
f'<a href="/h/{sub_from}">/h/{sub_from}</a>'
sub_to_str = 'frontpage' if sub_to is None else \
f'<a href="/h/{sub_to}">/h/{sub_to}</a>'
ma = ModAction(
kind='move_hole',
user_id=v.id,
target_submission_id=post.id,
_note=f'{sub_from_str}{sub_to_str}',
)
g.db.add(ma)
on_post_hole_entered(post, v)
return {"message": f"Post moved to {sub_to_str}!"}
def on_post_hole_entered(post):
if not post.sub or not post.subr:
return
hole = post.subr.name