forked from MarseyWorld/MarseyWorld
better code + allow reason before link
parent
ff0539780d
commit
157ff82ff9
|
@ -989,6 +989,9 @@ def admin_change_flair(user_id, v):
|
||||||
@admin_level_required(PERMS['USER_BAN'])
|
@admin_level_required(PERMS['USER_BAN'])
|
||||||
def ban_user(fullname, v):
|
def ban_user(fullname, v):
|
||||||
|
|
||||||
|
post = None
|
||||||
|
comment = None
|
||||||
|
|
||||||
if fullname.startswith('p_'):
|
if fullname.startswith('p_'):
|
||||||
post_id = fullname.split('p_')[1]
|
post_id = fullname.split('p_')[1]
|
||||||
post = g.db.get(Post, post_id)
|
post = g.db.get(Post, post_id)
|
||||||
|
@ -1062,21 +1065,14 @@ def ban_user(fullname, v):
|
||||||
|
|
||||||
if 'reason' in request.values:
|
if 'reason' in request.values:
|
||||||
reason = request.values["reason"]
|
reason = request.values["reason"]
|
||||||
if reason.startswith("/post/"):
|
if post:
|
||||||
try: post_id = int(reason.split("/post/")[1].split(None, 1)[0])
|
actual_reason = reason.replace(f'/post/{post.id}', '').strip()
|
||||||
except: abort(400)
|
post.bannedfor = f'{duration} by @{v.username}'
|
||||||
actual_reason = reason.split(str(post_id))[1].strip()
|
if actual_reason:
|
||||||
post = get_post(post_id)
|
post.bannedfor += f' for "{actual_reason}"'
|
||||||
if post.hole != 'chudrama':
|
|
||||||
post.bannedfor = f'{duration} by @{v.username}'
|
|
||||||
if actual_reason:
|
|
||||||
post.bannedfor += f' for "{actual_reason}"'
|
|
||||||
g.db.add(post)
|
g.db.add(post)
|
||||||
elif reason.startswith("/comment/"):
|
elif comment:
|
||||||
try: comment_id = int(reason.split("/comment/")[1].split(None, 1)[0])
|
actual_reason = reason.replace(f'/comment/{comment.id}', '').strip()
|
||||||
except: abort(400)
|
|
||||||
actual_reason = reason.split(str(comment_id))[1].strip()
|
|
||||||
comment = get_comment(comment_id)
|
|
||||||
comment.bannedfor = f'{duration} by @{v.username}'
|
comment.bannedfor = f'{duration} by @{v.username}'
|
||||||
if actual_reason:
|
if actual_reason:
|
||||||
comment.bannedfor += f' for "{actual_reason}"'
|
comment.bannedfor += f' for "{actual_reason}"'
|
||||||
|
|
Loading…
Reference in New Issue