From bf1f1229840078a1e2dc32fa39950b401287a607 Mon Sep 17 00:00:00 2001 From: catborise Date: Wed, 7 Oct 2026 20:29:52 +0300 Subject: [PATCH] fix(instances): the VM page offers only the controls the user may use The page showed controls the backend then refused: power to global viewers, the console, virt-viewer and VDI controls and the root password and SSH key forms to viewers, resize to staff, per-vCPU hotplug, video model and guest agent to non-superusers, clone and options by the clone permission alone, snapshots without change permission. The page now asks the views' own rules (owner, is_change, clone and snapshot permissions, the template rules). OS info, opened from the header, is there for every viewer; the XML editor and tab restoring after a redirect no longer throw when a pane is absent; Settings opens on the first section the user has. The authorization matrix also covers a template VM, the template clone rule and the template snapshot rule. --- instances/templates/instance.html | 98 +++++----- instances/templates/instances/access_tab.html | 18 +- instances/templates/instances/power_tab.html | 4 + instances/templates/instances/resize_tab.html | 8 +- .../templates/instances/settings_tab.html | 21 ++- instances/test_page_controls.py | 169 ++++++++++++++++++ instances/views.py | 15 ++ webvirtcloud/test_authorization_matrix.py | 32 ++++ 8 files changed, 294 insertions(+), 71 deletions(-) create mode 100644 instances/test_page_controls.py diff --git a/instances/templates/instance.html b/instances/templates/instance.html index c5317690..6d6a203c 100644 --- a/instances/templates/instance.html +++ b/instances/templates/instance.html @@ -85,7 +85,7 @@ {% trans "Resize" %} - {% if allow_admin_or_not_template and 'instances.snapshot_instances' in perms %} + {% if can_snapshot %} {% endif %} + {% if show_settings %} + {% endif %} - {% endif %} + {% endif %} + {% if request.user.is_superuser %} {% endif %} - {% if perms.instances.clone_instances %} + {% if can_clone %} {% endif %} - {% if perms.instances.clone_instances %} + {% if can_change %}