mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-10 12:16:49 +00:00
feat: error pages that say what happened and what to do
The 403, 404 and 500 pages said "Oops!" and one generic sentence; a bad request and a failed CSRF check fell back to Django's plain pages. Every error page now shares templates/error.html: a card with the status in a coloured badge with an icon, a heading in plain words, what happened and what to do, and Back and Home buttons. It uses only theme-defined Bootstrap classes, so it reads in the light and dark themes alike. - 400: the request was not accepted; a new address belongs in ALLOWED_HOSTS. - 403: the account lacks the permission; ask an administrator. - 403 CSRF: the form's security check failed; reload and submit again, and where to look when it happens on every form. - 404: the path, and that the object may be gone or hidden from the account. - 500: a libvirt failure on a page says the host's data could not be loaded, under libvirt's message; any other failure says it was logged and shows the time to give an administrator.
This commit is contained in:
parent
c3c84d780c
commit
10eb0d1c2e
8 changed files with 140 additions and 33 deletions
39
templates/error.html
Normal file
39
templates/error.html
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
{% extends "base.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row justify-content-center py-3 py-sm-4">
|
||||
<div class="col-12 col-lg-10">
|
||||
<section class="card shadow-sm" aria-labelledby="error-heading">
|
||||
<div class="card-body p-4 p-sm-5">
|
||||
<div class="mb-3">
|
||||
<span class="badge d-inline-flex align-items-center gap-2 rounded-pill fs-6 px-3 py-2 {% block status_classes %}text-bg-secondary{% endblock %}">
|
||||
<i class="bi {% block icon %}bi-exclamation-circle{% endblock %}" aria-hidden="true"></i>
|
||||
<span class="font-monospace">
|
||||
<span class="visually-hidden">{% trans "HTTP status" %} </span>
|
||||
{% block code %}{% endblock %}
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<h1 id="error-heading" class="h3 mb-3">{% block heading %}{% endblock %}</h1>
|
||||
|
||||
<div class="text-break">
|
||||
{% block text %}{% endblock %}
|
||||
</div>
|
||||
|
||||
<div class="d-grid d-sm-flex gap-2 mt-4">
|
||||
<a class="btn btn-primary" href="javascript:history.back()">
|
||||
<i class="bi bi-arrow-left me-1" aria-hidden="true"></i>
|
||||
{% trans "Back" %}
|
||||
</a>
|
||||
<a class="btn btn-secondary" href="{% url 'index' %}">
|
||||
<i class="bi bi-house me-1" aria-hidden="true"></i>
|
||||
{% trans "Home" %}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
Loading…
Add table
Add a link
Reference in a new issue