Refine PHP settings and move checklist access to Support

This commit is contained in:
parkel committed 2026-12-01 02:04:33 +01:00
1 parent 621836ff1d
commit 63b73b4102
7 files changed
+76 -29

No files matched your search

@@ -0,0 +1,6 @@
{% extends "hosting/workspace_page.html" %}
{% block title %}Getting started · Coulobre Panel{% endblock %}
{% block page_title %}Getting started{% endblock %}
{% block page_content %}
{% include "hosting/workspace_onboarding.html" %}
{% endblock %}
@@ -2,25 +2,27 @@
<header class="section-heading"> <header class="section-heading">
<div> <div>
<h2 id="php-settings-heading">PHP settings</h2> <h2 id="php-settings-heading">PHP settings</h2>
{% if website_php_version %}<p class="heading-meta">Active version <strong>PHP {{ website_php_version }}</strong></p>{% endif %}
{% if website_php_version_job and website_php_version_job.finished_at is None %}
<p class="heading-meta">Changing to PHP {{ website_php_version_job.requested_version }}. Reload this page to check progress.</p>
{% elif website_php_version_job.problem %}
<p class="heading-meta">The change to PHP {{ website_php_version_job.requested_version }} needs attention.</p>
{% if is_operator %}<p class="heading-meta">{{ website_php_version_job.problem }}</p>{% endif %}
{% endif %}
{% if website_php_job.state == "queued" or website_php_job.state == "running" %} {% if website_php_job.state == "queued" or website_php_job.state == "running" %}
<p class="heading-meta">PHP settings update {{ website_php_job.state }}.</p> <p class="heading-meta">PHP settings update {{ website_php_job.state }}.</p>
{% elif can_change_php_settings and website_php_job.problem %} {% elif can_change_php_settings and website_php_job.problem %}
<p class="heading-meta">{{ website_php_job.problem }}</p> <p class="heading-meta">{{ website_php_job.problem }}</p>
{% endif %} {% endif %}
</div> </div>
{% if can_change_php_settings and website_php_job.state != "queued" and website_php_job.state != "running" %} <div class="form-actions">
<a class="button secondary" href="{% url 'panel:site_php_settings' account.pk %}">Change PHP settings</a> {% if can_change_php_version %}
{% endif %} <a class="button secondary" href="{% url 'panel:site_php_version' account.pk %}">Change PHP version</a>
{% endif %}
{% if can_change_php_settings and website_php_job.state != "queued" and website_php_job.state != "running" %}
<a class="button secondary" href="{% url 'panel:site_php_settings' account.pk %}">Change PHP settings</a>
{% endif %}
</div>
</header> </header>
{% if website_php_version %}<p>Active version <strong>PHP {{ website_php_version }}</strong></p>{% endif %}
{% if website_php_version_job and website_php_version_job.finished_at is None %}
<p>Changing to PHP {{ website_php_version_job.requested_version }}. Reload this page to check progress.</p>
{% elif website_php_version_job.problem %}
<p>The change to PHP {{ website_php_version_job.requested_version }} needs attention.</p>
{% if is_operator %}<p>{{ website_php_version_job.problem }}</p>{% endif %}
{% endif %}
{% if can_change_php_version %}
<a class="button secondary" href="{% url 'panel:site_php_version' account.pk %}">Change PHP version</a>
{% endif %}
{% include "hosting/php_setting_values.html" with limits=website_php_settings only %} {% include "hosting/php_setting_values.html" with limits=website_php_settings only %}
</section> </section>
@@ -1,18 +1,17 @@
{% if onboarding.dismissed %} {% if onboarding.steps or onboarding.enable_customer %}
<form method="post" action="{% url 'panel:onboarding_preference' %}" class="form-actions">
{% csrf_token %}
<button class="button secondary" name="action" value="show">Getting started</button>
</form>
{% elif onboarding.steps or onboarding.enable_customer %}
<section class="surface" aria-labelledby="onboarding-heading"> <section class="surface" aria-labelledby="onboarding-heading">
<header class="section-heading"> <header class="section-heading">
<h2 id="onboarding-heading">{{ onboarding.title }}</h2> <h2 id="onboarding-heading">{{ onboarding.title }}</h2>
<form method="post" action="{% url 'panel:onboarding_preference' %}"> <form method="post" action="{% url 'panel:onboarding_preference' %}">
{% csrf_token %} {% csrf_token %}
<button class="button secondary" name="action" value="dismiss">Dismiss checklist</button> {% if onboarding.dismissed %}
<button class="button secondary" name="action" value="show">Show on dashboard</button>
{% else %}
<button class="button secondary" name="action" value="dismiss">Dismiss checklist</button>
{% endif %}
</form> </form>
</header> </header>
<ul> <ul class="workspace-list">
{% for label, url, complete in onboarding.steps %} {% for label, url, complete in onboarding.steps %}
<li> <li>
{% if complete %}<span class="muted">Done · </span>{% endif %} {% if complete %}<span class="muted">Done · </span>{% endif %}
+17
View File
@@ -273,6 +273,7 @@ class WorkspaceTests(TestCase):
operator = get_user_model().objects.create_superuser("operator") operator = get_user_model().objects.create_superuser("operator")
device = TOTPDevice.objects.create(user=operator, name="Panel") device = TOTPDevice.objects.create(user=operator, name="Panel")
home = reverse("panel:accounts") home = reverse("panel:accounts")
support = reverse("panel:getting_started")
preference = reverse("panel:onboarding_preference") preference = reverse("panel:onboarding_preference")
enable = reverse("panel:enable_customer_workspace") enable = reverse("panel:enable_customer_workspace")
switch = reverse("panel:switch_panel_role") switch = reverse("panel:switch_panel_role")
@@ -294,6 +295,16 @@ class WorkspaceTests(TestCase):
self.assertTrue( self.assertTrue(
self.client.get(home).context["onboarding"]["dismissed"] self.client.get(home).context["onboarding"]["dismissed"]
) )
self.assertNotContains(
self.client.get(home), "Getting started as server administrator"
)
self.assertContains(
self.client.get(support), "Getting started as server administrator"
)
self.assertContains(self.client.get(support), "Show on dashboard")
self.assertTrue(
self.client.get(home).context["onboarding"]["dismissed"]
)
for role in ("manager", "customer"): for role in ("manager", "customer"):
self.assertRedirects( self.assertRedirects(
self.client.post(switch, {"role": role}), home self.client.post(switch, {"role": role}), home
@@ -301,6 +312,12 @@ class WorkspaceTests(TestCase):
self.assertContains( self.assertContains(
self.client.get(home), f"Getting started as {role}" self.client.get(home), f"Getting started as {role}"
) )
landing = self.client.get(support)
self.assertContains(landing, f"Getting started as {role}")
self.assertIn(
(support, "Getting started", "plans"),
dict(landing.context["navigation_groups"])["Support"],
)
self.assertEqual(self.client.post(enable).status_code, 403) self.assertEqual(self.client.post(enable).status_code, 403)
self.client.logout() self.client.logout()
self.client.force_login(operator) self.client.force_login(operator)
+2
View File
@@ -113,6 +113,7 @@ from .website_job_views import WebsiteJobEditor, WebsiteJobList
from .website_usage_views import WebsiteUsageView from .website_usage_views import WebsiteUsageView
from .workspace_onboarding import ( from .workspace_onboarding import (
enable_customer_workspace, enable_customer_workspace,
getting_started,
onboarding_preference, onboarding_preference,
) )
from .workspaces import customer_workspace, system_workspace from .workspaces import customer_workspace, system_workspace
@@ -315,6 +316,7 @@ urlpatterns = [
name="invitation_mail_settings", name="invitation_mail_settings",
), ),
path("account/role/", switch_panel_role, name="switch_panel_role"), path("account/role/", switch_panel_role, name="switch_panel_role"),
path("support/getting-started/", getting_started, name="getting_started"),
path( path(
"account/getting-started/", "account/getting-started/",
onboarding_preference, onboarding_preference,
+21 -4
View File
@@ -3,9 +3,10 @@ from django.contrib.auth.decorators import login_required
from django.core.exceptions import PermissionDenied from django.core.exceptions import PermissionDenied
from django.db import transaction from django.db import transaction
from django.http import HttpResponseBadRequest from django.http import HttpResponseBadRequest
from django.shortcuts import redirect from django.shortcuts import redirect, render
from django.urls import reverse from django.urls import reverse
from django.views.decorators.http import require_POST from django.views.decorators.cache import never_cache
from django.views.decorators.http import require_POST, require_safe
from .access import PanelRole, customer_for_user, reseller_for_user from .access import PanelRole, customer_for_user, reseller_for_user
from .account_administration import can_onboard_customer from .account_administration import can_onboard_customer
@@ -38,13 +39,16 @@ def customer_workspace_manager(user):
return reseller_for_user(user) return reseller_for_user(user)
def onboarding_context(request): def onboarding_context(request, *, show_dismissed=False):
role = workspace_role(request) role = workspace_role(request)
if role is None: if role is None:
return None return None
user = request.user user = request.user
title = f"Getting started as {ROLE_LABELS[role].lower()}" title = f"Getting started as {ROLE_LABELS[role].lower()}"
if OnboardingDismissal.objects.filter(user_id=user.pk, role=role).exists(): dismissed = OnboardingDismissal.objects.filter(
user_id=user.pk, role=role
).exists()
if dismissed and not show_dismissed:
return {"title": title, "dismissed": True} return {"title": title, "dismissed": True}
active = HostingAccount.objects.filter(retired_at__isnull=True) active = HostingAccount.objects.filter(retired_at__isnull=True)
@@ -133,9 +137,22 @@ def onboarding_context(request):
"steps": steps, "steps": steps,
"enable_customer": enable_customer, "enable_customer": enable_customer,
"role": role, "role": role,
"dismissed": dismissed,
} }
@login_required
@require_safe
@never_cache
def getting_started(request):
onboarding = onboarding_context(request, show_dismissed=True)
if onboarding is None:
raise PermissionDenied
return render(
request, "hosting/getting_started.html", {"onboarding": onboarding}
)
@login_required @login_required
@require_POST @require_POST
def onboarding_preference(request): def onboarding_preference(request):
+8 -4
View File
@@ -13,6 +13,7 @@ from .account_metrics import account_metrics
from .installation_features import panel_feature_allowed from .installation_features import panel_feature_allowed
from .models import HostingAccount, WebsiteScheduledJob from .models import HostingAccount, WebsiteScheduledJob
from .website_job_views import can_manage_website_jobs from .website_job_views import can_manage_website_jobs
from .workspace_onboarding import workspace_role
CUSTOMER_ACCOUNT = "coulobre_active_hosting_account" CUSTOMER_ACCOUNT = "coulobre_active_hosting_account"
@@ -61,6 +62,8 @@ CUSTOMER_NAV_ROUTES = {
"independent_website_files": "files", "independent_website_files": "files",
"mailbox_create": "email", "mailbox_create": "email",
"mailbox_credentials": "email", "mailbox_credentials": "email",
"mailbox_credential_rotation": "email",
"mailbox_quota": "email",
"mail_routing": "forwarders", "mail_routing": "forwarders",
"mail_vacation": "replies", "mail_vacation": "replies",
"mail_spam": "spam", "mail_spam": "spam",
@@ -287,6 +290,7 @@ NAVIGATION_ICONS = {
"service_health": "health", "service_health": "health",
"statistics": "chart", "statistics": "chart",
"installation": "information", "installation": "information",
"getting_started": "plans",
"tasks": "clock", "tasks": "clock",
"updates": "download", "updates": "download",
"directadmin_guide": "download", "directadmin_guide": "download",
@@ -451,8 +455,8 @@ def groups_for(request, *, customer, manager):
] ]
if user.is_superuser: if user.is_superuser:
system.append(link("updates", "Updates")) system.append(link("updates", "Updates"))
groups += [ support = [link("installation", "About Coulobre")]
("System", system), if workspace_role(request) is not None:
("Support", [link("installation", "About Coulobre")]), support.insert(0, link("getting_started", "Getting started"))
] groups += [("System", system), ("Support", support)]
return [(name, entries) for name, entries in groups if entries] return [(name, entries) for name, entries in groups if entries]