1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-03 17:36:05 +00:00

fix(ui): forms ask one thing at a time, offer the host's pools and say less twice

- A backup schedule asks Which VMs first (a compute's, chosen VMs or a
  tag's) and shows that one field only (policy_scope.js); the other two
  are not read, so a choice left in them is neither saved nor an error.
- A backup target's, a restore's and a disk restore's storage pool
  field offers the chosen compute's active file pools, the ones a
  restore copies into (a target's: directory and NFS only), from
  vmbackups.views.pools, which reads them without a refresh
  (pool_choices.js); a name can still be typed and is checked as before.
- A field's label is no longer repeated inside it as a placeholder, and
  a list's empty choice says Choose… instead of Django's dashes
  (webvirtcloud.bootstrap.FieldRenderer).
- The schedule, target, e-mail OTP and VM delete forms put Cancel and
  their main button at the right, as the other forms do.
This commit is contained in:
catborise 2026-11-22 00:09:10 +03:00
parent 7359fbb147
commit 4881c3cd3e
23 changed files with 228 additions and 69 deletions

View file

@ -7,6 +7,7 @@ from django.db import transaction
from django.conf import settings
from django.core.paginator import Paginator
from django.db.models import Count
from django.http import JsonResponse
from django.shortcuts import get_object_or_404, redirect, render
from django.urls import reverse
from django.utils import timezone
@ -14,8 +15,10 @@ from django.views.decorators.http import require_POST
from django.utils.translation import gettext_lazy as _
from django.utils.translation import gettext_noop
from libvirt import libvirtError
from lxml import etree
from admin.decorators import superuser_only
from computes.models import Compute
from instances.jobs import unprotected
from instances.models import Instance, InstanceTombstone
from instances.views import get_instance
@ -194,6 +197,22 @@ def create(request, instance_id):
return redirect(page)
@superuser_only
def pools(request, compute_id):
"""The compute's active pools that keep disks as files (vrtManager file_pools: where a restore
copies them), each with its type, for a form's pool suggestions (pool_choices.js); ?types=dir,netfs
keeps those types only. Read as they are, not refreshed; none from a host not reached."""
compute = get_object_or_404(Compute, pk=compute_id)
types = request.GET.get("types", "").split(",")
try:
found = [{"name": name, "type": etree.fromstring(pool.XMLDesc(0)).get("type")}
for name, (pool, _path) in wvmConnect(compute.hostname, compute.login, compute.password,
compute.type).file_pools().items()]
except libvirtError:
found = []
return JsonResponse([p for p in sorted(found, key=lambda p: p["name"]) if not types[0] or p["type"] in types], safe=False)
@superuser_only
def index(request):
"""Every backup, newest first; filtered by VM name, target and state."""