From 7daac5cddca530e272689a685e56987d379192ef Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Tue, 12 Nov 2024 12:11:44 -0500 Subject: [PATCH] Fixes #17969: Fix system info export when a config revision exists --- netbox/core/tests/test_views.py | 29 +++++++++++++++++++++++++++++ netbox/core/views.py | 6 +----- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/netbox/core/tests/test_views.py b/netbox/core/tests/test_views.py index 01912b4d6eb..047b51ef64a 100644 --- a/netbox/core/tests/test_views.py +++ b/netbox/core/tests/test_views.py @@ -346,3 +346,32 @@ def test_worker(self): self.assertIn(str(worker1.name), str(response.content)) self.assertIn('Birth', str(response.content)) self.assertIn('Total working time', str(response.content)) + + +class SystemTestCase(TestCase): + + def setUp(self): + super().setUp() + + self.user.is_staff = True + self.user.save() + + def test_system_view_default(self): + # Test UI render + response = self.client.get(reverse('core:system')) + self.assertEqual(response.status_code, 200) + + # Test export + response = self.client.get(f"{reverse('core:system')}?export=true") + self.assertEqual(response.status_code, 200) + + def test_system_view_with_config_revision(self): + ConfigRevision.objects.create() + + # Test UI render + response = self.client.get(reverse('core:system')) + self.assertEqual(response.status_code, 200) + + # Test export + response = self.client.get(f"{reverse('core:system')}?export=true") + self.assertEqual(response.status_code, 200) diff --git a/netbox/core/views.py b/netbox/core/views.py index 3c531962618..ecbf11e32d0 100644 --- a/netbox/core/views.py +++ b/netbox/core/views.py @@ -626,11 +626,7 @@ def get(self, request): } # Configuration - try: - config = ConfigRevision.objects.get(pk=cache.get('config_version')) - except ConfigRevision.DoesNotExist: - # Fall back to using the active config data if no record is found - config = get_config() + config = get_config() # Raw data export if 'export' in request.GET: