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

fix(templates): each confirmation says what its action does

Twenty-five prompts asked only "Are you sure?", and on the storage page
one handler asked the same before every button, Start and Enable
included. Each destructive button now names its object and says what
happens: a stopped network cuts running VMs off, a deleted pool keeps
its files, a deleted volume loses its data, a reverted snapshot loses
the changes made since. Saves no longer ask, and disabled buttons lose
prompts they could not show. The VM QoS messages said to restart the
network where the VM has to be powered off and on.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
catborise 2026-10-21 21:13:35 +03:00
parent bf6b736aef
commit 2144b3fe20
12 changed files with 70 additions and 49 deletions

View file

@ -0,0 +1,29 @@
"""A confirmation says what its action does: every prompt in a template is the
button's own data-confirm text, shown by return confirm(this.dataset.confirm)."""
from pathlib import Path
from django.conf import settings
from django.test import SimpleTestCase
ONCLICK = 'onclick="return confirm(this.dataset.confirm)"'
class ConfirmPromptTests(SimpleTestCase):
def test_every_prompt_is_the_buttons_own_text(self):
base = Path(settings.BASE_DIR)
templates = [*base.glob("*/templates/**/*.html"), *base.glob("templates/**/*.html")]
self.assertTrue(templates)
for path in templates:
text = path.read_text()
at = text.find("confirm(")
while at != -1:
# the tag around it: prompt texts and template tags hold no < or >
tag = text[text.rfind("<", 0, at):text.find(">", at) + 1]
with self.subTest(template=str(path.relative_to(base)), tag=tag[:60]):
self.assertRegex(tag, r"^<(button|input|a)\b")
self.assertIn(ONCLICK, tag)
self.assertIn('data-confirm="', tag)
self.assertNotIn('data-confirm=""', tag)
self.assertNotIn("Are you sure", tag)
at = text.find("confirm(", at + 1)