Queue database provisioning and new DNS publications on creation #140

Merged
parkel merged 2 commits from feature/automatic-provisioning into main 2026-11-22 23:30:44 +01:00
13 changed files with 197 additions and 83 deletions

No files matched your search

+11 -8
View File
@@ -1115,10 +1115,12 @@ sudo systemctl restart coulobre-panel coulobre-worker coulobre-beat
sudo systemctl enable --now coulobre-database-provisioner.service sudo systemctl enable --now coulobre-database-provisioner.service
``` ```
Open a hosting account and select **Provision database** for a database request. Select **Add database** on a hosting account to queue its provisioning.
Reload the account page to see the status. Use **Retry provisioning** after a Customers can add databases on their own accounts. Customer managers need
reported failure. Operators need permission to view hosting accounts and permission to manage resources for their assigned accounts. For a pending
database requests and the **Can add database provisioning** permission. request, an operator can select **Provision database**. Operators need
permission to view hosting accounts and databases and the **Can add database
provisioning** permission. Use **Retry provisioning** after a reported failure.
The MariaDB node stores the application login in the root-only file The MariaDB node stores the application login in the root-only file
`/var/lib/coulobre/database-node/<database-name>.json`. Use the credentials `/var/lib/coulobre/database-node/<database-name>.json`. Use the credentials
@@ -1774,10 +1776,11 @@ sudo systemctl restart coulobre-panel coulobre-worker coulobre-beat
sudo systemctl enable --now coulobre-dns-publisher.service sudo systemctl enable --now coulobre-dns-publisher.service
``` ```
Open a hosting account and select **Publish zone**. Reload the account page to Select **Save and publish zone** to queue a new zone from a hosting account.
see progress and the last SOA serial confirmed by the local BIND9 node. Use **Publish zone** to publish a pending revision of an existing zone.
Operators need permission to view hosting accounts and DNS zones and the The account page shows progress and the last SOA serial confirmed by the
**Can add DNS publication** permission. local BIND9 node. Operators need permission to view hosting accounts and DNS
zones and the **Can add DNS publication** permission.
Each request captures the reviewed SOA serial and records. You can edit the Each request captures the reviewed SOA serial and records. You can edit the
zone while it publishes. Publish the newer revision after the current request zone while it publishes. Publish the newer revision after the current request
+4 -2
View File
@@ -7,6 +7,7 @@ from django.views.decorators.cache import never_cache
from django.views.generic import TemplateView from django.views.generic import TemplateView
from .access import OperatorOnlyMixin from .access import OperatorOnlyMixin
from .dns_defaults import zone_defaults
@method_decorator(never_cache, name="dispatch") @method_decorator(never_cache, name="dispatch")
@@ -22,6 +23,7 @@ class InstallationView(
except PackageNotFoundError: except PackageNotFoundError:
installed_version = "Unavailable" installed_version = "Unavailable"
dns_defaults = zone_defaults()
features = ( features = (
("Local website provisioning", settings.LOCAL_WEB_ACTIVATION), ("Local website provisioning", settings.LOCAL_WEB_ACTIVATION),
("Managed website certificates", settings.LOCAL_WEB_HTTPS), ("Managed website certificates", settings.LOCAL_WEB_HTTPS),
@@ -31,8 +33,8 @@ class InstallationView(
( (
"Default managed DNS zones for new accounts", "Default managed DNS zones for new accounts",
settings.LOCAL_DNS_PUBLISHING settings.LOCAL_DNS_PUBLISHING
and settings.HOSTING_NAMESERVERS and dns_defaults.nameservers
and settings.HOSTING_PUBLIC_ADDRESSES, and dns_defaults.addresses,
), ),
( (
"Local mailbox provisioning", "Local mailbox provisioning",
+8 -2
View File
@@ -27,7 +27,9 @@ def lock_hosting_account(account_id, customer_id):
@transaction.atomic @transaction.atomic
def create_database_request(account_id, suffix, *, customer_id=None): def create_database_request(
account_id, suffix, *, customer_id=None, auto_provision=False
):
account = lock_hosting_account(account_id, customer_id) account = lock_hosting_account(account_id, customer_id)
require_open_account(account) require_open_account(account)
databases = account.databases databases = account.databases
@@ -45,7 +47,11 @@ def create_database_request(account_id, suffix, *, customer_id=None):
raise ValidationError( raise ValidationError(
"This hosting account has reached its database limit." "This hosting account has reached its database limit."
) )
return databases.create(suffix=suffix) database = databases.create(suffix=suffix)
if auto_provision:
require_active_services(account)
DatabaseProvisioning.objects.queue(database=database)
return database
@transaction.atomic @transaction.atomic
@@ -133,7 +133,7 @@
<section id="databases" data-account-section tabindex="-1" class="surface" aria-labelledby="databases-heading"> <section id="databases" data-account-section tabindex="-1" class="surface" aria-labelledby="databases-heading">
<header class="section-heading"> <header class="section-heading">
<div> <div>
<h2 id="databases-heading" tabindex="-1">MariaDB database requests</h2> <h2 id="databases-heading" tabindex="-1">MariaDB databases</h2>
{% if is_tenant or perms.hosting.view_hostingplan %} {% if is_tenant or perms.hosting.view_hostingplan %}
{% if account.hosting_plan and account.hosting_plan.database_limit is not None %} {% if account.hosting_plan and account.hosting_plan.database_limit is not None %}
<p class="heading-meta">{{ databases|length }} of {{ account.hosting_plan.database_limit }} databases requested</p> <p class="heading-meta">{{ databases|length }} of {{ account.hosting_plan.database_limit }} databases requested</p>
@@ -141,51 +141,50 @@
{% endif %} {% endif %}
</div> </div>
{% if is_customer or reseller_resource_management or is_operator and perms.hosting.add_hostingdatabase %} {% if is_customer or reseller_resource_management or is_operator and perms.hosting.add_hostingdatabase %}
<a class="button primary" href="{% url 'panel:database_create' account.pk %}">Request database</a> <a class="button primary" href="{% url 'panel:database_create' account.pk %}">{% if automatic_database_provisioning %}Add{% else %}Request{% endif %} database</a>
{% endif %} {% endif %}
</header> </header>
{% if databases %} {% if databases %}
<div class="table-scroll"> <div class="table-scroll">
<table> <table>
<thead><tr><th scope="col">Database</th>{% if is_operator or manage_database_provisioning %}<th scope="col">Deployment</th>{% endif %}</tr></thead> <thead><tr><th scope="col">Database</th><th scope="col">Status and actions</th></tr></thead>
<tbody> <tbody>
{% for database in databases %} {% for database in databases %}
<tr> <tr>
<td class="domain"> <th scope="row" class="domain">{{ database }}</th>
{{ database }} <td>
{% if show_database_credentials %} <div class="table-actions">
<div><a class="record-link" href="{% url 'panel:database_credentials' database.pk %}" aria-label="Connection details for {{ database }}">Connection details</a></div> {% if manage_database_provisioning %}
{% endif %} {% url 'panel:database_provision' database.pk as provision_url %}
{% if show_phpmyadmin %} {% include "hosting/resource_provisioning.html" with provisioning=database.provisioning enabled=local_database_enabled action=provision_url resource=database provision_label="Provision database" %}
<form method="post" action="{% url 'panel:phpmyadmin_launch' database.pk %}"> {% else %}
{% csrf_token %} {% include "hosting/resource_provisioning.html" with provisioning=database.provisioning enabled=False %}
<button class="button secondary" type="submit">Open phpMyAdmin</button> {% endif %}
</form> {% if not database.provisioning %}<span class="status pending">Requested</span>{% endif %}
{% if show_database_credentials %}
<a class="record-link" href="{% url 'panel:database_credentials' database.pk %}" aria-label="Connection details for {{ database }}">Connection details</a>
{% endif %}
{% if show_phpmyadmin %}
<form method="post" action="{% url 'panel:phpmyadmin_launch' database.pk %}">
{% csrf_token %}
<button class="button secondary" type="submit">Open phpMyAdmin</button>
</form>
{% endif %}
{% if is_operator %}
<a class="record-link" href="{% url 'panel:database_manifest' database.pk %}" aria-label="Download manifest for {{ database }}">Download manifest</a>
{% endif %}
</div>
{% if is_operator and manage_database_provisioning and database.provisioning.problem %}
<p class="heading-meta">{{ database.provisioning.problem }}</p>
{% endif %} {% endif %}
</td> </td>
{% if is_operator or manage_database_provisioning %}
<td>
<div class="form-actions">
{% if is_operator %}
<a class="record-link" href="{% url 'panel:database_manifest' database.pk %}" aria-label="Download manifest for {{ database }}">Download manifest</a>
{% endif %}
{% if manage_database_provisioning %}
{% url 'panel:database_provision' database.pk as provision_url %}
{% include "hosting/resource_provisioning.html" with provisioning=database.provisioning enabled=local_database_enabled action=provision_url resource=database provision_label="Provision database" %}
{% endif %}
</div>
{% if is_operator and manage_database_provisioning and database.provisioning.problem %}
<p class="heading-meta">{{ database.provisioning.problem }}</p>
{% endif %}
</td>
{% endif %}
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
</div> </div>
{% else %} {% else %}
<p class="empty">No databases requested yet.</p> <p class="empty">No databases yet.</p>
{% endif %} {% endif %}
</section> </section>
{% endif %} {% endif %}
@@ -1,15 +1,15 @@
{% extends "hosting/base.html" %} {% extends "hosting/base.html" %}
{% block title %}Request MariaDB database · Coulobre Panel{% endblock %} {% block title %}{% if auto_provision %}Add{% else %}Request{% endif %} MariaDB database · Coulobre Panel{% endblock %}
{% block content %} {% block content %}
<a class="back-link" href="{{ account.get_absolute_url }}">← {{ account.name }}</a> <a class="back-link" href="{{ account.get_absolute_url }}">← {{ account.name }}</a>
<header class="page-heading"><h1>Request MariaDB database</h1></header> <header class="page-heading"><h1>{% if auto_provision %}Add{% else %}Request{% endif %} MariaDB database</h1></header>
<section class="surface editor-surface"> <section class="surface editor-surface">
<form method="post" class="editor"> <form method="post" class="editor">
{% include "hosting/customer_action_fields.html" %} {% include "hosting/customer_action_fields.html" %}
{{ form.as_div }} {{ form.as_div }}
<div class="form-actions"> <div class="form-actions">
{% if can_request_resource %} {% if can_request_resource %}
<button class="button primary" type="submit">Request database</button> <button class="button primary" type="submit">{% if auto_provision %}Add{% else %}Request{% endif %} database</button>
{% endif %} {% endif %}
<a class="button secondary" href="{{ account.get_absolute_url }}">Cancel</a> <a class="button secondary" href="{{ account.get_absolute_url }}">Cancel</a>
</div> </div>
@@ -37,7 +37,7 @@
<script src="{% static 'hosting/dns-record-editor.js' %}" defer></script> <script src="{% static 'hosting/dns-record-editor.js' %}" defer></script>
{% endif %} {% endif %}
<div class="form-actions"> <div class="form-actions">
<button class="button primary" type="submit">Save zone</button> <button class="button primary" type="submit">{% if publish_on_create %}Save and publish zone{% else %}Save zone{% endif %}</button>
<a class="button secondary" href="{{ account.get_absolute_url }}">Cancel</a> <a class="button secondary" href="{{ account.get_absolute_url }}">Cancel</a>
</div> </div>
</form> </form>
@@ -25,7 +25,14 @@
{% for name, enabled in features %} {% for name, enabled in features %}
<tr> <tr>
<th scope="row">{{ name }}</th> <th scope="row">{{ name }}</th>
<td>{% if enabled %}<span class="status active">Enabled</span>{% else %}Disabled{% endif %}</td> <td>
<div class="table-actions">
{% if enabled %}<span class="status active">Enabled</span>{% else %}<span>Disabled</span>{% endif %}
{% if request.user.is_superuser and name == 'Default managed DNS zones for new accounts' %}
<a class="record-link" href="{% url 'panel:dns_defaults' %}">Configure DNS defaults</a>
{% endif %}
</div>
</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
@@ -1,10 +1,10 @@
{% extends "hosting/base.html" %} {% extends "hosting/base.html" %}
{% block title %}{% if automatic_mailbox_provisioning %}Add{% else %}Request{% endif %} mailbox · Coulobre Panel{% endblock %} {% block title %}{% if auto_provision %}Add{% else %}Request{% endif %} mailbox · Coulobre Panel{% endblock %}
{% block content %} {% block content %}
<a class="back-link" href="{{ account.get_absolute_url }}">← {{ account.name }}</a> <a class="back-link" href="{{ account.get_absolute_url }}">← {{ account.name }}</a>
<header class="page-heading"> <header class="page-heading">
<div> <div>
<h1>{% if automatic_mailbox_provisioning %}Add{% else %}Request{% endif %} mailbox</h1> <h1>{% if auto_provision %}Add{% else %}Request{% endif %} mailbox</h1>
<p class="heading-meta domain">{{ account.primary_domain }}</p> <p class="heading-meta domain">{{ account.primary_domain }}</p>
</div> </div>
</header> </header>
@@ -14,7 +14,7 @@
{{ form.as_div }} {{ form.as_div }}
<div class="form-actions"> <div class="form-actions">
{% if can_request_resource %} {% if can_request_resource %}
<button class="button primary" type="submit">{% if automatic_mailbox_provisioning %}Add{% else %}Request{% endif %} mailbox</button> <button class="button primary" type="submit">{% if auto_provision %}Add{% else %}Request{% endif %} mailbox</button>
{% endif %} {% endif %}
<a class="button secondary" href="{{ account.get_absolute_url }}">Cancel</a> <a class="button secondary" href="{{ account.get_absolute_url }}">Cancel</a>
</div> </div>
@@ -87,6 +87,34 @@ class DatabaseProvisioningTests(TestCase):
self.assertEqual(self.client.post(self.url).status_code, 403) self.assertEqual(self.client.post(self.url).status_code, 403)
self.assertFalse(DatabaseProvisioning.objects.exists()) self.assertFalse(DatabaseProvisioning.objects.exists())
def test_customer_creation_queues_a_database_and_shows_its_status(self):
self.client.force_login(self.user)
url = reverse("panel:database_create", args=[self.account.pk])
self.assertContains(self.client.get(url), "Add database")
self.assertRedirects(
self.client.post(url, {"suffix": "new"}), self.detail
)
job = DatabaseProvisioning.objects.get(database__suffix="new")
self.assertEqual(job.state, "queued")
self.assertContains(self.client.get(self.detail), "Queued")
def test_operator_without_provisioning_permission_creates_a_request(self):
requester = get_user_model().objects.create_user("requester")
requester.user_permissions.add(
*self.permissions.exclude(codename="add_databaseprovisioning"),
Permission.objects.get(codename="add_hostingdatabase"),
)
self.client.force_login(requester)
url = reverse("panel:database_create", args=[self.account.pk])
self.assertContains(self.client.get(url), "Request database")
self.assertRedirects(
self.client.post(url, {"suffix": "request"}), self.detail
)
self.assertTrue(
self.account.databases.filter(suffix="request").exists()
)
self.assertFalse(DatabaseProvisioning.objects.exists())
@override_settings(LOCAL_DATABASE_PROVISIONING=False) @override_settings(LOCAL_DATABASE_PROVISIONING=False)
def test_disabled_provisioning_preserves_existing_manifest_download(self): def test_disabled_provisioning_preserves_existing_manifest_download(self):
detail = self.client.get(self.detail) detail = self.client.get(self.detail)
@@ -42,6 +42,31 @@ class DnsPublicationTests(TestCase):
self.url = reverse("panel:dns_zone_publish", args=[self.zone.pk]) self.url = reverse("panel:dns_zone_publish", args=[self.zone.pk])
self.detail = self.account.get_absolute_url() self.detail = self.account.get_absolute_url()
def test_creating_a_managed_zone_queues_its_first_snapshot(self):
account = HostingAccount.objects.create(
name="Example DNS", primary_domain="new.example"
)
url = reverse("panel:dns_zone_create", args=[account.pk])
self.assertContains(self.client.get(url), "Save and publish zone")
self.assertRedirects(
self.client.post(
url,
{
"nameservers": "ns.provider.example",
"responsible_name": "hostmaster.new.example",
"addresses": "new.example 192.0.2.20",
},
),
account.get_absolute_url(),
)
zone = account.dns_zones.get()
self.assertEqual(
(zone.publication.state, zone.publication.serial), ("queued", 1)
)
self.assertEqual(
DnsZone.from_manifest(zone.publication.manifest), zone.spec
)
def test_queued_snapshot_survives_edits_and_next_revision_can_publish( def test_queued_snapshot_survives_edits_and_next_revision_can_publish(
self, self,
): ):
@@ -196,13 +196,11 @@ class ResellerOnboardingTests(TestCase):
for model, resource in (("database", database), ("mailbox", mailbox)): for model, resource in (("database", database), ("mailbox", mailbox)):
url = reverse(f"panel:{model}_provision", args=[resource.pk]) url = reverse(f"panel:{model}_provision", args=[resource.pk])
manifest = reverse(f"panel:{model}_manifest", args=[resource.pk]) manifest = reverse(f"panel:{model}_manifest", args=[resource.pk])
if model == "database": self.assertEqual(resource.provisioning.state, "queued")
self.assertContains( self.assertContains(self.client.get(detail), "Queued")
self.client.get(detail), "Provision database" self.assertNotContains(
) self.client.get(detail), f"Provision {model}"
else: )
self.assertEqual(mailbox.provisioning.state, "queued")
self.assertContains(self.client.get(detail), "Queued")
self.assertEqual(self.client.get(manifest).status_code, 403) self.assertEqual(self.client.get(manifest).status_code, 403)
for _ in range(2): for _ in range(2):
self.assertRedirects(self.client.post(url), detail) self.assertRedirects(self.client.post(url), detail)
@@ -214,7 +212,7 @@ class ResellerOnboardingTests(TestCase):
"action", flat=True "action", flat=True
) )
), ),
[Action.RESOURCE_REQUEST] * 2 + [Action.RESOURCE_PROVISION] * 2, [Action.RESOURCE_REQUEST, Action.RESOURCE_PROVISION] * 2,
) )
DatabaseProvisioning.objects.update( DatabaseProvisioning.objects.update(
finished_at=timezone.now(), problem="Failed" finished_at=timezone.now(), problem="Failed"
+19 -1
View File
@@ -20,7 +20,7 @@ from coulobre.service_health import (
main, main,
) )
from .models import Customer, Reseller, ServiceHealth from .models import Customer, DnsZoneDefaults, Reseller, ServiceHealth
TARGETS = ( TARGETS = (
HealthTarget("panel-01", "local", ("mariadb", "apache")), HealthTarget("panel-01", "local", ("mariadb", "apache")),
@@ -196,6 +196,24 @@ class ServiceHealthPanelTests(TestCase):
self.assertNotContains(response, "test-only-bridge-key") self.assertNotContains(response, "test-only-bridge-key")
self.assertNotContains(response, "https://webmail.example.net") self.assertNotContains(response, "https://webmail.example.net")
@override_settings(
LOCAL_DNS_PUBLISHING=True,
HOSTING_NAMESERVERS=(),
HOSTING_PUBLIC_ADDRESSES=(),
)
def test_installation_reports_dns_defaults_saved_in_the_panel(self):
DnsZoneDefaults.objects.create(
pk=1, nameservers=["ns.example.net"], addresses=["192.0.2.20"]
)
self.client.force_login(self.admin)
response = self.client.get(reverse("panel:installation"))
self.assertTrue(
dict(response.context["features"])[
"Default managed DNS zones for new accounts"
]
)
self.assertContains(response, "Configure DNS defaults")
def test_view_marks_missing_and_old_observations_distinctly(self): def test_view_marks_missing_and_old_observations_distinctly(self):
now = timezone.now() now = timezone.now()
for node, service, result, observed_at in ( for node, service, result, observed_at in (
+52 -24
View File
@@ -238,10 +238,8 @@ PROVISION_MAILBOX = (
CHANGE_MAILBOX_QUOTA = (*PROVISION_MAILBOX, "hosting.change_hostingmailbox") CHANGE_MAILBOX_QUOTA = (*PROVISION_MAILBOX, "hosting.change_hostingmailbox")
def automatic_mailbox_provisioning(user): def automatic_resource_provisioning(user, enabled, permissions):
return settings.LOCAL_MAILBOX_PROVISIONING and ( return enabled and (is_tenant(user) or user.has_perms(permissions))
is_tenant(user) or user.has_perms(PROVISION_MAILBOX)
)
def missing_account_setup(account, actor): def missing_account_setup(account, actor):
@@ -830,11 +828,17 @@ class AccountDetail(TenantScopeMixin, PermissionRequiredMixin, DetailView):
"show_mailbox_credentials" "show_mailbox_credentials"
] and roundcube_available(self.request) ] and roundcube_available(self.request)
if tenant or user.has_perm(VIEW_DATABASES): if tenant or user.has_perm(VIEW_DATABASES):
databases = self.object.databases.all() context["automatic_database_provisioning"] = (
automatic_resource_provisioning(
user,
settings.LOCAL_DATABASE_PROVISIONING,
PROVISION_DATABASE,
)
)
databases = self.object.databases.select_related("provisioning")
if manage_resources or ( if manage_resources or (
not tenant and user.has_perms(PROVISION_DATABASE) not tenant and user.has_perms(PROVISION_DATABASE)
): ):
databases = databases.select_related("provisioning")
context["manage_database_provisioning"] = True context["manage_database_provisioning"] = True
context["local_database_enabled"] = ( context["local_database_enabled"] = (
settings.LOCAL_DATABASE_PROVISIONING settings.LOCAL_DATABASE_PROVISIONING
@@ -898,7 +902,11 @@ class AccountDetail(TenantScopeMixin, PermissionRequiredMixin, DetailView):
) )
if tenant or user.has_perm(VIEW_MAILBOXES): if tenant or user.has_perm(VIEW_MAILBOXES):
context["automatic_mailbox_provisioning"] = ( context["automatic_mailbox_provisioning"] = (
automatic_mailbox_provisioning(user) automatic_resource_provisioning(
user,
settings.LOCAL_MAILBOX_PROVISIONING,
PROVISION_MAILBOX,
)
) )
context["manage_mail_routing"] = mail_policy_enabled( context["manage_mail_routing"] = mail_policy_enabled(
self.request, "routing" self.request, "routing"
@@ -1932,6 +1940,8 @@ def provisioning_conflict(error):
class ResourceRequestCreate(PermissionRequiredMixin, CreateView): class ResourceRequestCreate(PermissionRequiredMixin, CreateView):
audit_operation = None audit_operation = None
provisioning_setting = None
provisioning_permissions = ()
@cached_property @cached_property
def customer(self): def customer(self):
@@ -1959,9 +1969,23 @@ class ResourceRequestCreate(PermissionRequiredMixin, CreateView):
return super().get_context_data( return super().get_context_data(
account=self.account, account=self.account,
can_request_resource=can_edit_customer_resource(self.request), can_request_resource=can_edit_customer_resource(self.request),
auto_provision=self.auto_provision,
**kwargs, **kwargs,
) )
@cached_property
def auto_provision(self):
return automatic_resource_provisioning(
self.request.user,
getattr(settings, self.provisioning_setting),
self.provisioning_permissions,
)
def create_request(self, account_id, **values):
return self.create_resource(
account_id, auto_provision=self.auto_provision, **values
)
def get_form(self, form_class=None): def get_form(self, form_class=None):
form = super().get_form(form_class) form = super().get_form(form_class)
if not can_edit_customer_resource(self.request): if not can_edit_customer_resource(self.request):
@@ -2008,7 +2032,9 @@ class DatabaseCreate(ResourceRequestCreate):
template_name = "hosting/database_form.html" template_name = "hosting/database_form.html"
permission_required = CUSTOMER_WRITE_PERMISSIONS["panel:database_create"] permission_required = CUSTOMER_WRITE_PERMISSIONS["panel:database_create"]
audit_operation = CustomerImpersonationAction.Operation.DATABASE audit_operation = CustomerImpersonationAction.Operation.DATABASE
create_request = staticmethod(create_database_request) provisioning_setting = "LOCAL_DATABASE_PROVISIONING"
provisioning_permissions = PROVISION_DATABASE
create_resource = staticmethod(create_database_request)
class DownloadDatabaseManifest( class DownloadDatabaseManifest(
@@ -2129,6 +2155,17 @@ class DnsZoneCreate(OperatorOnlyMixin, DnsZoneEditor):
"record_rows": "[]", "record_rows": "[]",
} }
@cached_property
def publish_on_create(self):
return settings.LOCAL_DNS_PUBLISHING and self.request.user.has_perms(
PUBLISH_DNS
)
def get_context_data(self, **kwargs):
return super().get_context_data(
publish_on_create=self.publish_on_create, **kwargs
)
def form_valid(self, form): def form_valid(self, form):
try: try:
with transaction.atomic(): with transaction.atomic():
@@ -2136,12 +2173,14 @@ class DnsZoneCreate(OperatorOnlyMixin, DnsZoneEditor):
self.account.pk, customer_id=None self.account.pk, customer_id=None
) )
require_open_account(account) require_open_account(account)
HostingDnsZone.objects.create( zone = HostingDnsZone.objects.create(
account=account, account=account,
domain=account.primary_domain, domain=account.primary_domain,
**form.cleaned_data, **form.cleaned_data,
) )
except ValidationError as error: if self.publish_on_create:
queue_dns_publication(zone.pk, str(zone.serial))
except (ValidationError, ValueError) as error:
form.add_error(None, error) form.add_error(None, error)
return self.form_invalid(form) return self.form_invalid(form)
except IntegrityError: except IntegrityError:
@@ -2332,20 +2371,9 @@ class MailboxCreate(ResourceRequestCreate):
permission_required = CUSTOMER_WRITE_PERMISSIONS["panel:mailbox_create"] permission_required = CUSTOMER_WRITE_PERMISSIONS["panel:mailbox_create"]
audit_operation = CustomerImpersonationAction.Operation.MAILBOX audit_operation = CustomerImpersonationAction.Operation.MAILBOX
def create_request(self, account_id, **values): provisioning_setting = "LOCAL_MAILBOX_PROVISIONING"
return create_mailbox_request( provisioning_permissions = PROVISION_MAILBOX
account_id, create_resource = staticmethod(create_mailbox_request)
auto_provision=automatic_mailbox_provisioning(self.request.user),
**values,
)
def get_context_data(self, **kwargs):
return super().get_context_data(
automatic_mailbox_provisioning=automatic_mailbox_provisioning(
self.request.user
),
**kwargs,
)
def get_form(self, form_class=None): def get_form(self, form_class=None):
form = super().get_form(form_class) form = super().get_form(form_class)