1
0
Fork 0

Give admins option to test if a theme loads correctly

If a theme is uploaded incorrectly or has errors in it, users can still
select the theme but it will cause a 500 error on every page, making the
app unusable and also making it impossible for them to switch to a
functional theme.

A better fix would be to fail gracefully, but in lieu of that, this will
at least let admins confirm if a theme is broken safely.
This commit is contained in:
Mouse Reeve 2023-11-20 09:56:51 -08:00
parent 4da96d937e
commit d828ba0bc6
6 changed files with 88 additions and 1 deletions

View file

@ -12,6 +12,15 @@
{% endblock %}
{% block panel %}
{% if broken_theme %}
<div class="notification is-danger">
<span class="icon icon-warning" aria-hidden="true"></span>
<span>
{% trans "One of your themes appears to be broken. Selecting this theme will make the application unusable." %}
</span>
</div>
{% endif %}
{% if success %}
<div class="notification is-success is-light">
<span class="icon icon-check" aria-hidden="true"></span>
@ -98,6 +107,9 @@
<th>
{% trans "Actions" %}
</th>
<th>
{% trans "Status" %}
</th>
</tr>
{% for theme in themes %}
<tr>
@ -112,6 +124,37 @@
</button>
</form>
</td>
<td>
{% if theme.loads is None %}
<form method="POST" action="{% url 'settings-themes-test' theme.id %}">
{% csrf_token %}
<button type="submit" class="button is-small">
<span class="icon icon-question-circle" aria-hidden="true"></span>
<span>{% trans "Test theme" %}</span>
</button>
</form>
{% elif not theme.loads %}
<span class="tag is-danger">
<span class="icon icon-warning" aria-hidden="true"></span>
<span>
{% trans "Broken theme" %}
</span>
</span>
{% else %}
<span class="tag is-success">
<span class="icon icon-check" aria-hidden="true"></span>
<span>
{% trans "Loaded successfully" %}
</span>
</span>
{% endif %}
</td>
</tr>
{% endfor %}
</table>