Skip to content

Commit

Permalink
Fixes #17969: Fix system info export when a config revision exists
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremystretch authored and jsenecal committed Nov 12, 2024
1 parent 4ca156d commit 7daac5c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
29 changes: 29 additions & 0 deletions netbox/core/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
6 changes: 1 addition & 5 deletions netbox/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 7daac5c

Please sign in to comment.