make "unshadowban" button work instantly

master
Aevann1 2022-11-05 04:16:39 +02:00
parent 81ed8cfc81
commit f924f88821
2 changed files with 14 additions and 18 deletions

View File

@ -839,7 +839,8 @@ def unagendaposter(user_id, v):
@admin_level_required(PERMS['USER_SHADOWBAN']) @admin_level_required(PERMS['USER_SHADOWBAN'])
def shadowban(user_id, v): def shadowban(user_id, v):
user = get_account(user_id) user = get_account(user_id)
if user.admin_level != 0: abort(403) if user.admin_level > v.admin_level:
abort(403)
user.shadowbanned = v.username user.shadowbanned = v.username
reason = request.values.get("reason").strip()[:256] reason = request.values.get("reason").strip()[:256]
user.ban_reason = reason user.ban_reason = reason
@ -886,7 +887,7 @@ def unshadowban(user_id, v):
cache.delete_memoized(frontlist) cache.delete_memoized(frontlist)
return redirect(user.url) return {"message": f"@{user.username} has been unshadowbanned!"}
@app.post("/admin/title_change/<user_id>") @app.post("/admin/title_change/<user_id>")

View File

@ -57,22 +57,17 @@
</form> </form>
{% endif %} {% endif %}
{% if v.admin_level >= PERMS['USER_SHADOWBAN'] %} {% if v.admin_level >= PERMS['USER_SHADOWBAN'] %}
{% if u.shadowbanned %} <button type="button" id="unshadowban-{{deviceType}}" class="mt-1 mb-3 {% if not u.shadowbanned %}d-none{% endif %} btn btn-success" onclick="postToastSwitch(this,'/unshadowban/{{u.id}}','shadowban-{{deviceType}}','unshadowban-{{deviceType}}','d-none')">Unshadowban user</button>
<form class="mb-3" action="/unshadowban/{{u.id}}" method="post">
<input type="hidden" name="formkey" value="{{v.formkey}}"> <form id="shadowban-{{deviceType}}" class="mb-3 {% if u.shadowbanned %}d-none{% endif %}" action="/shadowban/{{u.id}}" method="post">
<input type="submit" onclick="disable(this)" class="btn btn-success" value="Unshadowban user"> <input type="hidden" name="formkey" value="{{v.formkey}}">
</form> <input autocomplete="off" style="font-size:11px" type="text" class="form-control" maxlength="256" name="reason" placeholder="Shadowban Reason" oninput="document.getElementById('user-shadowban-submit-{{deviceType}}').disabled=false" required>
{% else %} <div class="custom-control custom-checkbox mb-1">
<form class="mb-3" action="/shadowban/{{u.id}}" method="post"> <input autocomplete="off" type="checkbox" id="shadowban-alts-{{deviceType}}" class="custom-control-input" name="alts" value="1">
<input type="hidden" name="formkey" value="{{v.formkey}}"> <label class="custom-control-label" for="shadowban-alts-{{deviceType}}">Include alts</label>
<input autocomplete="off" style="font-size:11px" type="text" class="form-control" maxlength="256" name="reason" placeholder="Shadowban Reason" oninput="document.getElementById('user-shadowban-submit-{{deviceType}}').disabled=false" required> </div>
<div class="custom-control custom-checkbox mb-1"> <input autocomplete="off" id="user-shadowban-submit-{{deviceType}}" type="submit" onclick="disable(this)" class="btn btn-danger" value="Shadowban user" disabled>
<input autocomplete="off" type="checkbox" id="shadowban-alts-{{deviceType}}" class="custom-control-input" name="alts" value="1"> </form>
<label class="custom-control-label" for="shadowban-alts-{{deviceType}}">Include alts</label>
</div>
<input autocomplete="off" id="user-shadowban-submit-{{deviceType}}" type="submit" onclick="disable(this)" class="btn btn-danger" value="Shadowban user" disabled>
</form>
{% endif %}
{% endif %} {% endif %}
{% if v.admin_level >= PERMS['USER_AGENDAPOSTER'] %} {% if v.admin_level >= PERMS['USER_AGENDAPOSTER'] %}
<form id="agendaposter-{{deviceType}}" class="{% if u.agendaposter %}d-none{% endif %}" action="/agendaposter/{{u.id}}" method="post"> <form id="agendaposter-{{deviceType}}" class="{% if u.agendaposter %}d-none{% endif %}" action="/agendaposter/{{u.id}}" method="post">