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

fix(tags): the Tags page lists the tags by name and has a search box

The list counts each tag's VMs and hosts; a query with a count leaves
the model's ordering out, so the tags came in the order they were made.
With dozens of tags the page also gets the search box the other
administration lists have.
This commit is contained in:
catborise 2026-11-19 13:36:39 +03:00
parent a5d0dbfe66
commit 0a99713dda
7 changed files with 103 additions and 63 deletions

View file

@ -30,6 +30,14 @@ class TagAdminTests(TestCase):
self.assertEqual([(t.name, t.vm_count, t.host_count) for t in response.context["tags"]], [("prod", 1, 1)])
self.assertContains(response, 'class="badge tag-badge') # as small as on the other pages
def test_the_list_is_in_name_order_and_searched(self):
Tag.objects.create(name="web")
Tag.objects.create(name="db")
response = self.client.get(reverse("admin:tag_list"))
self.assertEqual([t.name for t in response.context["tags"]], ["db", "prod", "web"])
self.assertContains(response, 'id="filter"')
self.assertContains(response, 'data-search="web"')
def test_a_rename_keeps_the_tag_on_its_vms_hosts_and_removed_vms(self):
self.client.post(reverse("admin:tag_update", args=[self.prod.pk]), {"name": "Live"})
self.prod.refresh_from_db()