1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-11 12:46:49 +00:00

feat(instances): a template's page is a template's

A template's page was a VM's: it opened on Power, with only a note there
that a template is not started, while its clone form waited in a section
of Settings, next to a console, access, snapshots and stats that a VM
that never runs has no use for. A template's page now carries a Template
badge and a Clone button, opens on the clone form, and leaves out Power,
Access, Snapshot, Stats, the console settings, host devices and the
guest agent and address lines; Resize, Settings and Destroy stay for
whoever may change it. A page that no section opens shows its first.
This commit is contained in:
catborise 2026-11-01 22:57:02 +03:00
parent 8a809443a4
commit dbc0115c06
3 changed files with 53 additions and 19 deletions

View file

@ -273,7 +273,8 @@ def _instance_page(request, pk, instance, compute):
keymaps = settings.QEMU_KEYMAPS
# The console form renders the VNC password, so only users who may manage
# console settings get the form (and the password) at all.
can_manage_console = utils.can_manage_console(request.user, instance)
# a template is cloned, not run: no console settings or host devices on its page
can_manage_console = utils.can_manage_console(request.user, instance) and not instance.is_template
console_form = None
if can_manage_console:
console_form = ConsoleForm(instance=instance, is_superuser=request.user.is_superuser)
@ -350,7 +351,8 @@ def _instance_page(request, pk, instance, compute):
for row in pci_hostdevs:
row["name"] = names.get(row["address"], "")
# owners see the devices their VM has; only superusers change them
show_hostdevs = request.user.is_superuser or bool(usb_hostdevs or pci_hostdevs or other_hostdevs)
show_hostdevs = not instance.is_template and (
request.user.is_superuser or bool(usb_hostdevs or pci_hostdevs or other_hostdevs))
show_settings = show_settings or show_hostdevs
# what keeps the Migrate tab from migrating the VM to any destination