Show installation details to server administrators

This commit is contained in:
parkel committed 2026-11-22 22:23:55 +01:00
1 parent 897cf498ce
commit 1199810257
6 files changed
+143 -3

No files matched your search

@@ -0,0 +1,60 @@
from importlib.metadata import PackageNotFoundError, version
from django.conf import settings
from django.contrib.auth.mixins import PermissionRequiredMixin
from django.utils.decorators import method_decorator
from django.views.decorators.cache import never_cache
from django.views.generic import TemplateView
from .access import OperatorOnlyMixin
@method_decorator(never_cache, name="dispatch")
class InstallationView(
OperatorOnlyMixin, PermissionRequiredMixin, TemplateView
):
permission_required = "hosting.view_servicehealth"
template_name = "hosting/installation.html"
def get_context_data(self, **kwargs):
try:
installed_version = version("coulobre-panel")
except PackageNotFoundError:
installed_version = "Unavailable"
features = (
("Local website provisioning", settings.LOCAL_WEB_ACTIVATION),
("Managed website certificates", settings.LOCAL_WEB_HTTPS),
("Website file manager", settings.WEB_FILE_MANAGER),
("Website scheduled tasks", settings.WEBSITE_JOBS),
("Local DNS publishing", settings.LOCAL_DNS_PUBLISHING),
(
"Default managed DNS zones for new accounts",
settings.LOCAL_DNS_PUBLISHING
and settings.HOSTING_NAMESERVERS
and settings.HOSTING_PUBLIC_ADDRESSES,
),
(
"Local mailbox provisioning",
settings.LOCAL_MAILBOX_PROVISIONING,
),
("Managed mail DNS records", settings.MANAGE_MAIL_DNS),
(
"Local database provisioning",
settings.LOCAL_DATABASE_PROVISIONING,
),
("Local account backups", settings.LOCAL_ACCOUNT_BACKUPS),
(
"Off-site backup destinations",
settings.OFFSITE_BACKUP_DESTINATIONS,
),
("phpMyAdmin sign-in", settings.PHPMYADMIN_URL),
("Roundcube sign-in", settings.ROUNDCUBE_URL),
)
return super().get_context_data(
installed_version=installed_version,
features=[
(name, bool(configured)) for name, configured in features
],
**kwargs,
)
@@ -273,6 +273,14 @@ button, input, select, textarea {
linear-gradient(currentColor, currentColor) 75% bottom / 1px 55% no-repeat;
}
.nav-icon-information {
display: grid;
place-content: center;
border-radius: 50%;
font-size: 0.7rem;
font-weight: 700;
}
.nav-icon-customers {
position: relative;
height: 0.46rem;
@@ -52,8 +52,8 @@
</a>
{% endif %}
{% if group_customer_navigation %}</details>{% endif %}
{% if is_operator and perms.hosting.view_webprovisioningplan and perms.hosting.view_servicehealth %}
<details class="sidebar-group"{% if panel_section == 'plans' or panel_section == 'service_health' %} open{% endif %}>
{% if is_operator and perms.hosting.view_servicehealth %}
<details class="sidebar-group"{% if panel_section == 'plans' or panel_section == 'service_health' or panel_section == 'installation' %} open{% endif %}>
<summary>Server and services</summary>
{% endif %}
{% if is_reseller or is_operator and perms.hosting.view_webprovisioningplan %}
@@ -67,8 +67,12 @@
<span class="nav-icon nav-icon-health" aria-hidden="true"></span>
Service health
</a>
<a href="{% url 'panel:installation' %}"{% if current == 'installation' %} aria-current="page"{% endif %}>
<span class="nav-icon nav-icon-information" aria-hidden="true">i</span>
About Coulobre
</a>
</details>
{% endif %}
{% if is_operator and perms.hosting.view_webprovisioningplan and perms.hosting.view_servicehealth %}</details>{% endif %}
{% endwith %}
</nav>
<div class="sidebar-account">
@@ -0,0 +1,35 @@
{% extends "hosting/base.html" %}
{% block title %}About Coulobre · Coulobre Panel{% endblock %}
{% block content %}
<header class="page-heading"><h1>About Coulobre</h1></header>
<section class="surface" aria-labelledby="installation-heading">
<header class="section-heading"><h2 id="installation-heading">Installation</h2></header>
<dl class="details">
<div><dt>Installed version</dt><dd>{{ installed_version }}</dd></div>
<div><dt>Core software license</dt><dd>Apache License 2.0</dd></div>
</dl>
</section>
<section class="surface" aria-labelledby="features-heading">
<header class="section-heading">
<div>
<h2 id="features-heading">Feature configuration</h2>
<p class="muted">See <a href="{% url 'panel:service_health' %}">Service health</a> for the latest local and remote checks.</p>
</div>
</header>
<div class="table-scroll">
<table>
<thead><tr><th scope="col">Feature</th><th scope="col">Configuration</th></tr></thead>
<tbody>
{% for name, enabled in features %}
<tr>
<th scope="row">{{ name }}</th>
<td>{% if enabled %}<span class="status active">Enabled</span>{% else %}Disabled{% endif %}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</section>
{% endblock %}
@@ -165,6 +165,37 @@ class ServiceHealthPanelTests(TestCase):
self.client.force_login(user)
self.assertEqual(self.client.get(url).status_code, status)
@override_settings(
LOCAL_DNS_PUBLISHING=True,
HOSTING_NAMESERVERS=("ns.example.net",),
HOSTING_PUBLIC_ADDRESSES=("192.0.2.20",),
ROUNDCUBE_URL="https://webmail.example.net",
ROUNDCUBE_BRIDGE_KEY="test-only-bridge-key",
)
def test_installation_reports_configuration_to_operators(self):
url = reverse("panel:installation")
self.assertRedirects(
self.client.get(url), f"{reverse('panel:login')}?next={url}"
)
for user in (self.viewer, self.customer, self.reseller):
with self.subTest(user=user):
self.client.force_login(user)
self.assertEqual(self.client.get(url).status_code, 403)
self.client.force_login(self.operator)
with patch(
"coulobre.hosting.installation_views.version", return_value="1.2.3"
):
response = self.client.get(url)
self.assertContains(response, "1.2.3")
self.assertContains(response, "Apache License 2.0")
self.assertContains(response, reverse("panel:service_health"))
features = dict(response.context["features"])
self.assertTrue(features["Default managed DNS zones for new accounts"])
self.assertTrue(features["Roundcube sign-in"])
self.assertNotContains(response, "test-only-bridge-key")
self.assertNotContains(response, "https://webmail.example.net")
def test_view_marks_missing_and_old_observations_distinctly(self):
now = timezone.now()
for node, service, result, observed_at in (
+2
View File
@@ -11,6 +11,7 @@ from .independent_website_views import (
IndependentWebsiteManifest,
IndependentWebsiteOperation,
)
from .installation_views import InstallationView
from .invitations import AcceptInvitation, ManageInvitation
from .mail_dns_views import MailDnsCheckView, RequestMailDnsSetup
from .mail_policy_views import MailRoutingEditor, MailVacationEditor
@@ -67,6 +68,7 @@ urlpatterns = [
path(
"service-health/", ServiceHealthView.as_view(), name="service_health"
),
path("about/", InstallationView.as_view(), name="installation"),
path("sign-in/", PanelLoginView.as_view(), name="login"),
path(
"welcome/<uidb64>/<token>/",