mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-10 20:26:48 +00:00
feat(admin): the admin lists as a people directory, the user form by what it allows
The Users, Groups and Removed VMs pages were bare tables: rows of coloured icon buttons without words, five columns of small checks for a user's role and permissions, dates broken over three lines and a lone "+" for a new entry. The owner chose a directory layout from three rendered options; it follows the host pages' cards: - Each list is a card with its count and search in the header and one list-group item per entry, which stacks on a phone without scrolling. - A user shows their role as a badge (Superuser, Template editor) or "User", Blocked as a red badge, their groups, a granted clone permission and live API tokens, and the last login on one line; role and status are searchable. Edit is the visible action, the menu holds View profile, Block or Unblock and Delete; Block and Delete are disabled on one's own account, which the server refuses anyway. - A group shows its member and permission counts; its name opens it. The page's title said "Users". - A removed VM shows its UUID, the host it left, its owners and when the record was made and expires. - Logs keep their table in a card, the server search in its header, the count of matching rows, Done and Failed as badges, and a message column wide enough to read on a phone. The user form was one long column of horizontal fields. The owner rejected three boxed layouts and chose one led by what the user may do: the Active switch, Template editor and Superuser as two cards, groups as chips, the user's own permissions as switches each saying what it allows, then the name and password and the quota folded into details whose summaries tell their values (-1 as "any"); they open on a new user and on an error inside them. A refused group or permission is said beside its field. The group form follows it: the name, what its members may do, its members as chips. Cancel goes back to the list instead of the browser history.
This commit is contained in:
parent
db3c80b620
commit
3c6de221ca
15 changed files with 477 additions and 260 deletions
|
|
@ -50,7 +50,7 @@ class LogsPageTests(TestCase):
|
|||
def test_the_failed_rows_only_and_marked(self):
|
||||
page = self.page(failed="1")
|
||||
self.assertEqual([row[2] for row in self.rows(page)], ["alice"])
|
||||
self.assertIn("table-danger", page.xpath("//tbody/tr")[0].get("class"))
|
||||
self.assertTrue(page.xpath("//tbody/tr[1]//span[contains(@class, 'text-bg-danger')]"))
|
||||
|
||||
def test_the_pages_keep_the_search(self):
|
||||
page = self.page(q="bob")
|
||||
|
|
|
|||
|
|
@ -38,8 +38,7 @@ class TombstoneTests(TestCase):
|
|||
self.assertContains(response, "ts-vm")
|
||||
self.assertContains(response, UUID)
|
||||
self.assertContains(response, "ts-owner")
|
||||
self.assertContains(response, "<td>ts-host</td>", html=True)
|
||||
self.assertContains(response, '<th scope="col">Host</th>', html=True)
|
||||
self.assertContains(response, '<span class="fw-semibold">ts-host</span>', html=True)
|
||||
|
||||
def test_only_superusers_see_or_remove_them(self):
|
||||
self.client.force_login(self.owner)
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class UserPagesTests(TestCase):
|
|||
def test_the_form_tells_the_password_state_and_links_its_page(self):
|
||||
page = html.fromstring(self.client.get(reverse("admin:user_update", args=[self.alice.pk])).content)
|
||||
text = " ".join(page.text_content().split())
|
||||
self.assertIn("Password Set Change password", text)
|
||||
self.assertIn("Password: Set Change password", text)
|
||||
self.assertNotIn("No password set", text)
|
||||
self.assertEqual(page.xpath("//a[normalize-space()='Change password']/@href"),
|
||||
[reverse("admin:user_update_password", args=[self.alice.pk])])
|
||||
|
|
@ -57,15 +57,35 @@ class UserPagesTests(TestCase):
|
|||
self.assertNotIn("log into this admin site", page)
|
||||
self.assertIn("Max memory (MiB)", page)
|
||||
self.assertIn("Max disk size (GiB)", page)
|
||||
self.assertIn("-1: no limit; 0: none allowed", page)
|
||||
self.assertIn("-1 means no limit, 0 none allowed", page)
|
||||
|
||||
def test_a_refused_choice_is_said_beside_its_field(self):
|
||||
url = reverse("admin:user_update", args=[self.alice.pk])
|
||||
response = self.client.post(url, {"username": "up-alice", "is_active": "on", "groups": "99999", "user_permissions": "99999",
|
||||
"max_instances": 1, "max_cpus": 1, "max_memory": 1, "max_disk_size": 1})
|
||||
page = html.fromstring(response.content)
|
||||
self.assertEqual(len(page.xpath("//fieldset//div[contains(@class, 'invalid-feedback')]")), 2)
|
||||
|
||||
def test_the_folded_quota_says_what_it_allows(self):
|
||||
UserAttributes.objects.filter(user=self.alice).update(max_instances=-1, max_cpus=1, max_memory=2048, max_disk_size=-1)
|
||||
page = html.fromstring(self.client.get(reverse("admin:user_update", args=[self.alice.pk])).content)
|
||||
(summary,) = [s for s in page.xpath("//summary") if "Quota" in s.text_content()]
|
||||
self.assertEqual(" ".join(summary.text_content().split()), "Quota any number of VMs · 1 vCPU · 2048 MiB · any disk size")
|
||||
|
||||
def test_a_missing_users_profile_is_not_found(self):
|
||||
self.assertEqual(self.client.get(reverse("accounts:account", args=[99999])).status_code, 404)
|
||||
|
||||
def test_a_user_who_never_logged_in_says_never(self):
|
||||
page = html.fromstring(self.client.get(reverse("admin:user_list")).content)
|
||||
(row,) = [r for r in page.xpath("//tbody/tr") if r.xpath("td")[0].text_content().strip() == "up-alice"]
|
||||
self.assertEqual(row.xpath("td")[2].text_content().strip(), "never")
|
||||
(row,) = page.xpath("//div[contains(@class, 'list-group-item')][.//a[normalize-space()='up-alice']]")
|
||||
self.assertIn("Last login: never", " ".join(row.text_content().split()))
|
||||
|
||||
def test_the_search_finds_a_user_by_role_and_status(self):
|
||||
self.alice.is_active = False
|
||||
self.alice.save()
|
||||
page = html.fromstring(self.client.get(reverse("admin:user_list")).content)
|
||||
(row,) = page.xpath("//div[contains(@class, 'list-group-item')][.//a[normalize-space()='up-alice']]")
|
||||
self.assertIn("User Blocked", row.get("data-search"))
|
||||
|
||||
def test_a_password_set_by_an_administrator_can_be_one_to_change(self):
|
||||
url = reverse("admin:user_update_password", args=[self.alice.pk])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue