feat: edit pre-existing bans (#528)

* feat: edit pre-existing bans

* change default permission

* theres no need for elseif here. related: d34f083a6b33185927c6b79a38477f4ea4ce49b5

* quote href param

* changes made
This commit is contained in:
perdedora
2023-01-13 01:38:23 +00:00
committed by GitHub
parent 46b29de7ff
commit b02a1fc0db
9 changed files with 170 additions and 79 deletions

View File

@@ -1,5 +1,7 @@
{% if post and board %}
{% set action = '?/' ~ board ~ '/ban/' ~ post %}
{% elseif edit_ban %}
{% set action = '' %}
{% else %}
{% set action = '?/ban' %}
{% endif %}
@@ -14,7 +16,7 @@
{% endif %}
<table>
{% if not edit_ban %}
<tr>
<th>
<label for="ip">{% trans 'IP' %} <span class="unimportant">{% trans '(or subnet)' %}</span></label>
@@ -27,6 +29,7 @@
{% endif %}
</td>
</tr>
{% endif %}
<tr>
<th>
<label for="reason">{% trans 'Reason' %}</label>
@@ -66,7 +69,7 @@
<td>
<ul style="list-style:none;padding:2px 5px">
<li>
<input type="radio" name="board" value="*" id="ban-allboards" checked>
<input type="radio" name="board" value="*" id="ban-allboards" {% if (edit_ban and not current_board) or not edit_ban %}checked{% endif %}>
<label style="display:inline" for="ban-allboards">
<em>{% trans 'all boards' %}</em>
</label>
@@ -74,7 +77,7 @@
{% for board in boards %}
<li>
<input type="radio" name="board" value="{{ board.uri }}" id="ban-board-{{ board.uri }}">
<input type="radio" name="board" value="{{ board.uri }}" id="ban-board-{{ board.uri }}" {% if edit_ban and current_board == board.uri %}checked{% endif %}>
<label style="display:inline" for="ban-board-{{ board.uri }}">
{{ config.board_abbreviation|sprintf(board.uri) }} - {{ board.title|e }}
</label>
@@ -85,7 +88,7 @@
</tr>
<tr>
<td></td>
<td><input name="new_ban" type="submit" value="{% trans 'New Ban' %}"></td>
<td><input name="new_ban" type="submit" value="{% if edit_ban %}{% trans 'Edit Ban' %}{% else %}{% trans 'New Ban' %}{% endif %}"></td>
</tr>
</table>
</form>

View File

@@ -0,0 +1,70 @@
<table style="width:400px;margin-bottom:10px;border-bottom:1px solid #ddd;padding:5px">
<tr>
<th>{% trans 'Status' %}</th>
<td>
{% if config.mod.view_banexpired and ban.expires != 0 and ban.expires < time() %}
{% trans 'Expired' %}
{% else %}
{% trans 'Active' %}
{% endif %}
</td>
</tr>
<tr>
<th>{% trans 'IP' %}</th>
<td>{{ ban.cmask }}</td>
</tr>
<tr>
<th>{% trans 'Reason' %}</th>
<td>
{% if ban.reason %}
{{ ban.reason }}
{% else %}
<em>{% trans 'no reason' %}</em>
{% endif %}
</td>
</tr>
<tr>
<th>{% trans 'Board' %}</th>
<td>
{% if ban.board %}
{{ config.board_abbreviation|sprintf(ban.board) }}
{% else %}
<em>{% trans 'all boards' %}</em>
{% endif %}
</td>
</tr>
<tr>
<th>{% trans 'Set' %}</th>
<td>{{ ban.created|date(config.post_date) }}</td>
</tr>
<tr>
<th>{% trans 'Expires' %}</th>
<td>
{% if ban.expires %}
{{ ban.expires|date(config.post_date) }}
{% else %}
<em>{% trans 'never' %}</em>
{% endif %}
</td>
</tr>
<tr>
<th>{% trans 'Seen' %}</th>
<td>
{% if ban.seen %}
{% trans 'Yes' %}
{% else %}
{% trans 'No' %}
{% endif %}
</td>
</tr>
<tr>
<th>{% trans 'Staff' %}</th>
<td>
{% if ban.username %}
{{ ban.username|e }}
{% else %}
<em>{% trans 'deleted?' %}</em>
{% endif %}
</td>
</tr>
</table>

View File

@@ -0,0 +1,14 @@
<p style="text-align: center">
{% trans %}The previous ban will be replaced by the edited ban and the ban duration will start from the time of the edit.<br/>
The ban public message will <strong>not</strong> be changed.{% endtrans %}
</p>
<hr>
{% for ban in bans %}
<h2 style="text-align:center">{% trans %}Current ban{% endtrans %}</h2>
<form style="text-align:center; margin-bottom: unset"> {# dummy form to trigger css rules #}
{% include 'mod/ban_history.html' %}
</form>
<hr>
<h2 style="text-align:center">{% trans %}New ban{% endtrans %}</h2>
{% include 'mod/ban_form.html' with {'edit_ban': true} %}
{% endfor %}

View File

@@ -167,78 +167,10 @@
{% for ban in bans %}
<form action="" method="post" style="text-align:center">
<input type="hidden" name="token" value="{{ security_token }}">
<table style="width:400px;margin-bottom:10px;border-bottom:1px solid #ddd;padding:5px">
<tr>
<th>{% trans 'Status' %}</th>
<td>
{% if config.mod.view_banexpired and ban.expires != 0 and ban.expires < time() %}
{% trans 'Expired' %}
{% else %}
{% trans 'Active' %}
{% endif %}
</td>
</tr>
<tr>
<th>{% trans 'IP' %}</th>
<td>{{ ban.cmask }}</td>
</tr>
<tr>
<th>{% trans 'Reason' %}</th>
<td>
{% if ban.reason %}
{{ ban.reason }}
{% else %}
<em>{% trans 'no reason' %}</em>
{% endif %}
</td>
</tr>
<tr>
<th>{% trans 'Board' %}</th>
<td>
{% if ban.board %}
{{ config.board_abbreviation|sprintf(ban.board) }}
{% else %}
<em>{% trans 'all boards' %}</em>
{% endif %}
</td>
</tr>
<tr>
<th>{% trans 'Set' %}</th>
<td>{{ ban.created|date(config.post_date) }}</td>
</tr>
<tr>
<th>{% trans 'Expires' %}</th>
<td>
{% if ban.expires %}
{{ ban.expires|date(config.post_date) }}
{% else %}
<em>{% trans 'never' %}</em>
{% endif %}
</td>
</tr>
<tr>
<th>{% trans 'Seen' %}</th>
<td>
{% if ban.seen %}
{% trans 'Yes' %}
{% else %}
{% trans 'No' %}
{% endif %}
</td>
</tr>
<tr>
<th>{% trans 'Staff' %}</th>
<td>
{% if ban.username %}
{{ ban.username|e }}
{% else %}
<em>{% trans 'deleted?' %}</em>
{% endif %}
</td>
</tr>
</table>
{% include 'mod/ban_history.html' %}
<input type="hidden" name="ban_id" value="{{ ban.id }}">
<input type="submit" name="unban" value="{% trans 'Remove ban' %}">
<input type="submit" name="edit_ban" value="{% trans 'Edit ban' %}">
</form>
{% endfor %}
</fieldset>