Add ActionSuccessView

ActionSuccessView is a a generic view that indicates that something was
successful, e.g. deleting a post or banning a user. This hopefully
reduces the amount of boilerplate code used for creating success pages
since most of them can derive from this generic view.

The report and delete success views are updated to use this directly.

The ban and modify success views are updated to derive from this class,
with special permissions required.

The post success view is updated to derive from this class, using a
different template.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2022-07-17 15:08:33 -07:00
parent bfd3dedb09
commit e686c3b235
9 changed files with 78 additions and 112 deletions

View File

@@ -0,0 +1,23 @@
{% extends "board/base.html" %}
{% load i18n static %}
{# Title #}
{% block title %}{% translate "Action success" %}{% endblock %}
{# Body #}
{% block content %}
<div class="row" id="message">
{{message}}
{# We do not use pluralize filter for "seconds" because it's a pain to get it to translate. #}
{% blocktranslate %}This window will close in {{window_timeout}} second(s).{% endblocktranslate %}
</div>
<script>
setTimeout(function() {
if(typeof thisWindow !== "undefined") {
thisWindow.closeFrame();
} else {
window.close();
}
}, 1000 * {{window_timeout}});
</script>
{% endblock %}

View File

@@ -1,33 +0,0 @@
{% extends "board/base.html" %}
{% load i18n static %}
{# Title #}
{% block title %}{% translate "Post delete 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 %}Delete successful. 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 deleteWindow = getDeleteWindow();
if(deleteWindow) {
deleteWindow.closeFrame();
}
} else {
window.close();
}
}, 1000 * {{window_timeout}});
</script>
{% endblock %}

View File

@@ -1,33 +0,0 @@
{% extends "board/base.html" %}
{% load i18n static %}
{# Title #}
{% block title %}{% translate "Report 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 reported. 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 reportWindow = getReportWindow();
if(reportWindow) {
reportWindow.closeFrame();
}
} else {
window.close();
}
}, 1000 * {{window_timeout}});
</script>
{% endblock %}