From bc927ef2380d470817bda5fbed98f188fb0cebb4 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 12 Jul 2022 21:32:34 +0200 Subject: [PATCH 1/3] remove editing sidebar from PCM --- files/routes/admin.py | 35 ---------------------- files/templates/admin/admin_home.html | 14 +++------ files/templates/admin/sidebar.html | 42 --------------------------- 3 files changed, 4 insertions(+), 87 deletions(-) delete mode 100644 files/templates/admin/sidebar.html diff --git a/files/routes/admin.py b/files/routes/admin.py index 57845ba11d..b8c09aa4e2 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -146,41 +146,6 @@ def merge_all(v, id): return redirect(user.url) - -if SITE_NAME == 'PCM': - @app.get('/admin/sidebar') - @admin_level_required(3) - def get_sidebar(v): - - try: - with open(f'files/templates/sidebar_{SITE_NAME}.html', 'r', encoding="utf-8") as f: sidebar = f.read() - except: - sidebar = None - - return render_template('admin/sidebar.html', v=v, sidebar=sidebar) - - - @app.post('/admin/sidebar') - @limiter.limit("1/second;30/minute;200/hour;1000/day") - @admin_level_required(3) - def post_sidebar(v): - - text = request.values.get('sidebar', '').strip() - - with open(f'files/templates/sidebar_{SITE_NAME}.html', 'w+', encoding="utf-8") as f: f.write(text) - - with open(f'files/templates/sidebar_{SITE_NAME}.html', 'r', encoding="utf-8") as f: sidebar = f.read() - - ma = ModAction( - kind="change_sidebar", - user_id=v.id, - ) - g.db.add(ma) - - - return render_template('admin/sidebar.html', v=v, sidebar=sidebar, msg='Sidebar edited successfully!') - - @app.post("/@/make_admin") @admin_level_required(3) def make_admin(v, username): diff --git a/files/templates/admin/admin_home.html b/files/templates/admin/admin_home.html index c2a4921bd8..1a026e238f 100644 --- a/files/templates/admin/admin_home.html +++ b/files/templates/admin/admin_home.html @@ -61,16 +61,10 @@
  • Daily Stat Chart
  • -{% if SITE_NAME in ['PCM', 'WPD'] -%} -

    Configuration

    - -{%- endif %} +

    Configuration

    + {% if v.admin_level > 2 %}
    
    diff --git a/files/templates/admin/sidebar.html b/files/templates/admin/sidebar.html
    deleted file mode 100644
    index 77b6c49b69..0000000000
    --- a/files/templates/admin/sidebar.html
    +++ /dev/null
    @@ -1,42 +0,0 @@
    -{% extends "default.html" %}
    -
    -{% block pagetitle %}Edit {{SITE_NAME}} sidebar{% endblock %}
    -
    -{% block content %}
    -
    -{% if msg %}
    -	
    -{% endif %}
    -
    -
    -
    -
    -
    -

    Edit Sidebar

    -
    -
    -
    -
    -
    - - - -
    - -
    -
    -
    -
    -
    -
    -
    - -{% endblock %} \ No newline at end of file From 077353c1f444333bf6ea03e21c7024cccafc13ce Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 12 Jul 2022 21:42:23 +0200 Subject: [PATCH 2/3] hide ghost posts from post notifications --- files/classes/user.py | 3 ++- files/routes/notifications.py | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/files/classes/user.py b/files/classes/user.py index 04d1c63aea..d95a2d89ec 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -481,7 +481,8 @@ class User(Base): Submission.deleted_utc == 0, Submission.is_banned == False, Submission.private == False, - Submission.author_id != self.id + Submission.author_id != self.id, + Submission.ghost == False ).count() @property diff --git a/files/routes/notifications.py b/files/routes/notifications.py index 601f7a0d4b..2ea025305f 100644 --- a/files/routes/notifications.py +++ b/files/routes/notifications.py @@ -102,6 +102,7 @@ def notifications_posts(v): Submission.is_banned == False, Submission.private == False, Submission.author_id != v.id, + Submission.ghost == False ).order_by(Submission.created_utc.desc()).offset(25 * (page - 1)).limit(26).all()] next_exists = (len(listing) > 25) From 093c83d7c9781a79e8608c081bf193c59bd4858c Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 12 Jul 2022 22:00:19 +0200 Subject: [PATCH 3/3] tweaking bannedfor column --- files/routes/admin.py | 9 ++++++--- files/templates/comments.html | 2 +- files/templates/submission.html | 2 +- files/templates/submission_listing.html | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/files/routes/admin.py b/files/routes/admin.py index b8c09aa4e2..6206c086e7 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -255,6 +255,7 @@ def revert_actions(v, username): for item in posts + comments: item.is_banned = False item.ban_reason = None + item.is_approved = v.id g.db.add(item) users = (x[0] for x in g.db.query(ModAction.target_user_id).filter(ModAction.user_id == user.id, ModAction.created_utc > cutoff, ModAction.kind.in_(('shadowban', 'ban_user'))).all()) @@ -1014,9 +1015,9 @@ def ban_user(user_id, v): send_repeatable_notification(user.id, text) - if days == 0: duration = "permanent" - elif days == 1: duration = "1 day" - else: duration = f"{days} days" + if days == 0: duration = "permanently" + elif days == 1: duration = "for 1 day" + else: duration = f"for {days} days" note = f'reason: "{reason}", duration: {duration}' ma=ModAction( @@ -1488,6 +1489,7 @@ def admin_nunuke_user(v): post.is_banned = False post.ban_reason = None + post.is_approved = v.id g.db.add(post) for comment in g.db.query(Comment).filter_by(author_id=user.id).all(): @@ -1496,6 +1498,7 @@ def admin_nunuke_user(v): comment.is_banned = False comment.ban_reason = None + comment.is_approved = v.id g.db.add(comment) ma=ModAction( diff --git a/files/templates/comments.html b/files/templates/comments.html index c6ef8d0976..e054e7f880 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -175,7 +175,7 @@ {% endif %} {% if c.bannedfor %} - + {% endif %} {% if c.active_flags(v) and (v and v.admin_level >= PERMS['FLAGS_VISIBLE']) %}{{c.active_flags(v)}} Report{{ help.plural(c.active_flags(v)) }}{% endif %} {% if c.over_18 %}+18{% endif %} diff --git a/files/templates/submission.html b/files/templates/submission.html index 8189dbd207..64b41114ae 100644 --- a/files/templates/submission.html +++ b/files/templates/submission.html @@ -636,7 +636,7 @@ {% endif %} {% if p.bannedfor %} - + {% endif %} {% for a in p.awards %} diff --git a/files/templates/submission_listing.html b/files/templates/submission_listing.html index ddaec44f16..35591eab15 100644 --- a/files/templates/submission_listing.html +++ b/files/templates/submission_listing.html @@ -163,7 +163,7 @@ {% endif %} {% if p.bannedfor %} - + {% endif %} {% for a in p.awards %}