Add the Coulobre operator interface

Provide a responsive sign-in flow, hosting account management, and
Apache preview requests and status pages.
This commit is contained in:
parkel committed 2026-11-19 21:30:25 +01:00
1 parent 84d94f7efa
commit 64ee6ddcba
22 files changed
+1085 -14

No files matched your search

+95
View File
@@ -0,0 +1,95 @@
from django.contrib.auth.mixins import PermissionRequiredMixin
from django.db.models import Q
from django.shortcuts import redirect
from django.views import View
from django.views.generic import CreateView, DetailView, ListView, UpdateView
from django.views.generic.detail import SingleObjectMixin
from .models import HostingAccount, WebProvisioningPlan
VIEW_ACCOUNTS = "hosting.view_hostingaccount"
CHANGE_ACCOUNTS = "hosting.change_hostingaccount"
VIEW_PLANS = "hosting.view_webprovisioningplan"
class AccountList(PermissionRequiredMixin, ListView):
model = HostingAccount
permission_required = VIEW_ACCOUNTS
template_name = "hosting/account_list.html"
context_object_name = "accounts"
paginate_by = 20
def get_queryset(self):
self.search = self.request.GET.get("q", "").strip()[:253]
accounts = HostingAccount.objects.order_by("primary_domain")
if self.search:
accounts = accounts.filter(
Q(name__icontains=self.search)
| Q(primary_domain__icontains=self.search)
)
return accounts
def get_context_data(self, **kwargs):
return super().get_context_data(search=self.search, **kwargs)
class AccountCreate(PermissionRequiredMixin, CreateView):
model = HostingAccount
permission_required = (VIEW_ACCOUNTS, "hosting.add_hostingaccount")
template_name = "hosting/account_form.html"
fields = ("name", "primary_domain")
extra_context = {"page_title": "Add hosting account", "submit_label": "Add account"}
class AccountEdit(PermissionRequiredMixin, UpdateView):
model = HostingAccount
permission_required = (VIEW_ACCOUNTS, CHANGE_ACCOUNTS)
template_name = "hosting/account_form.html"
context_object_name = "account"
fields = ("name", "primary_domain")
extra_context = {
"page_title": "Edit hosting account",
"submit_label": "Save changes",
}
class AccountDetail(PermissionRequiredMixin, DetailView):
model = HostingAccount
permission_required = VIEW_ACCOUNTS
template_name = "hosting/account_detail.html"
context_object_name = "account"
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
if self.request.user.has_perm(VIEW_PLANS):
context["plans"] = self.object.webprovisioningplan_set.order_by(
"-requested_at", "-pk"
)[:10]
return context
class RequestWebPlan(PermissionRequiredMixin, SingleObjectMixin, View):
model = HostingAccount
permission_required = (VIEW_ACCOUNTS, CHANGE_ACCOUNTS, VIEW_PLANS)
def post(self, request, *args, **kwargs):
plan = WebProvisioningPlan.for_account(self.get_object())
plan.save()
return redirect("panel:plan", pk=plan.pk)
class PlanList(PermissionRequiredMixin, ListView):
queryset = WebProvisioningPlan.objects.select_related("account").order_by(
"-requested_at", "-pk"
)
permission_required = VIEW_PLANS
template_name = "hosting/plan_list.html"
context_object_name = "plans"
paginate_by = 20
class PlanDetail(PermissionRequiredMixin, DetailView):
queryset = WebProvisioningPlan.objects.select_related("account")
permission_required = VIEW_PLANS
template_name = "hosting/plan_detail.html"
context_object_name = "plan"