mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-11 12:46:49 +00:00
fix(instances): the delete page names the host only where hosts are shown
The confirmation page put "on <host>" in its heading for every owner who may delete the VM, while the VM list and page show the host only to superusers and users with view_instances. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Kk4h2TcUiaWmU5MUszYSea
This commit is contained in:
parent
0cee65805d
commit
f18287d3b8
2 changed files with 11 additions and 1 deletions
|
|
@ -4,7 +4,7 @@
|
|||
{% block title %}{% blocktrans with name=instance.name %}Destroy {{ name }}{% endblocktrans %}{% endblock title %}
|
||||
|
||||
{% block page_heading %}
|
||||
{% blocktrans with name=instance.name %}Destroy {{ name }}{% endblocktrans %} <small class="text-body-secondary fs-6">{% blocktrans with host=instance.compute.name %}on {{ host }}{% endblocktrans %}</small>
|
||||
{% blocktrans with name=instance.name %}Destroy {{ name }}{% endblocktrans %}{% if perms.instances.view_instances %} <small class="text-body-secondary fs-6">{% blocktrans with host=instance.compute.name %}on {{ host }}{% endblocktrans %}</small>{% endif %}
|
||||
{% endblock page_heading %}
|
||||
|
||||
{% block content %}
|
||||
|
|
|
|||
|
|
@ -236,6 +236,16 @@ class DestroyOrderTestCase(TransactionTestCase):
|
|||
response = self.client.get(reverse("instances:destroy", args=[self.instance.id]))
|
||||
self.assertEqual(b"Its TPM state is deleted" in response.content, shown)
|
||||
|
||||
def test_the_confirmation_page_names_the_host_only_to_whom_the_app_shows_hosts(self):
|
||||
owner = get_user_model().objects.create_user("destroy_owner", password="pw")
|
||||
self.instance.userinstance_set.create(user=owner, is_delete=True)
|
||||
for user, shown in ((self.admin, True), (owner, False)):
|
||||
with self.subTest(user=user.username), patch("instances.models.wvmInstance"):
|
||||
self.client.force_login(user)
|
||||
response = self.client.get(reverse("instances:destroy", args=[self.instance.id]))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual("on destroy-compute" in response.content.decode(), shown)
|
||||
|
||||
def test_the_confirmation_page_of_a_paused_vm_offers_the_form(self):
|
||||
with patch("instances.models.wvmInstance") as wvm:
|
||||
wvm.return_value.get_status.return_value = 3 # paused
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue