Update PostModifyForm to use permissions to create its fields
Fields are only displayed via the PostModifyForm if the user has specific permissions to do things, like set stickies. Also, add PostModifySuccessView that will close the modify window when the process is complete. Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -12,8 +12,11 @@
|
||||
<script src="{% static 'board/jquery.js' %}"></script>
|
||||
<script src="{% static 'board/jsframe.min.js' %}"></script>
|
||||
<script src="{% static 'board/post.js' %}"></script>
|
||||
{% if perms.board.create_ban %}
|
||||
<script src="{% static 'board/ban_window.js' %}"></script>
|
||||
{% if perms.board.add_ban %}
|
||||
<script src="{% static 'board/ban.js' %}"></script>
|
||||
{% endif %}
|
||||
{% if can_modify %}
|
||||
<script src="{% static 'board/modify.js' %}"></script>
|
||||
{% endif %}
|
||||
{% block extrajs %}{% endblock %}
|
||||
</head>
|
||||
|
||||
33
board/templates/board/post_modify_success.html
Normal file
33
board/templates/board/post_modify_success.html
Normal file
@@ -0,0 +1,33 @@
|
||||
{% extends "board/base.html" %}
|
||||
{% load i18n static %}
|
||||
{# Title #}
|
||||
{% block title %}{% translate "Post modify success" %}{% endblock %}
|
||||
{# Body #}
|
||||
{% block content %}
|
||||
<div class="row" id="message">
|
||||
{# We do not use pluralize filter for "seconds" because it's a pain to get it to translate. #}
|
||||
{% blocktranslate %}Post has been modified. This window will close in {{window_timeout}} second(s).{% endblocktranslate %}
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function isIframe() {
|
||||
try {
|
||||
return window.self !== window.top;
|
||||
} catch (_) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
setTimeout(function() {
|
||||
if(isIframe()) {
|
||||
let modifyWindow = getModifyWindow();
|
||||
if(modifyWindow) {
|
||||
modifyWindow.closeFrame();
|
||||
}
|
||||
} else {
|
||||
window.close();
|
||||
}
|
||||
}, 1000 * {{window_timeout}});
|
||||
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -5,7 +5,7 @@
|
||||
<form method="post" action="{% url 'board:post_modify' post.id %}">
|
||||
{% csrf_token %}
|
||||
<table>
|
||||
{% if perms.board.can_sticky %}
|
||||
{% if perms.board.set_sticky %}
|
||||
<tr>
|
||||
<th>{{form.sticky.label_tag}}</th>
|
||||
<td>{{form.sticky}}</td>
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
<div
|
||||
id="p{{post.id}}"
|
||||
data-report-url="{% url 'board:report_form' board.url post.id %}"
|
||||
{% if perms.board.create_ban %}
|
||||
{% if perms.board.add_ban %}
|
||||
data-ban-url="{% url 'board:ban_create' board.url post.id %}"
|
||||
{% endif %}
|
||||
{% if perms.board.can_sticky %}
|
||||
{% if can_modify %}
|
||||
data-modify-url="{% url 'board:post_modify' post.id %}"
|
||||
{% endif %}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user