Add un-holing to hole report command.

remotes/1693045480750635534/spooky-22
Snakes 2022-06-09 02:42:52 -04:00
parent d9cf7d0ebb
commit b94e71450f
2 changed files with 17 additions and 7 deletions

View File

@ -280,7 +280,7 @@ ACTIONTYPES = {
"color": 'bg-success'
},
'move_hole': {
"str": 'moved {self.target_link} to <a href="/h/{self.target_post.sub}">/h/{self.target_post.sub}</a>',
"str": 'changed hole of {self.target_link}',
"icon": 'fa-manhole',
"color": 'bg-primary'
},

View File

@ -40,15 +40,25 @@ def api_flag_post(pid, v):
)
g.db.add(ma)
elif reason.startswith('/h/') and v.admin_level > 1:
sub = reason[3:].strip().lower()
sub = g.db.query(Sub).filter_by(name=sub).one_or_none()
if not sub: abort(404)
post.sub = sub.name
sub_from = post.sub
sub_to = reason[3:].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(404)
post.sub = sub_to
g.db.add(post)
ma=ModAction(
kind="move_hole",
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)
else: