Add ability to create bans from reports
This is done in the admin view and opens a new iframed window. The ban form is pretty barebones and doesn't have full functionality yet, but that is coming. Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
50
board/templates/board/ban_form.html
Normal file
50
board/templates/board/ban_form.html
Normal file
@@ -0,0 +1,50 @@
|
||||
{% extends "board/base.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
<form id="form" action="{% url 'board:ban_create' url=board.url id=post.id %}" method="post">
|
||||
{% csrf_token %}
|
||||
<table>
|
||||
<tr>
|
||||
<th>{% translate 'Post ID' %}:</th>
|
||||
<td>{{post.id}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{% translate 'Board' %}:</th>
|
||||
<td>{{board.url}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>IP:</th>
|
||||
<td>{{post.ip}}</td>
|
||||
</tr>
|
||||
{{form.as_table}}
|
||||
<tr>
|
||||
<th>{% translate "Previous bans" %}</th>
|
||||
<td>{{previous_bans|length}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{% translate "Current bans" %}</th>
|
||||
<td id="current_bans">{{current_bans|length}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td><input type="submit" id="submit" value="{% translate 'Create ban' %}" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
function submitConfirm(e) {
|
||||
console.log($("#current_bans").text());
|
||||
if($("#current_bans").text() !== '0') {
|
||||
let result = window.confirm("There is already at least one ban for this IP address on this board, are you sure you want to continue?");
|
||||
if (!result) {
|
||||
e.preventDefault();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$("#submit").on("click", submitConfirm);
|
||||
</script>
|
||||
{% endblock content %}
|
||||
29
board/templates/board/ban_success.html
Normal file
29
board/templates/board/ban_success.html
Normal file
@@ -0,0 +1,29 @@
|
||||
{% extends "board/base.html" %}
|
||||
{% load l10n %}
|
||||
{# Title #}
|
||||
{% block title %}{% localize on %}Ban success{% endlocalize %}{% endblock %}
|
||||
{# Body #}
|
||||
{% block content %}
|
||||
<div class="row" id="message">
|
||||
{% localize on %}A ban has been created. This window will close in 1 second.{% endlocalize %}
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function isIframe() {
|
||||
try {
|
||||
return window.self !== window.top;
|
||||
} catch (_) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
setTimeout(function() {
|
||||
if(isIframe()) {
|
||||
window.top.banWindow.close();
|
||||
} else {
|
||||
window.close();
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
</script>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user