From 472bed996f0a49e409d98ee45d4e4a613c80d293 Mon Sep 17 00:00:00 2001 From: Aevann Date: Sun, 19 Feb 2023 16:02:30 +0200 Subject: [PATCH] add button to remove progstack --- files/helpers/config/modaction_types.py | 23 +++++++++--- files/routes/admin.py | 36 +++++++++++++++++++ files/templates/comments.html | 6 ++-- files/templates/post_actions.html | 3 +- .../templates/post_admin_actions_mobile.html | 3 +- 5 files changed, 62 insertions(+), 9 deletions(-) diff --git a/files/helpers/config/modaction_types.py b/files/helpers/config/modaction_types.py index 7c83a6621..2e3b2466d 100644 --- a/files/helpers/config/modaction_types.py +++ b/files/helpers/config/modaction_types.py @@ -207,15 +207,25 @@ MODACTION_TYPES = { "color": 'bg-success' }, 'progstack_comment': { - "str": 'Applied progressive stack on {self.target_link}', + "str": 'applied progressive stack on {self.target_link}', "icon": 'fa-bullhorn', "color": 'bg-success' }, + 'unprogstack_comment': { + "str": 'removed progressive stack from {self.target_link}', + "icon": 'fa-bullhorn', + "color": 'bg-danger' + }, 'progstack_post': { - "str": 'Applied progressive stack on post {self.target_link}', + "str": 'applied progressive stack on post {self.target_link}', "icon": 'fa-bullhorn', "color": 'bg-success' }, + 'unprogstack_post': { + "str": 'removed progressive stack from post {self.target_link}', + "icon": 'fa-bullhorn', + "color": 'bg-danger' + }, 'clear_cloudflare_cache': { "str": 'cleared cloudflare cache', "icon": 'fab fa-cloudflare', @@ -381,12 +391,15 @@ MODACTION_TYPES = { MODACTION_PRIVILEGED_TYPES = {'shadowban', 'unshadowban', 'mod_mute_user', 'mod_unmute_user', 'link_accounts', 'delink_accounts', - 'progstack_post', 'progstack_comment'} -MODACTION_PRIVILEGED__TYPES = {'progstack_post', 'progstack_comment'} + 'progstack_post', 'progstack_comment', + 'unprogstack_post', 'unprogstack_comment'} +MODACTION_PRIVILEGED__TYPES = {'progstack_post', 'progstack_comment', + 'unprogstack_post', 'unprogstack_comment'} MODACTION_TYPES_FILTERED = deepcopy({t:v for t,v in MODACTION_TYPES.items() if not t in MODACTION_PRIVILEGED_TYPES}) MODACTION_TYPES__FILTERED = deepcopy({t:v for t,v in MODACTION_TYPES.items() if not t in MODACTION_PRIVILEGED__TYPES}) AEVANN_MODACTION_TYPES = {'ban_user','unban_user', 'shadowban','unshadowban', - 'progstack_post','progstack_comment'} + 'progstack_post','progstack_comment', + 'unprogstack_post', 'unprogstack_comment'} diff --git a/files/routes/admin.py b/files/routes/admin.py index 1b0441332..706ee6f88 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -1117,6 +1117,24 @@ def progstack_post(post_id, v): cache.delete_memoized(frontlist) return {"message": "Progressive stack applied on post!"} +@app.post("/admin/unprogstack/post/") +@limiter.limit(DEFAULT_RATELIMIT_SLOWER) +@limiter.limit(DEFAULT_RATELIMIT_SLOWER, key_func=get_ID) +@admin_level_required(PERMS['PROGSTACK']) +def unprogstack_post(post_id, v): + post = get_post(post_id) + post.is_approved = None + g.db.add(post) + + ma=ModAction( + kind="unprogstack_post", + user_id=v.id, + target_submission_id=post.id, + ) + g.db.add(ma) + + return {"message": "Progressive stack removed from post!"} + @app.post("/admin/progstack/comment/") @limiter.limit(DEFAULT_RATELIMIT_SLOWER) @limiter.limit(DEFAULT_RATELIMIT_SLOWER, key_func=get_ID) @@ -1137,6 +1155,24 @@ def progstack_comment(comment_id, v): cache.delete_memoized(comment_idlist) return {"message": "Progressive stack applied on comment!"} +@app.post("/admin/unprogstack/comment/") +@limiter.limit(DEFAULT_RATELIMIT_SLOWER) +@limiter.limit(DEFAULT_RATELIMIT_SLOWER, key_func=get_ID) +@admin_level_required(PERMS['PROGSTACK']) +def unprogstack_comment(comment_id, v): + comment = get_comment(comment_id) + comment.is_approved = None + g.db.add(comment) + + ma=ModAction( + kind="unprogstack_comment", + user_id=v.id, + target_comment_id=comment.id, + ) + g.db.add(ma) + + return {"message": "Progressive stack removed from comment!"} + @app.post("/remove_post/") @limiter.limit(DEFAULT_RATELIMIT_SLOWER) @limiter.limit(DEFAULT_RATELIMIT_SLOWER, key_func=get_ID) diff --git a/files/templates/comments.html b/files/templates/comments.html index 9be640a0a..c4245c164 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -463,7 +463,8 @@ {% endif %} {% if v.admin_level >= PERMS['PROGSTACK'] %} - + + {% endif %} {% if FEATURES['NSFW_MARKING'] and (c.parent_submission or c.wall_user_id) and (c.author_id==v.id or v.admin_level >= PERMS['POST_COMMENT_MODERATION'] or (c.post.sub and v.mods(c.post.sub))) %} @@ -670,7 +671,8 @@ {% endif %} {% if v.admin_level >= PERMS['PROGSTACK'] %} - + + {% endif %} {% if v.id != c.author_id and v.admin_level >= PERMS['USER_BAN'] %} diff --git a/files/templates/post_actions.html b/files/templates/post_actions.html index 09bbb61e8..2cd82bb07 100644 --- a/files/templates/post_actions.html +++ b/files/templates/post_actions.html @@ -83,7 +83,8 @@ {% endif %} {% if v.admin_level >= PERMS['PROGSTACK'] %} - + + {% endif %} {% if v.admin_level >= PERMS['USER_BAN'] and v.id != p.author_id %} diff --git a/files/templates/post_admin_actions_mobile.html b/files/templates/post_admin_actions_mobile.html index 2b41634a2..eea2e70b6 100644 --- a/files/templates/post_admin_actions_mobile.html +++ b/files/templates/post_admin_actions_mobile.html @@ -37,7 +37,8 @@ {% endif %} {% if v.admin_level >= PERMS['PROGSTACK'] %} - + + {% endif %} {% if v.id != p.author_id and v.admin_level >= PERMS['USER_BAN'] %}