forked from rDrama/rDrama
Add un-holing to hole report command.
parent
d9cf7d0ebb
commit
b94e71450f
|
@ -280,7 +280,7 @@ ACTIONTYPES = {
|
||||||
"color": 'bg-success'
|
"color": 'bg-success'
|
||||||
},
|
},
|
||||||
'move_hole': {
|
'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',
|
"icon": 'fa-manhole',
|
||||||
"color": 'bg-primary'
|
"color": 'bg-primary'
|
||||||
},
|
},
|
||||||
|
|
|
@ -40,15 +40,25 @@ def api_flag_post(pid, v):
|
||||||
)
|
)
|
||||||
g.db.add(ma)
|
g.db.add(ma)
|
||||||
elif reason.startswith('/h/') and v.admin_level > 1:
|
elif reason.startswith('/h/') and v.admin_level > 1:
|
||||||
sub = reason[3:].strip().lower()
|
sub_from = post.sub
|
||||||
sub = g.db.query(Sub).filter_by(name=sub).one_or_none()
|
sub_to = reason[3:].strip().lower()
|
||||||
if not sub: abort(404)
|
sub_to = g.db.query(Sub).filter_by(name=sub_to).one_or_none()
|
||||||
post.sub = sub.name
|
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)
|
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(
|
ma = ModAction(
|
||||||
kind="move_hole",
|
kind='move_hole',
|
||||||
user_id=v.id,
|
user_id=v.id,
|
||||||
target_submission_id=post.id,
|
target_submission_id=post.id,
|
||||||
|
_note=f'{sub_from_str} → {sub_to_str}',
|
||||||
)
|
)
|
||||||
g.db.add(ma)
|
g.db.add(ma)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue