diff --git a/files/routes/admin.py b/files/routes/admin.py index 6a9b94365b..4be2e85917 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -850,9 +850,14 @@ def ban_user(user_id, v): if user.admin_level >= v.admin_level: abort(403) # check for number of days for suspension - days = int(request.values.get("days")) if request.values.get('days') else 0 - reason = sanitize(request.values.get("reason", "")) - message = request.values.get("reason", "") + if 'form' in request.values: + days = int(request.form.get("days")) if request.form.get('days') else 0 + reason = sanitize(request.form.get("reason", "")) + message = request.form.get("reason", "") + else: + days = int(request.values.get("days")) if request.values.get('days') else 0 + reason = sanitize(request.values.get("reason", "")) + message = request.values.get("reason", "") if not user: abort(400) diff --git a/files/templates/ban_modal.html b/files/templates/ban_modal.html new file mode 100644 index 0000000000..ac5b2021f9 --- /dev/null +++ b/files/templates/ban_modal.html @@ -0,0 +1,41 @@ + + \ No newline at end of file diff --git a/files/templates/comments.html b/files/templates/comments.html index e4cfe158e5..3d496b4ab0 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -333,7 +333,7 @@ {% if v and v.admin_level==6 and v.id != c.author_id %}
  • Unban user
  • -
  • Ban user
  • +
  • Ban user
  • {% endif %} {% if v and v.admin_level >=4 and c.oauth_app %} @@ -492,7 +492,7 @@ {% if v and (c.post and v.admin_level == 6) %} {% if c.author_id != v.id %} -
  • Ban user
  • +
  • Ban user
  • Unban user
  • {% endif %} {% endif %} diff --git a/files/templates/default.html b/files/templates/default.html index 3e3b197963..15a8a66c7a 100644 --- a/files/templates/default.html +++ b/files/templates/default.html @@ -445,6 +445,31 @@ }; + // ban modal + + const banModal = function(link, id, name) { + document.getElementById("banModalTitle").innerHTML = `Ban @${name}`; + document.getElementById("ban-modal-link").innerHTML = `${link}`; + document.getElementById("banUserButton").innerHTML = `Ban @${name}`; + + document.getElementById("banUserButton").onclick = function() { + let fd = new FormData(document.getElementById("banModalForm")); + fd.append("formkey", formkey()); + + let xhr = new XMLHttpRequest(); + xhr.open("POST", `/ban_user/${id}?form`, true); + xhr.withCredentials = true; + + xhr.onload = function(){ + $('#toast-post-success').toast('dispose'); + $('#toast-post-success').toast('show'); + document.getElementById('toast-post-success-text').innerHTML = `@${name} banned`; + } + + xhr.send(fd); + } + }; + //reporting // Report Comment @@ -1336,6 +1361,22 @@ +{% if v %} +{% include "award_modal.html" %} +{% include "flag_post_modal.html" %} +{% include "flag_comment_modal.html" %} +{% include "gif_modal.html" %} +{% include "delete_comment_modal.html" %} +{% include "delete_post_modal.html" %} + +{% if v.admin_level > 1 %} +{% include "ban_modal.html" %} +{% endif %} + +{% endif %} + +{% include "expanded_image_modal.html" %} + diff --git a/files/templates/submission.html b/files/templates/submission.html index 3812a1c692..1ac5ea5e8e 100644 --- a/files/templates/submission.html +++ b/files/templates/submission.html @@ -179,7 +179,7 @@ {% endif %} {% if v and v.admin_level == 6 and v.id!=p.author_id %} - + {% endif %} @@ -489,7 +489,7 @@ {% endif %} {% if v.admin_level >=3 and v.id!=p.author_id %} -
  • Ban user
  • +
  • Ban user
  • Unban user
  • {% endif %} {% endif %} diff --git a/files/templates/submission_listing.html b/files/templates/submission_listing.html index 9c09dcb450..c5b0549b8e 100644 --- a/files/templates/submission_listing.html +++ b/files/templates/submission_listing.html @@ -208,7 +208,7 @@ {% endif %} {% if v.admin_level >=3 and v.id!=p.author_id %} -
  • Ban user
  • +
  • Ban user
  • Unban user
  • {% endif %} {% endif %} @@ -371,7 +371,7 @@ {% endif %} {% if v and v.admin_level == 6 and v.id!=p.author_id %} - + {% endif %}