1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Closes #2495: Enable deep-merging of config context data

This commit is contained in:
Jeremy Stretch
2018-12-05 14:34:49 -05:00
parent d3d6c83fbb
commit 686a65880e
4 changed files with 108 additions and 4 deletions

View File

@ -18,7 +18,7 @@ from django.utils.encoding import python_2_unicode_compatible
from django.utils.safestring import mark_safe
from dcim.constants import CONNECTION_STATUS_CONNECTED
from utilities.utils import foreground_color
from utilities.utils import deepmerge, foreground_color
from .constants import *
from .querysets import ConfigContextQuerySet
@ -727,11 +727,11 @@ class ConfigContextModel(models.Model):
# Compile all config data, overwriting lower-weight values with higher-weight values where a collision occurs
data = OrderedDict()
for context in ConfigContext.objects.get_for_object(self):
data.update(context.data)
data = deepmerge(data, context.data)
# If the object has local config context data defined, that data overwrites all rendered data
# If the object has local config context data defined, merge it last
if self.local_context_data is not None:
data.update(self.local_context_data)
data = deepmerge(data, self.local_context_data)
return data