mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Fixes #14613: Fix display of current configuration parameters
This commit is contained in:
@ -1,4 +1,5 @@
|
|||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
|
from django.core.cache import cache
|
||||||
from django.shortcuts import get_object_or_404, redirect
|
from django.shortcuts import get_object_or_404, redirect
|
||||||
|
|
||||||
from extras.models import ConfigRevision
|
from extras.models import ConfigRevision
|
||||||
@ -153,9 +154,11 @@ class ConfigView(generic.ObjectView):
|
|||||||
queryset = ConfigRevision.objects.all()
|
queryset = ConfigRevision.objects.all()
|
||||||
|
|
||||||
def get_object(self, **kwargs):
|
def get_object(self, **kwargs):
|
||||||
if config := self.queryset.first():
|
revision_id = cache.get('config_version')
|
||||||
return config
|
try:
|
||||||
# Instantiate a dummy default config if none has been created yet
|
return ConfigRevision.objects.get(pk=revision_id)
|
||||||
return ConfigRevision(
|
except ConfigRevision.DoesNotExist:
|
||||||
data=get_config().defaults
|
# Fall back to using the active config data if no record is found
|
||||||
)
|
return ConfigRevision(
|
||||||
|
data=get_config()
|
||||||
|
)
|
||||||
|
Reference in New Issue
Block a user