From ffd0d9ed316d19bcc626ae0363a4d14bef8bc093 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 25 Jun 2022 02:11:00 +0200 Subject: [PATCH] show duration on ban icon tooltip --- files/classes/comment.py | 2 +- files/classes/submission.py | 2 +- files/routes/admin.py | 20 ++++++++------------ files/templates/ban_modal.html | 2 +- files/templates/comments.html | 2 +- files/templates/submission.html | 2 +- files/templates/submission_listing.html | 2 +- schema.sql | 4 ++-- 8 files changed, 16 insertions(+), 20 deletions(-) diff --git a/files/classes/comment.py b/files/classes/comment.py index 480eb4171..fd3ee26a9 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -51,7 +51,7 @@ class Comment(Base): edited_utc = Column(Integer, default=0) is_banned = Column(Boolean, default=False) ghost = Column(Boolean, default=False) - bannedfor = Column(Boolean) + bannedfor = Column(String) distinguish_level = Column(Integer, default=0) deleted_utc = Column(Integer, default=0) is_approved = Column(Integer, ForeignKey("users.id")) diff --git a/files/classes/submission.py b/files/classes/submission.py index cdf21a7af..f4f606e7d 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -40,7 +40,7 @@ class Submission(Base): created_utc = Column(Integer) thumburl = Column(String) is_banned = Column(Boolean, default=False) - bannedfor = Column(Boolean) + bannedfor = Column(String) ghost = Column(Boolean, default=False) views = Column(Integer, default=0) deleted_utc = Column(Integer, default=0) diff --git a/files/routes/admin.py b/files/routes/admin.py index 30e26a1c2..1d13f8413 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -1110,19 +1110,15 @@ def ban_user(user_id, v): if 'reason' in request.values: if request.values["reason"].startswith("/post/"): - try: - post = int(request.values["reason"].split("/post/")[1].split(None, 1)[0]) - post = get_post(post) - post.bannedfor = True - g.db.add(post) - except: pass + post = int(request.values["reason"].split("/post/")[1].split(None, 1)[0]) + post = get_post(post) + post.bannedfor = duration + g.db.add(post) elif request.values["reason"].startswith("/comment/"): - try: - comment = int(request.values["reason"].split("/comment/")[1].split(None, 1)[0]) - comment = get_comment(comment) - comment.bannedfor = True - g.db.add(comment) - except: pass + comment = int(request.values["reason"].split("/comment/")[1].split(None, 1)[0]) + comment = get_comment(comment) + comment.bannedfor = duration + g.db.add(comment) notify_mod_action(v.id, f"@{v.username} has banned @{user.username} ({note})") g.db.commit() diff --git a/files/templates/ban_modal.html b/files/templates/ban_modal.html index 10c5832aa..c619fecfa 100644 --- a/files/templates/ban_modal.html +++ b/files/templates/ban_modal.html @@ -1,5 +1,5 @@ - +