Refine PHP settings and move checklist access to Support
This commit is contained in:
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">
|
||||
<div>
|
||||
<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" %}
|
||||
<p class="heading-meta">PHP settings update {{ website_php_job.state }}.</p>
|
||||
{% elif can_change_php_settings and website_php_job.problem %}
|
||||
<p class="heading-meta">{{ website_php_job.problem }}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% 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 class="form-actions">
|
||||
{% if can_change_php_version %}
|
||||
<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>
|
||||
{% 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 %}
|
||||
</section>
|
||||
@@ -1,18 +1,17 @@
|
||||
{% if onboarding.dismissed %}
|
||||
<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 %}
|
||||
{% if onboarding.steps or onboarding.enable_customer %}
|
||||
<section class="surface" aria-labelledby="onboarding-heading">
|
||||
<header class="section-heading">
|
||||
<h2 id="onboarding-heading">{{ onboarding.title }}</h2>
|
||||
<form method="post" action="{% url 'panel:onboarding_preference' %}">
|
||||
{% 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>
|
||||
</header>
|
||||
<ul>
|
||||
<ul class="workspace-list">
|
||||
{% for label, url, complete in onboarding.steps %}
|
||||
<li>
|
||||
{% if complete %}<span class="muted">Done · </span>{% endif %}
|
||||
|
||||
@@ -273,6 +273,7 @@ class WorkspaceTests(TestCase):
|
||||
operator = get_user_model().objects.create_superuser("operator")
|
||||
device = TOTPDevice.objects.create(user=operator, name="Panel")
|
||||
home = reverse("panel:accounts")
|
||||
support = reverse("panel:getting_started")
|
||||
preference = reverse("panel:onboarding_preference")
|
||||
enable = reverse("panel:enable_customer_workspace")
|
||||
switch = reverse("panel:switch_panel_role")
|
||||
@@ -294,6 +295,16 @@ class WorkspaceTests(TestCase):
|
||||
self.assertTrue(
|
||||
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"):
|
||||
self.assertRedirects(
|
||||
self.client.post(switch, {"role": role}), home
|
||||
@@ -301,6 +312,12 @@ class WorkspaceTests(TestCase):
|
||||
self.assertContains(
|
||||
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.client.logout()
|
||||
self.client.force_login(operator)
|
||||
|
||||
@@ -113,6 +113,7 @@ from .website_job_views import WebsiteJobEditor, WebsiteJobList
|
||||
from .website_usage_views import WebsiteUsageView
|
||||
from .workspace_onboarding import (
|
||||
enable_customer_workspace,
|
||||
getting_started,
|
||||
onboarding_preference,
|
||||
)
|
||||
from .workspaces import customer_workspace, system_workspace
|
||||
@@ -315,6 +316,7 @@ urlpatterns = [
|
||||
name="invitation_mail_settings",
|
||||
),
|
||||
path("account/role/", switch_panel_role, name="switch_panel_role"),
|
||||
path("support/getting-started/", getting_started, name="getting_started"),
|
||||
path(
|
||||
"account/getting-started/",
|
||||
onboarding_preference,
|
||||
|
||||
@@ -3,9 +3,10 @@ from django.contrib.auth.decorators import login_required
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.db import transaction
|
||||
from django.http import HttpResponseBadRequest
|
||||
from django.shortcuts import redirect
|
||||
from django.shortcuts import redirect, render
|
||||
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 .account_administration import can_onboard_customer
|
||||
@@ -38,13 +39,16 @@ def customer_workspace_manager(user):
|
||||
return reseller_for_user(user)
|
||||
|
||||
|
||||
def onboarding_context(request):
|
||||
def onboarding_context(request, *, show_dismissed=False):
|
||||
role = workspace_role(request)
|
||||
if role is None:
|
||||
return None
|
||||
user = request.user
|
||||
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}
|
||||
|
||||
active = HostingAccount.objects.filter(retired_at__isnull=True)
|
||||
@@ -133,9 +137,22 @@ def onboarding_context(request):
|
||||
"steps": steps,
|
||||
"enable_customer": enable_customer,
|
||||
"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
|
||||
@require_POST
|
||||
def onboarding_preference(request):
|
||||
|
||||
@@ -13,6 +13,7 @@ from .account_metrics import account_metrics
|
||||
from .installation_features import panel_feature_allowed
|
||||
from .models import HostingAccount, WebsiteScheduledJob
|
||||
from .website_job_views import can_manage_website_jobs
|
||||
from .workspace_onboarding import workspace_role
|
||||
|
||||
CUSTOMER_ACCOUNT = "coulobre_active_hosting_account"
|
||||
|
||||
@@ -61,6 +62,8 @@ CUSTOMER_NAV_ROUTES = {
|
||||
"independent_website_files": "files",
|
||||
"mailbox_create": "email",
|
||||
"mailbox_credentials": "email",
|
||||
"mailbox_credential_rotation": "email",
|
||||
"mailbox_quota": "email",
|
||||
"mail_routing": "forwarders",
|
||||
"mail_vacation": "replies",
|
||||
"mail_spam": "spam",
|
||||
@@ -287,6 +290,7 @@ NAVIGATION_ICONS = {
|
||||
"service_health": "health",
|
||||
"statistics": "chart",
|
||||
"installation": "information",
|
||||
"getting_started": "plans",
|
||||
"tasks": "clock",
|
||||
"updates": "download",
|
||||
"directadmin_guide": "download",
|
||||
@@ -451,8 +455,8 @@ def groups_for(request, *, customer, manager):
|
||||
]
|
||||
if user.is_superuser:
|
||||
system.append(link("updates", "Updates"))
|
||||
groups += [
|
||||
("System", system),
|
||||
("Support", [link("installation", "About Coulobre")]),
|
||||
]
|
||||
support = [link("installation", "About Coulobre")]
|
||||
if workspace_role(request) is not None:
|
||||
support.insert(0, link("getting_started", "Getting started"))
|
||||
groups += [("System", system), ("Support", support)]
|
||||
return [(name, entries) for name, entries in groups if entries]
|
||||
Reference in new issue
Block a user