Compare commits
3
Commits
165f3cf7db
...
1c3ee425d1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1c3ee425d1 | ||
|
|
006c85d327 | ||
|
|
d9a85fd8d7 |
No files matched your search
@@ -66,6 +66,9 @@ jobs:
|
||||
python tools/check_core_release.py dist/*.tar.gz dist/*.whl
|
||||
python tools/build_deb.py dist/*.tar.gz dist/*.whl
|
||||
umask 077
|
||||
python tools/build_deb.py dist/*.tar.gz dist/*.whl --output rebuilt
|
||||
git -c user.name='Coulobre CI' -c user.email='ci@hippogrief.nl' \
|
||||
tag --annotate coulobre-ci-artifacts -m 'Verify tagged build'
|
||||
python tools/build_deb.py dist/*.tar.gz dist/*.whl \
|
||||
--ref coulobre-ci-artifacts --output rebuilt
|
||||
cmp dist/*.deb rebuilt/*.deb
|
||||
dpkg-deb --info dist/*.deb
|
||||
+8
-5
@@ -145,22 +145,25 @@ and installs the selected operating system services and Python dependencies.
|
||||
### Use the Gitea APT repository
|
||||
|
||||
Use the `resolute` suite on Ubuntu 26.04 or `trixie` on Debian 13. The `main`
|
||||
component carries final releases. Add `candidate` to the component list on a
|
||||
test host to opt in to release candidates. A version like `0.13.0~rc1` sorts
|
||||
before `0.13.0` in APT.
|
||||
component carries final releases. Use `candidate` on a test host to opt in to
|
||||
release candidates. A version like `0.13.0~rc1` sorts before `0.13.0` in APT.
|
||||
|
||||
```sh
|
||||
suite=resolute
|
||||
component=main
|
||||
registry=https://code.hosting.hippogrief.nl/api/packages/hippogrief/debian
|
||||
sudo install -d -m 0755 /etc/apt/keyrings
|
||||
sudo curl -fsS "$registry/repository.key" -o /etc/apt/keyrings/hippogrief.asc
|
||||
sudo chmod 0644 /etc/apt/keyrings/hippogrief.asc
|
||||
printf 'deb [signed-by=/etc/apt/keyrings/hippogrief.asc] %s %s main\n' \
|
||||
"$registry" "$suite" | sudo tee /etc/apt/sources.list.d/hippogrief.list
|
||||
printf 'deb [signed-by=/etc/apt/keyrings/hippogrief.asc] %s %s %s\n' \
|
||||
"$registry" "$suite" "$component" | sudo tee /etc/apt/sources.list.d/hippogrief.list
|
||||
sudo apt update
|
||||
sudo apt install coulobre-panel
|
||||
```
|
||||
|
||||
Set `component=candidate` when testing a release candidate. Gitea adds the
|
||||
`main` component to each suite when its first final package is published.
|
||||
|
||||
[Gitea Debian registry documentation](https://docs.gitea.com/usage/packages/debian/)
|
||||
|
||||
### Upgrade an installer-managed panel
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "coulobre-panel"
|
||||
version = "0.13.0rc1"
|
||||
version = "0.13.0rc2"
|
||||
description = "A web hosting control panel for hosting providers and resellers."
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.12"
|
||||
|
||||
@@ -22,8 +22,13 @@ from .models import Customer, Reseller, ResellerProfile
|
||||
SESSION_ROLE = "coulobre_panel_role"
|
||||
ROLE_LABELS = {
|
||||
PanelRole.ADMIN: "Server administrator",
|
||||
PanelRole.CUSTOMER: "Customer",
|
||||
PanelRole.MANAGER: "Manager",
|
||||
PanelRole.CUSTOMER: "Customer",
|
||||
}
|
||||
ROLE_SWITCH_DETAILS = {
|
||||
PanelRole.ADMIN: ("shield", "Server and all accounts"),
|
||||
PanelRole.MANAGER: ("resellers", "Customers you manage"),
|
||||
PanelRole.CUSTOMER: ("customers", "Your own hosting"),
|
||||
}
|
||||
|
||||
|
||||
@@ -126,8 +131,12 @@ class PanelRoleMiddleware:
|
||||
return redirect("panel:login")
|
||||
|
||||
request.active_panel_role = role
|
||||
request.panel_role_label = ROLE_LABELS[role]
|
||||
request.panel_role_icon = ROLE_SWITCH_DETAILS[role][0]
|
||||
request.panel_role_options = [
|
||||
(option, ROLE_LABELS[option]) for option in roles
|
||||
(option, ROLE_LABELS[option], *ROLE_SWITCH_DETAILS[option])
|
||||
for option in PanelRole
|
||||
if option in roles
|
||||
]
|
||||
request.user = scoped_user(user, role)
|
||||
|
||||
|
||||
@@ -33,18 +33,19 @@ updateMenuLayout();
|
||||
|
||||
const roleSwitch = document.querySelector("[data-role-switch]");
|
||||
if (roleSwitch) {
|
||||
const picker = roleSwitch.querySelector("select");
|
||||
const currentRole = picker.value;
|
||||
roleSwitch.classList.add("role-switch-on-change");
|
||||
roleSwitch.querySelector("button").hidden = true;
|
||||
picker.setAttribute("aria-label", "Panel role (switches when selected)");
|
||||
picker.addEventListener("change", () => {
|
||||
if (picker.value !== currentRole) {
|
||||
roleSwitch.requestSubmit();
|
||||
roleSwitch.addEventListener("keydown", event => {
|
||||
if (event.key === "Escape" && roleSwitch.open) {
|
||||
roleSwitch.open = false;
|
||||
roleSwitch.querySelector("summary").focus();
|
||||
}
|
||||
});
|
||||
document.addEventListener("click", event => {
|
||||
if (roleSwitch.open && !roleSwitch.contains(event.target)) {
|
||||
roleSwitch.open = false;
|
||||
}
|
||||
});
|
||||
window.addEventListener("pageshow", () => {
|
||||
picker.value = currentRole;
|
||||
roleSwitch.open = false;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -329,25 +329,102 @@ a.sidebar-identity:hover {
|
||||
}
|
||||
|
||||
.panel-role-switch {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto;
|
||||
gap: 0.35rem;
|
||||
position: relative;
|
||||
font-size: 0.82rem;
|
||||
}
|
||||
|
||||
.panel-role-switch.role-switch-on-change {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.panel-role-switch select {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
.panel-role-switch summary {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.45rem;
|
||||
min-height: 2.2rem;
|
||||
background: var(--sidebar-active);
|
||||
color: var(--sidebar-text);
|
||||
border: 1px solid var(--sidebar-control-line);
|
||||
border-radius: 6px;
|
||||
padding: 0.35rem 0.45rem;
|
||||
padding: 0.35rem 0.55rem;
|
||||
cursor: pointer;
|
||||
font-weight: 650;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.panel-role-switch summary::-webkit-details-marker {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.panel-role-switch summary::after {
|
||||
width: 0.45rem;
|
||||
height: 0.45rem;
|
||||
flex: 0 0 auto;
|
||||
margin-inline-start: auto;
|
||||
margin-inline-end: 0.15rem;
|
||||
border-inline-end: 1.5px solid currentColor;
|
||||
border-block-end: 1.5px solid currentColor;
|
||||
content: "";
|
||||
transform: translateY(-0.1rem) rotate(45deg);
|
||||
}
|
||||
|
||||
.panel-role-switch[open] summary::after {
|
||||
transform: translateY(0.1rem) rotate(225deg);
|
||||
}
|
||||
|
||||
.panel-role-options {
|
||||
position: absolute;
|
||||
z-index: 3;
|
||||
inset-block-end: calc(100% + 0.4rem);
|
||||
inset-inline-start: 0;
|
||||
display: grid;
|
||||
width: max(100%, 16rem);
|
||||
max-height: 55dvh;
|
||||
overflow-y: auto;
|
||||
padding: 0.25rem;
|
||||
border: 1px solid var(--sidebar-control-line);
|
||||
border-radius: 8px;
|
||||
background: var(--sidebar);
|
||||
box-shadow: 0 4px 14px #0004;
|
||||
}
|
||||
|
||||
.panel-role-option {
|
||||
display: grid;
|
||||
grid-template-columns: auto minmax(0, 1fr) auto;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
padding: 0.5rem;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 5px;
|
||||
background: transparent;
|
||||
color: var(--sidebar-text);
|
||||
text-align: start;
|
||||
}
|
||||
|
||||
.panel-role-option:enabled {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.panel-role-option:hover:enabled,
|
||||
.panel-role-option[aria-current] {
|
||||
border-color: var(--sidebar-line);
|
||||
background: var(--sidebar-active);
|
||||
}
|
||||
|
||||
.sidebar .panel-role-option:focus-visible {
|
||||
outline-offset: -2px;
|
||||
}
|
||||
|
||||
.panel-role-option strong,
|
||||
.panel-role-option small {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.panel-role-option small {
|
||||
color: var(--sidebar-account);
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
.panel-role-current {
|
||||
color: var(--sidebar-highlight);
|
||||
font-size: 0.75rem;
|
||||
font-weight: 650;
|
||||
}
|
||||
|
||||
.sidebar-action {
|
||||
@@ -1069,6 +1146,14 @@ dd {
|
||||
margin: 0;
|
||||
padding-top: 0.6rem;
|
||||
}
|
||||
|
||||
.panel-role-options {
|
||||
inset-block-start: calc(100% + 0.4rem);
|
||||
inset-block-end: auto;
|
||||
inset-inline-start: auto;
|
||||
inset-inline-end: 0;
|
||||
max-width: calc(100vw - 1.5rem);
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 520px) and (max-width: 780px) {
|
||||
|
||||
@@ -51,16 +51,25 @@
|
||||
</form>
|
||||
</div>
|
||||
{% if not request.impersonation and request.panel_role_options|length > 1 %}
|
||||
<form method="post" class="panel-role-switch" action="{% url 'panel:switch_panel_role' %}" data-role-switch>
|
||||
{% csrf_token %}
|
||||
<label class="visually-hidden" for="panel-role">Panel role</label>
|
||||
<select name="role" id="panel-role">
|
||||
{% for value, label in request.panel_role_options %}
|
||||
<option value="{{ value }}"{% if request.active_panel_role == value %} selected{% endif %}>{{ label }}</option>
|
||||
<details class="panel-role-switch" data-role-switch>
|
||||
<summary aria-label="Switch role from {{ request.panel_role_label }}">
|
||||
<svg class="nav-icon" aria-hidden="true" focusable="false"><use href="{{ panel_icons }}#{{ request.panel_role_icon }}"></use></svg>
|
||||
{{ request.panel_role_label }}
|
||||
</summary>
|
||||
<form method="post" class="panel-role-options" action="{% url 'panel:switch_panel_role' %}">
|
||||
{% csrf_token %}
|
||||
{% for value, label, icon, description in request.panel_role_options %}
|
||||
<button class="panel-role-option" type="submit" name="role" value="{{ value }}"{% if request.active_panel_role == value %} aria-current="true" disabled{% endif %}>
|
||||
<svg class="nav-icon" aria-hidden="true" focusable="false"><use href="{{ panel_icons }}#{{ icon }}"></use></svg>
|
||||
<span>
|
||||
<strong>{{ label }}</strong>
|
||||
<small>{{ description }}</small>
|
||||
</span>
|
||||
{% if request.active_panel_role == value %}<span class="panel-role-current">Current</span>{% endif %}
|
||||
</button>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<button class="sidebar-action" type="submit">Switch role</button>
|
||||
</form>
|
||||
</form>
|
||||
</details>
|
||||
{% endif %}
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
@@ -92,6 +92,22 @@ class PanelRoleTests(TestCase):
|
||||
self.assertEqual(self.switch("administrator").status_code, 403)
|
||||
self.assertEqual(self.switch("forged-role").status_code, 403)
|
||||
|
||||
def test_switcher_orders_workspaces_and_identifies_the_current_role(self):
|
||||
self.sign_in()
|
||||
self.assertEqual(self.switch("customer").status_code, 302)
|
||||
response = self.client.get(reverse("panel:accounts"))
|
||||
self.assertEqual(
|
||||
[role for role, *_ in response.wsgi_request.panel_role_options],
|
||||
[PanelRole.ADMIN, PanelRole.MANAGER, PanelRole.CUSTOMER],
|
||||
)
|
||||
self.assertContains(response, 'aria-label="Switch role from Customer"')
|
||||
self.assertContains(response, "Server and all accounts")
|
||||
self.assertContains(response, "Customers you manage")
|
||||
self.assertContains(response, "Your own hosting")
|
||||
self.assertContains(
|
||||
response, 'value="customer" aria-current="true" disabled'
|
||||
)
|
||||
|
||||
def test_removed_assignment_signs_out_before_processing_request(self):
|
||||
self.sign_in()
|
||||
self.assertEqual(self.switch("manager").status_code, 302)
|
||||
|
||||
@@ -63,9 +63,7 @@ class WorkspaceTests(TestCase):
|
||||
operator = get_user_model().objects.create_superuser("operator")
|
||||
self.client.force_login(operator)
|
||||
landing = self.client.get(reverse("panel:accounts"))
|
||||
self.assertContains(
|
||||
landing, '<option value="manager">Manager</option>', html=True
|
||||
)
|
||||
self.assertContains(landing, 'name="role" value="manager"')
|
||||
profile = Reseller.objects.get(user=operator)
|
||||
unrelated = HostingAccount.objects.create(
|
||||
name="Other hosting", primary_domain="other.test"
|
||||
|
||||
+14
-3
@@ -13,12 +13,23 @@ from check_core_release import ROOT, git_files, verify_release
|
||||
|
||||
|
||||
def build_package(source, wheel, ref, output):
|
||||
verify_release(source, wheel, ref)
|
||||
tracked = git_files(ref)
|
||||
commit = subprocess.check_output(
|
||||
[
|
||||
"git",
|
||||
"rev-parse",
|
||||
"--verify",
|
||||
"--end-of-options",
|
||||
f"{ref}^{{commit}}",
|
||||
],
|
||||
cwd=ROOT,
|
||||
text=True,
|
||||
).strip()
|
||||
verify_release(source, wheel, commit)
|
||||
tracked = git_files(commit)
|
||||
project = tomllib.loads(tracked["pyproject.toml"].decode())["project"]
|
||||
version = project["version"].replace("rc", "~rc")
|
||||
epoch = subprocess.check_output(
|
||||
["git", "show", "-s", "--format=%ct", ref], cwd=ROOT, text=True
|
||||
["git", "show", "-s", "--format=%ct", commit], cwd=ROOT, text=True
|
||||
).strip()
|
||||
output.mkdir(parents=True, exist_ok=True)
|
||||
target = output / f"coulobre-panel_{version}_all.deb"
|
||||
|
||||
Reference in new issue
Block a user