mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 01:16:10 +00:00
fix(ui): a block or a job's cancel asks first; every delete and save says it is done
- Block in the Users list asks first: the user is signed out and their API tokens are deleted, which unblocking does not bring back. Block and Unblock then say what they did. - Cancel on a job's page and in the job panel asks first, naming the job; the button says Cancel the job, apart from the dialog's Cancel. - Deleting a user or a group, removing a host from the panel or an owner from a VM, and deleting an interface, a network filter or a secret say so, as the other deletes do. - Renaming a tag and saving a VM's title and description say so.
This commit is contained in:
parent
00a44f7621
commit
e79817e7db
22 changed files with 247 additions and 39 deletions
|
|
@ -113,6 +113,32 @@ class AdminTestCase(TestCase):
|
|||
self.assertEqual(Client().get("/api/v1/instances/", HTTP_AUTHORIZATION=f"Token {token}").status_code, 401)
|
||||
self.assertFalse(ApiToken.objects.filter(user=user).exists())
|
||||
|
||||
def test_a_block_is_asked_first_and_each_change_is_said(self):
|
||||
from django.contrib.messages import get_messages
|
||||
|
||||
from computes.models import Tag
|
||||
|
||||
def said(response): # this response's messages; the next one starts afresh
|
||||
self.client.cookies.pop("messages", None)
|
||||
return [str(m) for m in get_messages(response.wsgi_request)]
|
||||
|
||||
user = User.objects.create_user("asked", password="Wvc-asked-9")
|
||||
page = html.fromstring(self.client.get(reverse("admin:user_list")).content)
|
||||
(block,) = page.xpath("//form[@action=$u]/button", u=reverse("admin:user_block", args=[user.id]))
|
||||
self.assertIn("API tokens are deleted", block.get("data-confirm"))
|
||||
self.assertEqual(said(self.client.post(reverse("admin:user_block", args=[user.id]))),
|
||||
["asked is blocked: signed out, API tokens deleted"])
|
||||
page = html.fromstring(self.client.get(reverse("admin:user_list")).content)
|
||||
(unblock,) = page.xpath("//form[@action=$u]/button", u=reverse("admin:user_unblock", args=[user.id]))
|
||||
self.assertIsNone(unblock.get("data-confirm"))
|
||||
self.assertEqual(said(self.client.post(reverse("admin:user_unblock", args=[user.id]))), ["asked may sign in again"])
|
||||
self.assertEqual(said(self.client.post(reverse("admin:user_delete", args=[user.id]))), ["User asked deleted"])
|
||||
group = Group.objects.create(name="said")
|
||||
self.assertEqual(said(self.client.post(reverse("admin:group_delete", args=[group.id]))), ["Group said deleted"])
|
||||
tag = Tag.objects.create(name="old-name")
|
||||
self.assertEqual(said(self.client.post(reverse("admin:tag_update", args=[tag.id]), {"name": "new-name"})),
|
||||
["Tag old-name renamed to new-name"])
|
||||
|
||||
def test_users(self):
|
||||
response = self.client.get(reverse("admin:user_create"))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue