(feature) show latest snapshot on the Django dashboard
Add latest snapshot context to each dashboard host row so imported legacy snapshots are visible without opening every host page. Link the latest snapshot directly to its detail page and show its kind and status beside the host snapshot count. Cover the dashboard latest-snapshot selection with a view test.
This commit is contained in:
@@ -47,6 +47,20 @@ class ViewTests(TestCase):
|
||||
self.assertContains(response, "20260519-021500Z__ABCDEFGH")
|
||||
self.assertContains(response, "success")
|
||||
|
||||
def test_dashboard_links_latest_snapshot_for_each_host(self) -> None:
|
||||
self.client.force_login(self.staff_user)
|
||||
host = HostConfig.objects.create(host="web-01", address="web-01.example.test")
|
||||
old_snapshot = self._snapshot(host, "20260518-021500Z__OLDSNAP")
|
||||
latest_snapshot = self._snapshot(host, "20260519-021500Z__NEWSNAP")
|
||||
|
||||
response = self.client.get(reverse("dashboard"))
|
||||
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertContains(response, "Latest Snapshot")
|
||||
self.assertContains(response, latest_snapshot.dirname)
|
||||
self.assertContains(response, reverse("snapshot_detail", args=[latest_snapshot.id]))
|
||||
self.assertNotContains(response, reverse("snapshot_detail", args=[old_snapshot.id]))
|
||||
|
||||
def test_dashboard_prompts_for_global_config_when_database_is_empty(self) -> None:
|
||||
self.client.force_login(self.staff_user)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user