diff --git a/templates/400.html b/templates/400.html new file mode 100644 index 00000000..827dfb31 --- /dev/null +++ b/templates/400.html @@ -0,0 +1,13 @@ +{% extends "error.html" %} +{% load i18n %} + +{% block title %}{% trans "Bad request" %}{% endblock %} +{% block code %}400{% endblock %} +{% block status_classes %}text-bg-warning{% endblock %} +{% block icon %}bi-exclamation-triangle{% endblock %} +{% block heading %}{% trans "Bad request" %}{% endblock %} + +{% block text %} +
{% trans "The panel could not accept this request." %}
+{% trans "If the panel was opened at a new address, an administrator must add that address to ALLOWED_HOSTS." %}
+{% endblock %} diff --git a/templates/403.html b/templates/403.html index 6b0a7e8a..86519c6a 100644 --- a/templates/403.html +++ b/templates/403.html @@ -1,15 +1,12 @@ -{% extends "base.html" %} +{% extends "error.html" %} {% load i18n %} -{% block title %}{% trans "403" %}{% endblock %} -{% block content %} -{% trans "403 Forbidden" %}
+{% block title %}{% trans "Access denied" %}{% endblock %} +{% block code %}403{% endblock %} +{% block status_classes %}text-bg-warning{% endblock %} +{% block icon %}bi-shield-lock{% endblock %} +{% block heading %}{% trans "Access denied" %}{% endblock %} -{% trans "You do not have permission to access this page." %}
- ← {% trans 'Back'%} -{% trans "Your account does not have the permission for this page or action. Ask an administrator for it." %}
{% endblock %} diff --git a/templates/403_csrf.html b/templates/403_csrf.html new file mode 100644 index 00000000..77e52c6a --- /dev/null +++ b/templates/403_csrf.html @@ -0,0 +1,14 @@ +{% extends "error.html" %} +{% load i18n %} + +{% block title %}{% trans "Form could not be submitted" %}{% endblock %} +{% block code %}403{% endblock %} +{% block status_classes %}text-bg-warning{% endblock %} +{% block icon %}bi-shield-exclamation{% endblock %} +{% block heading %}{% trans "Form could not be submitted" %}{% endblock %} + +{% block text %} +{% trans "This submission was rejected because its security check failed. It usually happens when the page was open for a long time, or after signing in or out in another tab." %}
+{% trans "Go back, reload the page and submit the form again." %}
+{% trans "If it happens on every form, the browser may block cookies, or the panel's proxy or address settings may be wrong. The reason is written to the panel's log." %}
+{% endblock %} diff --git a/templates/404.html b/templates/404.html index dd42e10f..7f4dd90a 100644 --- a/templates/404.html +++ b/templates/404.html @@ -1,15 +1,13 @@ -{% extends "base.html" %} +{% extends "error.html" %} {% load i18n %} -{% block title %}{% trans "404" %}{% endblock %} -{% block content %} -{% trans "404 Not Found" %}
+{% block title %}{% trans "Page not found" %}{% endblock %} +{% block code %}404{% endblock %} +{% block status_classes %}text-bg-secondary{% endblock %} +{% block icon %}bi-file-earmark-x{% endblock %} +{% block heading %}{% trans "Page not found" %}{% endblock %} -{% trans "The requested page was not found on this server." %}
- ← {% trans 'Back'%} -{% blocktrans with path=request_path %}Nothing was found at {{ path }}, or your account cannot see it.{% endblocktrans %}
{% trans "The virtual machine or host may have been deleted, or the link is wrong." %}
{% endblock %} diff --git a/templates/500.html b/templates/500.html index e8f1e569..451d86ab 100644 --- a/templates/500.html +++ b/templates/500.html @@ -1,15 +1,18 @@ -{% extends "base.html" %} +{% extends "error.html" %} {% load i18n %} -{% block title %}{% trans "500" %}{% endblock %} -{% block content %} -{% trans "500 Internal Server Error" %}
+{% block title %}{% if libvirt_error %}{% trans "Could not load data from the host" %}{% else %}{% trans "Server error" %}{% endif %}{% endblock %} +{% block code %}500{% endblock %} +{% block status_classes %}text-bg-danger{% endblock %} +{% block icon %}{% if libvirt_error %}bi-hdd-network{% else %}bi-exclamation-octagon{% endif %}{% endblock %} +{% block heading %}{% if libvirt_error %}{% trans "Could not load data from the host" %}{% else %}{% trans "Server error" %}{% endif %}{% endblock %} -{% trans "The server encountered an internal error or misconfiguration and was unable to complete you request." %}
- ← {% trans 'Back'%} -{% trans "This page needs data from the host, and libvirt returned the error shown above." %}
+{% trans "Check that the host is running and reachable, then reload the page." %}
+ {% else %} +{% trans "The panel failed while handling this request. This is a fault in the panel, not something you did, and it was written to the panel's log." %}
+{% now "Y-m-d H:i:s" as now %}{% blocktrans %}Reload the page to try again. If it keeps happening, tell an administrator the time: {{ now }}.{% endblocktrans %}
+ {% endif %} {% endblock %} diff --git a/templates/error.html b/templates/error.html new file mode 100644 index 00000000..d360274e --- /dev/null +++ b/templates/error.html @@ -0,0 +1,39 @@ +{% extends "base.html" %} +{% load i18n %} + +{% block content %} +/no/such/page/", status_code=404)
+
+ def test_the_reason_of_a_not_found_is_not_shown(self):
+ response = page_not_found(RequestFactory().get("/datasource/"), Http404("libvirt detail of the host"))
+ self.assertNotIn(b"libvirt detail", response.content)
+
+ def test_a_server_error_renders_without_a_request_context(self):
+ response = server_error(RequestFactory().get("/"))
+ self.assertContains(response, "Server error", status_code=500)
+ self.assertContains(response, "tell an administrator the time", status_code=500)