add button to remove progstack

pull/128/head
Aevann 2023-02-19 16:02:30 +02:00
parent f462562080
commit 472bed996f
5 changed files with 62 additions and 9 deletions

View File

@ -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'}

View File

@ -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/<int:post_id>")
@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/<int:comment_id>")
@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/<int:comment_id>")
@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/<int:post_id>")
@limiter.limit(DEFAULT_RATELIMIT_SLOWER)
@limiter.limit(DEFAULT_RATELIMIT_SLOWER, key_func=get_ID)

View File

@ -463,7 +463,8 @@
{% endif %}
{% if v.admin_level >= PERMS['PROGSTACK'] %}
<button type="button" id="progstack-{{c.id}}" class="dropdown-item list-inline-item d-none {% if c.is_approved != PROGSTACK_ID %}d-md-block{% endif %} text-danger" data-nonce="{{g.nonce}}" data-onclick="postToast(this,'/admin/progstack/comment/{{c.id}}'"><i class="fas fa-bullhorn text-danger fa-fw"></i>Apply Progressive Stack</button>
<button type="button" id="progstack-{{c.id}}" class="dropdown-item list-inline-item d-none {% if c.is_approved != PROGSTACK_ID %}d-md-block{% endif %} text-danger" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/admin/progstack/comment/{{c.id}}','progstack-{{c.id}}','unprogstack-{{c.id}}','d-md-block')"><i class="fas fa-bullhorn text-danger fa-fw"></i>Apply Progressive Stack</button>
<button type="button" id="unprogstack-{{c.id}}" class="dropdown-item list-inline-item d-none {% if c.is_approved == PROGSTACK_ID %}d-md-block{% endif %} text-danger" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/admin/unprogstack/comment/{{c.id}}','progstack-{{c.id}}','unprogstack-{{c.id}}','d-md-block')"><i class="fas fa-bullhorn text-danger fa-fw"></i>Remove Progressive Stack</button>
{% 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'] %}
<button type="button" id="progstack2-{{c.id}}" class="{% if c.is_approved == PROGSTACK_ID %}d-none{% endif %} list-group-item text-danger" data-nonce="{{g.nonce}}" data-onclick="postToast(this,'/admin/progstack/comment/{{c.id}}'" data-bs-dismiss="modal"><i class="fas fa-bullhorn text-danger fa-fw mr-2"></i>Apply Progressive Stack</button>
<button type="button" id="progstack2-{{c.id}}" class="{% if c.is_approved == PROGSTACK_ID %}d-none{% endif %} list-group-item text-danger" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/admin/progstack/comment/{{c.id}}','progstack2-{{c.id}}','unprogstack2-{{c.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-bullhorn text-danger fa-fw mr-2"></i>Apply Progressive Stack</button>
<button type="button" id="unprogstack2-{{c.id}}" class="{% if c.is_approved != PROGSTACK_ID %}d-none{% endif %} list-group-item text-danger" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/admin/unprogstack/comment/{{c.id}}','progstack2-{{c.id}}','unprogstack2-{{c.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-bullhorn text-danger fa-fw mr-2"></i>Remove Progressive Stack</button>
{% endif %}
{% if v.id != c.author_id and v.admin_level >= PERMS['USER_BAN'] %}

View File

@ -83,7 +83,8 @@
<button type="button" id="unmark-{{p.id}}" class="dropdown-item {% if not p.over_18 %}d-none{% endif %} list-inline-item text-success" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/unmark_post_nsfw/{{p.id}}','mark-{{p.id}}','unmark-{{p.id}}','d-none')"><i class="fas fa-eye-evil"></i>Unmark +18</button>
{% endif %}
{% if v.admin_level >= PERMS['PROGSTACK'] %}
<button type="button" id="progstack-{{p.id}}" class="dropdown-item {% if p.is_approved == PROGSTACK_ID %}d-none{% endif %} list-inline-item text-danger" data-nonce="{{g.nonce}}" data-onclick="postToast(this,'/admin/progstack/post/{{p.id}}'"><i class="fas fa-bullhorn"></i>Apply Progressive Stack</button>
<button type="button" id="progstack-{{p.id}}" class="dropdown-item {% if p.is_approved == PROGSTACK_ID %}d-none{% endif %} list-inline-item text-danger" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/admin/progstack/post/{{p.id}}','progstack-{{p.id}}','unprogstack-{{p.id}}','d-none')"><i class="fas fa-bullhorn"></i>Apply Progressive Stack</button>
<button type="button" id="unprogstack-{{p.id}}" class="dropdown-item {% if p.is_approved != PROGSTACK_ID %}d-none{% endif %} list-inline-item text-danger" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/admin/unprogstack/post/{{p.id}}','progstack-{{p.id}}','unprogstack-{{p.id}}','d-none')"><i class="fas fa-bullhorn"></i>Remove Progressive Stack</button>
{% endif %}
{% if v.admin_level >= PERMS['USER_BAN'] and v.id != p.author_id %}
<button type="button" class="dropdown-item list-inline-item text-danger" data-bs-toggle="modal" data-bs-target="#banModal" data-nonce="{{g.nonce}}" data-onclick="banModal('/post/{{p.id}}', '{{p.author_name}}', '{{p.fullname}}','d-none')"><i class="fas fa-user-slash text-danger fa-fw"></i>Ban user</button>

View File

@ -37,7 +37,8 @@
<button type="button" id="unmark2-{{p.id}}" class="{% if not p.over_18 %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-success" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/unmark_post_nsfw/{{p.id}}','mark2-{{p.id}}','unmark2-{{p.id}}','d-none')" data-bs-dismiss="modal"><i class="far fa-eye-evil text-center text-success mr-2"></i>Unmark +18</button>
{% endif %}
{% if v.admin_level >= PERMS['PROGSTACK'] %}
<button type="button" id="progstack2-{{p.id}}" class="{% if p.is_approved == PROGSTACK_ID %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-danger" data-nonce="{{g.nonce}}" data-onclick="postToast(this,'/admin/progstack/post/{{p.id}}'" data-bs-dismiss="modal"><i class="fas fa-bullhorn text-center text-danger mr-2"></i>Apply Progressive Stack</button>
<button type="button" id="progstack2-{{p.id}}" class="{% if p.is_approved == PROGSTACK_ID %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-danger" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/admin/progstack/post/{{p.id}}','progstack2-{{p.id}}','unprogstack2-{{p.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-bullhorn text-center text-danger mr-2"></i>Apply Progressive Stack</button>
<button type="button" id="unprogstack2-{{p.id}}" class="{% if p.is_approved != PROGSTACK_ID %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-danger" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/admin/unprogstack/post/{{p.id}}','progstack2-{{p.id}}','unprogstack2-{{p.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-bullhorn text-center text-danger mr-2"></i>Remove Progressive Stack</button>
{% endif %}
{% if v.id != p.author_id and v.admin_level >= PERMS['USER_BAN'] %}
<button type="button" data-bs-dismiss="modal" data-bs-toggle="modal" data-bs-target="#banModal" data-nonce="{{g.nonce}}" data-onclick="banModal('/post/{{p.id}}', '{{p.author_name}}', '{{p.fullname}}','d-none')" class="nobackground btn btn-link btn-block btn-lg text-danger text-left"><i class="fas fa-user-minus mr-2"></i>Ban user</button>