Compare commits
9
Commits
664087f18b
...
v0.12.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e240cbc64f | ||
|
|
454945c328 | ||
|
|
0803db8e5f | ||
|
|
29246b7114 | ||
|
|
b76e6c78a3 | ||
|
|
6ed566f1ee | ||
|
|
b215cd0ab1 | ||
|
|
ccbc2ad931 | ||
|
|
7e68b9928c |
No files matched your search
+32
-3
@@ -28,11 +28,39 @@
|
||||
release. Issues without a milestone stay in the backlog. Add a due date
|
||||
when a release date has been agreed.
|
||||
|
||||
### Choose a release version
|
||||
|
||||
Use [Semantic Versioning][semver] for Coulobre releases. Consider the
|
||||
documented interfaces people depend on, including configuration, CLI commands,
|
||||
upgrade paths, and the protocols between the panel and its service nodes.
|
||||
|
||||
| Change | Version increment from 1.0 onward |
|
||||
| --- | --- |
|
||||
| Compatible bug fixes, including compatible security fixes | Patch (`1.2.3` → `1.2.4`) |
|
||||
| Compatible features or deprecations | Minor (`1.2.3` → `1.3.0`) |
|
||||
| Incompatible changes to a documented interface | Major (`1.2.3` → `2.0.0`) |
|
||||
|
||||
Before 1.0, use `0.Y.Z`. Increment `Y` and reset `Z` for a feature release or
|
||||
an incompatible change. Increment `Z` for compatible fixes. Document any
|
||||
incompatible change and its upgrade steps in the release notes.
|
||||
|
||||
Start release candidates at 1 for each target version and increment the
|
||||
candidate number for each release. Use [Python version specifiers][versions]
|
||||
in `pyproject.toml` and the matching tag in Git and Gitea.
|
||||
|
||||
| Release | Python package version | Git tag |
|
||||
| --- | --- | --- |
|
||||
| First candidate for 0.12.0 | `0.12.0rc1` | `v0.12.0-rc.1` |
|
||||
| Next candidate for 0.12.0 | `0.12.0rc2` | `v0.12.0-rc.2` |
|
||||
| Final 0.12.0 release | `0.12.0` | `v0.12.0` |
|
||||
|
||||
Keep published release tags and artifacts fixed. Publish a new version for
|
||||
subsequent changes.
|
||||
|
||||
### Prepare a release
|
||||
|
||||
1. Update the package version in `pyproject.toml`. For a release candidate,
|
||||
use a Python version such as `0.1.0rc1` and a matching Git tag such as
|
||||
`v0.1.0-rc.1`. [Python version specifiers][versions]
|
||||
1. Update the package version in `pyproject.toml` using the versioning rules
|
||||
above.
|
||||
2. From a clean checkout, use `python -m build` to build the source
|
||||
distribution and wheel. Run
|
||||
`python tools/check_core_release.py dist/*.tar.gz dist/*.whl` to compare
|
||||
@@ -71,6 +99,7 @@ python tools/web_update_manifest.py dist/coulobre_panel-0.10.2rc1-py3-none-any.w
|
||||
[issues]: https://code.hosting.hippogrief.nl/hippogrief/coulobre/issues
|
||||
[milestones]: https://code.hosting.hippogrief.nl/hippogrief/coulobre/milestones
|
||||
[releases]: https://code.hosting.hippogrief.nl/hippogrief/coulobre/releases
|
||||
[semver]: https://semver.org/
|
||||
[versions]: https://packaging.python.org/en/latest/specifications/version-specifiers/#pre-releases
|
||||
[build]: https://build.pypa.io/en/stable/
|
||||
[deployment-checks]: docs/deployment.md#verify-a-new-installation
|
||||
|
||||
@@ -96,6 +96,12 @@ and select a customer on hosting accounts they can create or edit. **Can add
|
||||
customer** enables customer creation. **Can change customer** enables
|
||||
sign-in suspension and restoration.
|
||||
|
||||
To create an account for your own hosting, sign in as a verified server
|
||||
administrator. On **Add hosting account**, leave **Customer** unassigned and
|
||||
select **For my own hosting**. The panel links the account to your login and
|
||||
creates a customer profile if needed. Use the role selector to switch to
|
||||
**Customer** and manage the hosting assigned to that profile.
|
||||
|
||||
If local credential access is enabled, customers can choose **Connection
|
||||
details** for databases and mailboxes on their assigned accounts. The panel
|
||||
requires password confirmation for each reveal.
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "coulobre-panel"
|
||||
version = "0.12.0rc2"
|
||||
version = "0.12.0"
|
||||
description = "A web hosting control panel for hosting providers and resellers."
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.12"
|
||||
|
||||
@@ -709,12 +709,14 @@ tbody tr:hover {
|
||||
border-top: 0;
|
||||
}
|
||||
|
||||
.surface > .table-scroll:first-child th:first-child {
|
||||
border-top-left-radius: var(--radius);
|
||||
.surface > .table-scroll:first-child {
|
||||
border-start-start-radius: calc(var(--radius) - 1px);
|
||||
border-start-end-radius: calc(var(--radius) - 1px);
|
||||
}
|
||||
|
||||
.surface > .table-scroll:first-child th:last-child {
|
||||
border-top-right-radius: var(--radius);
|
||||
.surface > .table-scroll:last-child {
|
||||
border-end-start-radius: calc(var(--radius) - 1px);
|
||||
border-end-end-radius: calc(var(--radius) - 1px);
|
||||
}
|
||||
|
||||
.cell-date, .status {
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
from django.contrib.admin.models import ADDITION, LogEntry
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.test import TestCase, override_settings
|
||||
from django.urls import reverse
|
||||
from django_otp.plugins.otp_totp.models import TOTPDevice
|
||||
|
||||
from .models import HostingAccount, WebsiteAlias
|
||||
from .models import Customer, HostingAccount, PanelInvitation, WebsiteAlias
|
||||
|
||||
|
||||
@override_settings(
|
||||
@@ -102,3 +104,90 @@ class HostingAccountSetupTests(TestCase):
|
||||
self.assertIn(
|
||||
"check me", {record.text for record in zone.spec.txt_records}
|
||||
)
|
||||
|
||||
|
||||
class OperatorOwnHostingTests(TestCase):
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
users = get_user_model().objects
|
||||
cls.operator = users.create_superuser("operator")
|
||||
cls.device = TOTPDevice.objects.create(user=cls.operator, name="Panel")
|
||||
cls.customer = Customer.objects.create(user=users.create_user("other"))
|
||||
cls.other = HostingAccount.objects.create(
|
||||
name="Other site",
|
||||
primary_domain="other.example.test",
|
||||
customer=cls.customer,
|
||||
)
|
||||
|
||||
def setUp(self):
|
||||
self.client.force_login(self.operator)
|
||||
self.url = reverse("panel:account_create")
|
||||
self.data = {
|
||||
"name": "Own website",
|
||||
"primary_domain": "own.example.test",
|
||||
"own_hosting": "on",
|
||||
}
|
||||
|
||||
def verify_operator(self):
|
||||
session = self.client.session
|
||||
session["otp_device_id"] = self.device.persistent_id
|
||||
session.save()
|
||||
|
||||
def test_current_login_can_manage_its_own_accounts_as_customer(self):
|
||||
self.verify_operator()
|
||||
self.assertContains(self.client.get(self.url), "For my own hosting")
|
||||
for domain in ("own.example.test", "second.example.test"):
|
||||
response = self.client.post(
|
||||
self.url, self.data | {"primary_domain": domain}
|
||||
)
|
||||
account = HostingAccount.objects.get(primary_domain=domain)
|
||||
self.assertRedirects(response, account.get_absolute_url())
|
||||
self.assertEqual(account.customer.user_id, self.operator.pk)
|
||||
self.assertEqual(
|
||||
Customer.objects.filter(user=self.operator).count(), 1
|
||||
)
|
||||
self.assertEqual(
|
||||
LogEntry.objects.filter(
|
||||
user=self.operator, action_flag=ADDITION
|
||||
).count(),
|
||||
1,
|
||||
)
|
||||
self.assertFalse(PanelInvitation.objects.exists())
|
||||
response = self.client.post(
|
||||
reverse("panel:switch_panel_role"), {"role": "customer"}
|
||||
)
|
||||
self.assertRedirects(response, reverse("panel:accounts"))
|
||||
page = self.client.get(reverse("panel:accounts"))
|
||||
self.assertContains(page, "own.example.test")
|
||||
self.assertContains(page, "second.example.test")
|
||||
self.assertNotContains(page, "other.example.test")
|
||||
self.assertEqual(
|
||||
self.client.get(self.other.get_absolute_url()).status_code, 404
|
||||
)
|
||||
self.assertEqual(self.client.get(self.url).status_code, 403)
|
||||
|
||||
def test_own_hosting_cannot_override_an_explicit_customer(self):
|
||||
self.verify_operator()
|
||||
response = self.client.post(
|
||||
self.url, self.data | {"customer": self.customer.pk}
|
||||
)
|
||||
self.assertContains(response, "Leave Customer unassigned")
|
||||
self.assertFalse(Customer.objects.filter(user=self.operator).exists())
|
||||
self.assertEqual(HostingAccount.objects.count(), 1)
|
||||
|
||||
def test_reserved_domain_rolls_back_the_customer_role(self):
|
||||
self.verify_operator()
|
||||
self.other.website_domains.create(domain=self.data["primary_domain"])
|
||||
response = self.client.post(self.url, self.data)
|
||||
self.assertContains(response, "This domain is unavailable.")
|
||||
self.assertFalse(Customer.objects.filter(user=self.operator).exists())
|
||||
self.assertFalse(LogEntry.objects.filter(user=self.operator).exists())
|
||||
self.assertEqual(HostingAccount.objects.count(), 1)
|
||||
|
||||
def test_unverified_operator_cannot_create_a_customer_role(self):
|
||||
self.assertNotContains(self.client.get(self.url), "For my own hosting")
|
||||
self.assertEqual(
|
||||
self.client.post(self.url, self.data).status_code, 403
|
||||
)
|
||||
self.assertFalse(Customer.objects.filter(user=self.operator).exists())
|
||||
self.assertEqual(HostingAccount.objects.count(), 1)
|
||||
@@ -2,6 +2,7 @@ from operator import attrgetter
|
||||
|
||||
from django import forms
|
||||
from django.conf import settings
|
||||
from django.contrib.admin.models import ADDITION, LogEntry
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.contrib.auth.mixins import PermissionRequiredMixin
|
||||
from django.core.exceptions import PermissionDenied, ValidationError
|
||||
@@ -458,6 +459,15 @@ class AccountCreate(PermissionRequiredMixin, AccountEditor, CreateView):
|
||||
def get_form(self, form_class=None):
|
||||
form = super().get_form(form_class)
|
||||
actor = self.request.user
|
||||
if actor.is_superuser and actor.is_verified():
|
||||
form.fields["own_hosting"] = forms.BooleanField(
|
||||
label="For my own hosting",
|
||||
help_text=(
|
||||
"Leave Customer unassigned to use your current login "
|
||||
"in the Customer workspace."
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
reseller = reseller_for_user(actor) is not None
|
||||
defaults = zone_defaults()
|
||||
web = panel_feature_allowed("LOCAL_WEB_ACTIVATION") and (
|
||||
@@ -516,14 +526,35 @@ class AccountCreate(PermissionRequiredMixin, AccountEditor, CreateView):
|
||||
return initial
|
||||
|
||||
def form_valid(self, form):
|
||||
reseller = reseller_for_user(self.request.user)
|
||||
actor = self.request.user
|
||||
if self.request.POST.get("own_hosting") and (
|
||||
"own_hosting" not in form.fields
|
||||
):
|
||||
raise PermissionDenied
|
||||
own_hosting = form.cleaned_data.get("own_hosting")
|
||||
if own_hosting and form.cleaned_data.get("customer"):
|
||||
form.add_error(
|
||||
"customer", "Leave Customer unassigned for your own hosting."
|
||||
)
|
||||
return self.form_invalid(form)
|
||||
reseller = reseller_for_user(actor)
|
||||
self.object = form.save(commit=False)
|
||||
try:
|
||||
with transaction.atomic():
|
||||
if reseller is None:
|
||||
save_operator_account(
|
||||
self.object, self.request.user.get_username()
|
||||
if own_hosting:
|
||||
customer, created = Customer.objects.get_or_create(
|
||||
user_id=actor.pk
|
||||
)
|
||||
self.object.customer = customer
|
||||
if created:
|
||||
LogEntry.objects.log_actions(
|
||||
actor.pk,
|
||||
[customer],
|
||||
ADDITION,
|
||||
"Assigned Customer role for own hosting.",
|
||||
)
|
||||
if reseller is None:
|
||||
save_operator_account(self.object, actor.get_username())
|
||||
else:
|
||||
create_reseller_account(reseller, self.object)
|
||||
setup_new_account(self.object, form.cleaned_data)
|
||||
|
||||
Reference in new issue
Block a user