diff --git a/.gitignore b/.gitignore
index d16515a..a3b83a9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,3 +19,4 @@ dist/
*.sqlite3-journal
*.sqlite3-shm
*.sqlite3-wal
+celerybeat-schedule*
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 7167387..d00ab45 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -2,6 +2,8 @@
- Use Gitea issues for work items and milestones for release planning.
- Start changes on a dedicated branch from the default branch, named main.
+- Keep related commits on the same branch and open one pull request when they
+ form a coherent change that can be reviewed and verified together.
- Reference the relevant issue in the pull request and describe what changed and
how it was verified.
- Submit changes for review before merging into main.
diff --git a/README.md b/README.md
index 4b1e0dc..835a4a8 100644
--- a/README.md
+++ b/README.md
@@ -3,6 +3,10 @@
Coulobre Panel is an open-source web hosting control panel for hosting providers
and resellers. The project is in early development.
+The web panel gives operators a workspace to manage hosting accounts, request
+Apache configuration previews, and follow their progress.
+See [Local development](docs/development.md) to run it.
+
## Planned scope
- Self-hosted installation on a single Ubuntu server, with Debian support planned.
diff --git a/docs/development.md b/docs/development.md
new file mode 100644
index 0000000..c154fc9
--- /dev/null
+++ b/docs/development.md
@@ -0,0 +1,93 @@
+# Local development
+
+Use Python 3.12 or later. From the repository root, install the panel and its
+development tools in a virtual environment.
+
+```sh
+python3 -m venv .venv
+. .venv/bin/activate
+python -m pip install -e '.[dev]'
+export COULOBRE_SECRET_KEY="$(python -c 'from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())')"
+export COULOBRE_DEBUG=1
+python manage.py migrate
+python manage.py createsuperuser
+python manage.py runserver
+```
+
+Open
{}", obj.apache_config)
+ return None
+
+ def has_add_permission(self, request):
+ return False
+
+ def has_change_permission(self, request, obj=None):
+ return False
+
+ def has_delete_permission(self, request, obj=None):
+ return False
diff --git a/src/coulobre/hosting/fields.py b/src/coulobre/hosting/fields.py
new file mode 100644
index 0000000..7b63e5f
--- /dev/null
+++ b/src/coulobre/hosting/fields.py
@@ -0,0 +1,24 @@
+import idna
+from django.core.exceptions import ValidationError
+from django.core.validators import DomainNameValidator
+from django.db import models
+
+validate_domain = DomainNameValidator(accept_idna=False)
+
+
+class DomainNameField(models.CharField):
+ """Store public hostnames in their canonical DNS representation."""
+
+ def to_python(self, value):
+ value = super().to_python(value)
+ if value in self.empty_values:
+ return value
+
+ try:
+ domain = idna.encode(value.strip(), uts46=True).decode("ascii")
+ except idna.IDNAError as error:
+ raise ValidationError(validate_domain.message, code="invalid") from error
+
+ domain = domain.removesuffix(".")
+ validate_domain(domain)
+ return domain
diff --git a/src/coulobre/hosting/migrations/0001_initial.py b/src/coulobre/hosting/migrations/0001_initial.py
new file mode 100644
index 0000000..e0550d7
--- /dev/null
+++ b/src/coulobre/hosting/migrations/0001_initial.py
@@ -0,0 +1,36 @@
+# Generated by Django 5.2.19 on 2026-11-19 20:03
+
+from django.db import migrations, models
+
+import coulobre.hosting.fields
+
+
+class Migration(migrations.Migration):
+ initial = True
+
+ dependencies = []
+
+ operations = [
+ migrations.CreateModel(
+ name="HostingAccount",
+ fields=[
+ (
+ "id",
+ models.BigAutoField(
+ auto_created=True,
+ primary_key=True,
+ serialize=False,
+ verbose_name="ID",
+ ),
+ ),
+ ("name", models.CharField(max_length=120)),
+ (
+ "primary_domain",
+ coulobre.hosting.fields.DomainNameField(
+ max_length=253, unique=True
+ ),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ],
+ ),
+ ]
diff --git a/src/coulobre/hosting/migrations/0002_webprovisioningplan.py b/src/coulobre/hosting/migrations/0002_webprovisioningplan.py
new file mode 100644
index 0000000..f2b218a
--- /dev/null
+++ b/src/coulobre/hosting/migrations/0002_webprovisioningplan.py
@@ -0,0 +1,44 @@
+# Generated by Django 5.2.19 on 2026-11-19 20:12
+
+import django.db.models.deletion
+from django.db import migrations, models
+
+import coulobre.hosting.fields
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("hosting", "0001_initial"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="WebProvisioningPlan",
+ fields=[
+ (
+ "id",
+ models.BigAutoField(
+ auto_created=True,
+ primary_key=True,
+ serialize=False,
+ verbose_name="ID",
+ ),
+ ),
+ (
+ "primary_domain",
+ coulobre.hosting.fields.DomainNameField(max_length=253),
+ ),
+ ("requested_at", models.DateTimeField(auto_now_add=True)),
+ ("last_dispatched_at", models.DateTimeField(blank=True, null=True)),
+ ("completed_at", models.DateTimeField(blank=True, null=True)),
+ ("apache_config", models.TextField(blank=True)),
+ (
+ "account",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ to="hosting.hostingaccount",
+ ),
+ ),
+ ],
+ ),
+ ]
diff --git a/src/coulobre/hosting/migrations/__init__.py b/src/coulobre/hosting/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/src/coulobre/hosting/models.py b/src/coulobre/hosting/models.py
new file mode 100644
index 0000000..23eb19a
--- /dev/null
+++ b/src/coulobre/hosting/models.py
@@ -0,0 +1,40 @@
+from django.db import models
+from django.urls import reverse
+
+from .fields import DomainNameField
+
+
+class HostingAccount(models.Model):
+ name = models.CharField(max_length=120)
+ primary_domain = DomainNameField(max_length=253, unique=True)
+ created_at = models.DateTimeField(auto_now_add=True)
+
+ def get_absolute_url(self):
+ return reverse("panel:account", kwargs={"pk": self.pk})
+
+ def __str__(self):
+ return str(self.primary_domain)
+
+
+class WebProvisioningPlan(models.Model):
+ account = models.ForeignKey(HostingAccount, on_delete=models.CASCADE)
+ primary_domain = DomainNameField(max_length=253)
+ requested_at = models.DateTimeField(auto_now_add=True)
+ last_dispatched_at = models.DateTimeField(null=True, blank=True)
+ completed_at = models.DateTimeField(null=True, blank=True)
+ apache_config = models.TextField(blank=True)
+
+ @classmethod
+ def for_account(cls, account):
+ return cls(account=account, primary_domain=account.primary_domain)
+
+ @property
+ def can_export(self):
+ return (
+ self.completed_at is not None
+ and bool(self.apache_config)
+ and self.primary_domain == self.account.primary_domain
+ )
+
+ def __str__(self):
+ return str(self.primary_domain)
diff --git a/src/coulobre/hosting/static/hosting/panel.css b/src/coulobre/hosting/static/hosting/panel.css
new file mode 100644
index 0000000..4985ffe
--- /dev/null
+++ b/src/coulobre/hosting/static/hosting/panel.css
@@ -0,0 +1,567 @@
+:root {
+ color-scheme: light;
+ --page: #f4f5ef;
+ --surface: #fffefa;
+ --ink: #182923;
+ --muted: #516258;
+ --line: #dce3d9;
+ --sidebar: #142b26;
+ --sidebar-text: #e7f0e9;
+ --accent: #235440;
+ --accent-hover: #174332;
+ --focus: #8c4d2b;
+ --radius: 12px;
+ font: 100%/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
+}
+
+* {
+ box-sizing: border-box;
+}
+
+body {
+ margin: 0;
+ background: var(--page);
+ color: var(--ink);
+}
+
+a {
+ color: var(--accent);
+ text-underline-offset: 0.2em;
+}
+
+button, input {
+ font: inherit;
+}
+
+:focus-visible {
+ outline: 3px solid var(--focus);
+ outline-offset: 3px;
+}
+
+.sidebar :focus-visible {
+ outline-color: #f1c68e;
+}
+
+.visually-hidden, .skip-link:not(:focus) {
+ position: absolute;
+ width: 1px;
+ height: 1px;
+ margin: -1px;
+ overflow: hidden;
+ clip-path: inset(50%);
+ white-space: nowrap;
+}
+
+.skip-link:focus {
+ position: fixed;
+ z-index: 1;
+ top: 1rem;
+ left: 1rem;
+ padding: 0.6rem 1rem;
+ background: var(--surface);
+}
+
+.panel {
+ display: grid;
+ min-height: 100vh;
+ grid-template-columns: 242px minmax(0, 1fr);
+}
+
+.sidebar {
+ position: sticky;
+ top: 0;
+ display: flex;
+ height: 100dvh;
+ flex-direction: column;
+ overflow-y: auto;
+ padding: 1.65rem 1.1rem 1.1rem;
+ background: var(--sidebar);
+ color: var(--sidebar-text);
+}
+
+.brand {
+ display: flex;
+ align-items: center;
+ gap: 0.65rem;
+ padding: 0.25rem 0.45rem;
+ color: inherit;
+ font-size: 1.06rem;
+ font-weight: 750;
+ text-decoration: none;
+ white-space: nowrap;
+}
+
+.brand-mark {
+ display: grid;
+ width: 2.15rem;
+ height: 2.15rem;
+ place-items: center;
+ border-radius: 0.55rem;
+ background: #d8e7bb;
+ color: #18372c;
+ font-size: 1.12rem;
+ font-weight: 800;
+}
+
+.brand-product {
+ color: #b8c9bd;
+ font-weight: 500;
+}
+
+.navigation {
+ display: grid;
+ gap: 0.35rem;
+ margin-top: 2.55rem;
+}
+
+.navigation a {
+ display: flex;
+ align-items: center;
+ gap: 0.7rem;
+ padding: 0.65rem 0.75rem;
+ border: 1px solid transparent;
+ border-radius: 8px;
+ color: #cad8ce;
+ font-size: 0.9rem;
+ text-decoration: none;
+}
+
+.navigation a:hover, .navigation a[aria-current="page"] {
+ border-color: #527369;
+ background: #28473e;
+ color: #fff;
+}
+
+.nav-icon {
+ display: inline-block;
+ width: 1rem;
+ height: 0.85rem;
+ flex: 0 0 auto;
+ border: 1px solid currentColor;
+ border-radius: 2px;
+ color: #b9d5c3;
+}
+
+.nav-icon-accounts {
+ background: linear-gradient(currentColor, currentColor) center / 100% 1px no-repeat;
+}
+
+.nav-icon-plans {
+ width: 0.8rem;
+ height: 1rem;
+ margin-inline: 0.1rem;
+ background:
+ linear-gradient(currentColor, currentColor) center 35% / 55% 1px no-repeat,
+ linear-gradient(currentColor, currentColor) center 65% / 55% 1px no-repeat;
+}
+
+.sidebar-account {
+ display: grid;
+ gap: 0.3rem;
+ margin-top: auto;
+ padding: 0.85rem 0.55rem 0;
+ border-top: 1px solid #3c594e;
+ font-size: 0.88rem;
+}
+
+.operator {
+ overflow-wrap: anywhere;
+ font-weight: 650;
+}
+
+.sidebar-account button {
+ padding: 0;
+ border: 0;
+ background: transparent;
+ color: #c1d4c7;
+ cursor: pointer;
+ text-decoration: underline;
+ text-underline-offset: 0.2em;
+}
+
+.main {
+ width: 100%;
+ max-width: 1230px;
+ padding: clamp(1.25rem, 4.6vw, 4.5rem);
+}
+
+.page-heading {
+ display: flex;
+ align-items: flex-start;
+ justify-content: space-between;
+ gap: 1rem;
+ margin-bottom: 1.45rem;
+}
+
+.page-heading > div {
+ min-width: 0;
+}
+
+.page-heading > .button {
+ flex: 0 0 auto;
+ margin-top: 0.2rem;
+}
+
+h1, h2, p, dl {
+ margin: 0;
+}
+
+h1 {
+ overflow-wrap: anywhere;
+ font-size: clamp(1.75rem, 4vw, 2.65rem);
+ font-weight: 750;
+ letter-spacing: -0.045em;
+ line-height: 1.12;
+}
+
+h2 {
+ font-size: 1.06rem;
+ font-weight: 700;
+}
+
+.heading-meta {
+ margin-top: 0.5rem;
+ color: var(--muted);
+ font-size: 0.92rem;
+}
+
+.surface {
+ min-width: 0;
+ border: 1px solid var(--line);
+ border-radius: var(--radius);
+ background: var(--surface);
+ box-shadow: 0 2px 5px #1a2e2010;
+}
+
+.button {
+ display: inline-flex;
+ min-height: 2.55rem;
+ align-items: center;
+ justify-content: center;
+ padding: 0.48rem 0.82rem;
+ border: 1px solid transparent;
+ border-radius: 7px;
+ cursor: pointer;
+ font-size: 0.9rem;
+ font-weight: 650;
+ text-decoration: none;
+}
+
+.primary {
+ background: var(--accent);
+ color: #fff;
+}
+
+.primary:hover {
+ background: var(--accent-hover);
+}
+
+.secondary {
+ border-color: #c5d1c7;
+ background: var(--surface);
+ color: var(--ink);
+}
+
+.secondary:hover {
+ background: #eaf0e9;
+}
+
+.toolbar, .section-heading, .pagination, .form-actions {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ gap: 0.6rem;
+}
+
+.toolbar, .section-heading, .pagination {
+ padding: 1rem 1.2rem;
+}
+
+.section-heading {
+ justify-content: space-between;
+}
+
+.pagination {
+ justify-content: flex-end;
+ border-top: 1px solid var(--line);
+ color: var(--muted);
+ font-size: 0.88rem;
+}
+
+input:not([type="hidden"]) {
+ min-width: 0;
+ height: 2.55rem;
+ padding: 0.48rem 0.68rem;
+ border: 1px solid #bbcbbf;
+ border-radius: 7px;
+ background: #fff;
+ color: var(--ink);
+}
+
+input::placeholder {
+ color: var(--muted);
+}
+
+.toolbar input {
+ width: min(100%, 20rem);
+}
+
+.quiet-link, .back-link {
+ font-size: 0.88rem;
+ font-weight: 600;
+}
+
+.back-link {
+ display: inline-block;
+ margin-bottom: 1.1rem;
+}
+
+.table-scroll {
+ overflow-x: auto;
+}
+
+table {
+ width: 100%;
+ border-collapse: collapse;
+ text-align: left;
+}
+
+th, td {
+ padding: 0.84rem 1.2rem;
+ border-top: 1px solid var(--line);
+ overflow-wrap: anywhere;
+ vertical-align: top;
+}
+
+th {
+ background: #edf1e9;
+ color: #40594b;
+ font-size: 0.78rem;
+ font-weight: 700;
+}
+
+td {
+ font-size: 0.93rem;
+}
+
+tbody tr:hover {
+ background: #f6f8f3;
+}
+
+.surface > .table-scroll:first-child thead tr:first-child th {
+ border-top: 0;
+}
+
+.surface > .table-scroll:first-child th:first-child {
+ border-top-left-radius: var(--radius);
+}
+
+.surface > .table-scroll:first-child th:last-child {
+ border-top-right-radius: var(--radius);
+}
+
+.cell-date, .status {
+ white-space: nowrap;
+}
+
+.record-link {
+ font-weight: 650;
+}
+
+.domain, code {
+ font-family: ui-monospace, "Cascadia Code", "SFMono-Regular", Consolas, monospace;
+ overflow-wrap: anywhere;
+}
+
+.domain {
+ font-size: 0.88rem;
+}
+
+.muted, .empty {
+ color: var(--muted);
+}
+
+.empty, .notice {
+ padding: 1.1rem 1.2rem;
+ font-size: 0.94rem;
+}
+
+.details {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 1.1rem 3rem;
+ margin-bottom: 1.5rem;
+ padding: 1.15rem 1.25rem;
+}
+
+.details > div {
+ min-width: 0;
+}
+
+dt {
+ color: var(--muted);
+ font-size: 0.8rem;
+ font-weight: 650;
+}
+
+dd {
+ margin: 0.28rem 0 0;
+ overflow-wrap: anywhere;
+}
+
+.notice {
+ margin-bottom: 1.15rem;
+ border-left: 3px solid #8ca487;
+ border-radius: 0 6px 6px 0;
+ background: #e7eee5;
+}
+
+.status {
+ display: inline-block;
+ padding: 0.18rem 0.55rem;
+ border-radius: 0.75rem;
+ font-size: 0.78rem;
+ font-weight: 680;
+}
+
+.status.ready {
+ background: #dcebdc;
+ color: #205038;
+}
+
+.status.pending {
+ background: #f5ead6;
+ color: #6b431b;
+}
+
+.configuration {
+ margin: 0;
+ overflow-x: auto;
+ padding: 1.2rem;
+ border-radius: 0 0 var(--radius) var(--radius);
+ background: #192e28;
+ color: #e6efe3;
+ font-size: 0.88rem;
+ line-height: 1.6;
+ tab-size: 4;
+}
+
+.editor-surface {
+ max-width: 600px;
+ padding: 1.35rem;
+}
+
+.editor {
+ display: grid;
+ gap: 1rem;
+}
+
+.editor label {
+ display: block;
+ margin-bottom: 0.35rem;
+ font-size: 0.88rem;
+ font-weight: 680;
+}
+
+.editor input:not([type="hidden"]) {
+ width: 100%;
+}
+
+.editor .errorlist {
+ margin: 0;
+ padding: 0 0 0 1.1rem;
+ color: #902d29;
+ font-size: 0.87rem;
+}
+
+.editor [aria-invalid="true"] {
+ border-color: #902d29;
+}
+
+.sign-in {
+ display: grid;
+ min-height: 100vh;
+ place-items: center;
+ padding: 1.5rem;
+ background: radial-gradient(ellipse at 25% 0%, #2b5343, var(--sidebar) 67%);
+}
+
+.sign-in-inner {
+ width: min(100%, 415px);
+}
+
+.sign-in-brand {
+ margin-bottom: 1.15rem;
+ color: var(--sidebar-text);
+}
+
+.sign-in-card {
+ padding: clamp(1.3rem, 4vw, 2rem);
+ border-radius: 14px;
+ background: var(--surface);
+ box-shadow: 0 16px 44px #08141045;
+}
+
+.sign-in-card h1 {
+ margin-bottom: 1.25rem;
+ font-size: 2rem;
+}
+
+@media (max-width: 780px) {
+ .panel {
+ display: block;
+ }
+
+ .sidebar {
+ position: static;
+ display: grid;
+ height: auto;
+ grid-template-columns: minmax(0, 1fr) auto;
+ gap: 0.65rem 0.3rem;
+ padding: 0.65rem 0.75rem;
+ }
+
+ .brand {
+ font-size: 1rem;
+ }
+
+ .navigation {
+ display: flex;
+ flex-wrap: wrap;
+ grid-column: 1 / -1;
+ grid-row: 2;
+ margin: 0;
+ }
+
+ .navigation a {
+ padding: 0.38rem 0.55rem;
+ }
+
+ .sidebar-account {
+ max-width: 8.5rem;
+ justify-items: end;
+ margin: 0;
+ padding: 0 0.35rem;
+ border-top: 0;
+ text-align: right;
+ }
+}
+
+@media (max-width: 520px) {
+ .page-heading {
+ flex-direction: column;
+ }
+
+ .toolbar input {
+ width: auto;
+ flex: 1 1 45%;
+ }
+
+ th, td, .toolbar, .section-heading, .pagination {
+ padding-inline: 0.8rem;
+ }
+
+ .cell-date {
+ display: none;
+ }
+}
diff --git a/src/coulobre/hosting/tasks.py b/src/coulobre/hosting/tasks.py
new file mode 100644
index 0000000..a403f47
--- /dev/null
+++ b/src/coulobre/hosting/tasks.py
@@ -0,0 +1,43 @@
+from datetime import timedelta
+
+from celery import shared_task
+from django.db.models import Q
+from django.template.loader import render_to_string
+from django.utils import timezone
+
+from .models import WebProvisioningPlan
+from .web_node import web_site_configuration
+
+REDISPATCH_AFTER = timedelta(minutes=5)
+
+
+@shared_task
+def dispatch_web_plans():
+ stale_before = timezone.now() - REDISPATCH_AFTER
+ pending_ids = (
+ WebProvisioningPlan.objects.filter(completed_at__isnull=True)
+ .filter(
+ Q(last_dispatched_at__isnull=True) | Q(last_dispatched_at__lte=stale_before)
+ )
+ .order_by("requested_at", "pk")
+ .values_list("pk", flat=True)[:100]
+ )
+
+ for plan_id in list(pending_ids):
+ render_web_plan.apply_async(args=[plan_id], retry=False)
+ WebProvisioningPlan.objects.filter(
+ pk=plan_id, completed_at__isnull=True
+ ).update(last_dispatched_at=timezone.now())
+
+
+@shared_task(acks_late=True, reject_on_worker_lost=True)
+def render_web_plan(plan_id):
+ pending = WebProvisioningPlan.objects.filter(pk=plan_id, completed_at__isnull=True)
+ plan = pending.first()
+ if plan is None:
+ return
+
+ apache_config = render_to_string(
+ "hosting/apache-vhost.conf", web_site_configuration(plan)
+ )
+ pending.update(apache_config=apache_config, completed_at=timezone.now())
diff --git a/src/coulobre/hosting/templates/403.html b/src/coulobre/hosting/templates/403.html
new file mode 100644
index 0000000..5ccd8fa
--- /dev/null
+++ b/src/coulobre/hosting/templates/403.html
@@ -0,0 +1,10 @@
+{% extends "hosting/base.html" %}
+{% block title %}Access restricted · Coulobre Panel{% endblock %}
+{% block content %}
+ | Account | Primary domain | Added |
|---|---|---|
| {{ account.name }} | +{{ account.primary_domain }} | +{{ account.created_at|date:"j M Y" }} | +
No hosting accounts match this search.
+ {% else %} +No hosting accounts yet.
+ {% endif %} + {% include "hosting/pagination.html" %} +This preview captures the original domain. The hosting account now uses {{ plan.account.primary_domain }}.
+ {% endif %} + {% if plan.completed_at %} +{{ plan.apache_config }}
+ The configuration will appear here after the worker completes the request.
+ {% endif %} +{% endblock %} diff --git a/src/coulobre/hosting/templates/hosting/plan_list.html b/src/coulobre/hosting/templates/hosting/plan_list.html new file mode 100644 index 0000000..e5a437d --- /dev/null +++ b/src/coulobre/hosting/templates/hosting/plan_list.html @@ -0,0 +1,14 @@ +{% extends "hosting/base.html" %} +{% block title %}Web provisioning · Coulobre Panel{% endblock %} +{% block content %} +| Primary domain | Requested | Status |
|---|---|---|
| {{ plan.primary_domain }} | +{{ plan.requested_at|date:"j M Y, H:i" }} UTC | +{% include "hosting/plan_status.html" %} | +
No Apache previews yet.
+{% endif %} diff --git a/src/coulobre/hosting/templates/hosting/smoke-index.php b/src/coulobre/hosting/templates/hosting/smoke-index.php new file mode 100644 index 0000000..f874ac0 --- /dev/null +++ b/src/coulobre/hosting/templates/hosting/smoke-index.php @@ -0,0 +1,5 @@ +<VirtualHost") + self.assertContains(response, "ServerName example.org") + self.assertEqual(self.client.post(plan_url).status_code, 403) + + @patch("coulobre.hosting.tasks.render_web_plan.apply_async") + def test_broker_failure_leaves_request_available_for_dispatch(self, publish): + plan = self.create_plan() + publish.side_effect = OperationalError("Broker unavailable") + with self.assertRaises(OperationalError): + dispatch_web_plans.run() + plan.refresh_from_db() + self.assertIsNone(plan.last_dispatched_at) + + publish.side_effect = None + publish.reset_mock() + dispatch_web_plans.run() + publish.assert_called_once_with(args=[plan.pk], retry=False) + plan.refresh_from_db() + self.assertIsNotNone(plan.last_dispatched_at) + + @patch("coulobre.hosting.tasks.render_web_plan.apply_async") + def test_only_incomplete_stale_deliveries_are_republished(self, publish): + now = timezone.now() + stale_at = now - REDISPATCH_AFTER - timedelta(seconds=1) + stale_plan = self.create_plan() + recent_plan = self.create_plan() + completed_plan = self.create_plan() + WebProvisioningPlan.objects.filter(pk=stale_plan.pk).update( + last_dispatched_at=stale_at + ) + WebProvisioningPlan.objects.filter(pk=recent_plan.pk).update( + last_dispatched_at=now + ) + WebProvisioningPlan.objects.filter(pk=completed_plan.pk).update( + last_dispatched_at=stale_at, completed_at=now + ) + + dispatch_web_plans.run() + + publish.assert_called_once_with(args=[stale_plan.pk], retry=False) + + def test_duplicate_delivery_preserves_the_completed_preview(self): + plan = self.create_plan() + render_web_plan.run(plan.pk) + plan.refresh_from_db() + original = (plan.completed_at, plan.apache_config) + + render_web_plan.run(plan.pk) + plan.refresh_from_db() + + self.assertEqual((plan.completed_at, plan.apache_config), original) diff --git a/src/coulobre/hosting/urls.py b/src/coulobre/hosting/urls.py new file mode 100644 index 0000000..f4a313a --- /dev/null +++ b/src/coulobre/hosting/urls.py @@ -0,0 +1,32 @@ +from django.contrib.auth.views import LoginView, LogoutView +from django.urls import path + +from . import views + +app_name = "panel" + +urlpatterns = [ + path("", views.AccountList.as_view(), name="accounts"), + path( + "sign-in/", + LoginView.as_view( + template_name="hosting/login.html", + redirect_authenticated_user=True, + ), + name="login", + ), + path("sign-out/", LogoutView.as_view(), name="logout"), + path("accounts/new/", views.AccountCreate.as_view(), name="account_create"), + path("accounts/