diff --git a/files/helpers/config/modaction_types.py b/files/helpers/config/modaction_types.py index abe01ebeb..a89eaec9d 100644 --- a/files/helpers/config/modaction_types.py +++ b/files/helpers/config/modaction_types.py @@ -196,6 +196,16 @@ MODACTION_TYPES = { "icon": 'fa-thumbtack fa-rotate--45', "color": 'bg-success' }, + 'progstack_comment': { + "str": 'Applied progressive stack on {self.target_link}', + "icon": 'fa-bullhorn', + "color": 'bg-success' + }, + 'progstack_post': { + "str": 'Applied progressive stack on post {self.target_link}', + "icon": 'fa-bullhorn', + "color": 'bg-success' + }, 'clear_cloudflare_cache': { "str": 'cleared cloudflare cache', "icon": 'fab fa-cloudflare', @@ -335,6 +345,7 @@ MODACTION_TYPES = { MODACTION_PRIVILEGED_TYPES = {'shadowban', 'unshadowban', 'mod_mute_user', 'mod_unmute_user', - 'link_accounts', 'delink_accounts'} + 'link_accounts', 'delink_accounts', + 'progstack_post', 'progstack_comment'} MODACTION_TYPES_FILTERED = deepcopy({t:v for t,v in MODACTION_TYPES.items() if not t in MODACTION_PRIVILEGED_TYPES}) diff --git a/files/routes/admin.py b/files/routes/admin.py index 37275122e..af0b6c831 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -22,7 +22,7 @@ from files.routes.routehelpers import check_for_alts from files.routes.wrappers import * from files.routes.routehelpers import get_alt_graph, get_alt_graph_ids -from .front import frontlist +from .front import frontlist, comment_idlist @app.get('/admin/loggedin') @limiter.limit(DEFAULT_RATELIMIT, key_func=get_ID) @@ -1121,17 +1121,45 @@ def unmute_user(v:User, user_id): return {"message": f"@{user.username} has been unmuted!"} -@app.post("/admin/progstack/") +@app.post("/admin/progstack/post/") @limiter.limit(DEFAULT_RATELIMIT_SLOWER) @limiter.limit(DEFAULT_RATELIMIT_SLOWER, key_func=get_ID) @admin_level_required(PERMS['PROGSTACK']) -def progstack(post_id, v): +def progstack_post(post_id, v): post = get_post(post_id) post.is_approved = PROGSTACK_ID post.realupvotes = floor(post.realupvotes * PROGSTACK_MUL) g.db.add(post) + + ma=ModAction( + kind="progstack_post", + user_id=v.id, + target_submission_id=post.id, + ) + g.db.add(ma) + cache.delete_memoized(frontlist) - return {"message": "Progressive stack applied!"} + return {"message": "Progressive stack applied on post!"} + +@app.post("/admin/progstack/comment/") +@limiter.limit(DEFAULT_RATELIMIT_SLOWER) +@limiter.limit(DEFAULT_RATELIMIT_SLOWER, key_func=get_ID) +@admin_level_required(PERMS['PROGSTACK']) +def progstack_comment(comment_id, v): + comment = get_comment(comment_id) + comment.is_approved = PROGSTACK_ID + comment.realupvotes = floor(comment.realupvotes * PROGSTACK_MUL) + g.db.add(comment) + + ma=ModAction( + kind="progstack_comment", + user_id=v.id, + target_comment_id=comment.id, + ) + g.db.add(ma) + + cache.delete_memoized(comment_idlist) + return {"message": "Progressive stack applied on comment!"} @app.post("/remove_post/") @limiter.limit(DEFAULT_RATELIMIT_SLOWER) diff --git a/files/templates/comments.html b/files/templates/comments.html index b15a1ad94..223de96f2 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -456,6 +456,10 @@ {% endif %} {% endif %} +{% if v.admin_level >= PERMS['PROGSTACK'] %} + +{% endif %} + {% if (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))) %} @@ -657,6 +661,10 @@ {% 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 feab586b1..2da399e26 100644 --- a/files/templates/post_actions.html +++ b/files/templates/post_actions.html @@ -83,7 +83,7 @@ {% 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 db41ebf14..8f0d46034 100644 --- a/files/templates/post_admin_actions_mobile.html +++ b/files/templates/post_admin_actions_mobile.html @@ -37,7 +37,7 @@ {% endif %} {% if v.admin_level >= PERMS['PROGSTACK'] %} - + {% endif %} {% if v.id != p.author_id and v.admin_level >= PERMS['USER_BAN'] %}