mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-24 17:38:37 -06:00
Fixes #12144: Ensure consistent treatment of context data when rendering config templates via UI & API
This commit is contained in:
parent
f245f07fd9
commit
2805633b16
@ -77,6 +77,7 @@ Two new webhook trigger events have been introduced: `job_start` and `job_end`.
|
|||||||
* [#12109](https://github.com/netbox-community/netbox/issues/12109) - Fix migration error when replicating more than 100 job results
|
* [#12109](https://github.com/netbox-community/netbox/issues/12109) - Fix migration error when replicating more than 100 job results
|
||||||
* [#12112](https://github.com/netbox-community/netbox/issues/12112) - Do not link data source URL for local paths
|
* [#12112](https://github.com/netbox-community/netbox/issues/12112) - Do not link data source URL for local paths
|
||||||
* [#12115](https://github.com/netbox-community/netbox/issues/12115) - Fix rendering config templates from a data file
|
* [#12115](https://github.com/netbox-community/netbox/issues/12115) - Fix rendering config templates from a data file
|
||||||
|
* [#12144](https://github.com/netbox-community/netbox/issues/12144) - Ensure consistent treatment of context data when rendering config templates via UI & API
|
||||||
* [#12146](https://github.com/netbox-community/netbox/issues/12146) - Do not display object selector for disabled fields
|
* [#12146](https://github.com/netbox-community/netbox/issues/12146) - Do not display object selector for disabled fields
|
||||||
|
|
||||||
### Other Changes
|
### Other Changes
|
||||||
|
@ -423,9 +423,13 @@ class DeviceViewSet(ConfigContextQuerySetMixin, ConfigTemplateRenderMixin, NetBo
|
|||||||
configtemplate = device.get_config_template()
|
configtemplate = device.get_config_template()
|
||||||
if not configtemplate:
|
if not configtemplate:
|
||||||
return Response({'error': 'No config template found for this device.'}, status=HTTP_400_BAD_REQUEST)
|
return Response({'error': 'No config template found for this device.'}, status=HTTP_400_BAD_REQUEST)
|
||||||
context = {**request.data, 'device': device}
|
|
||||||
|
|
||||||
return self.render_configtemplate(request, configtemplate, context)
|
# Compile context data
|
||||||
|
context_data = device.get_config_context()
|
||||||
|
context_data.update(request.data)
|
||||||
|
context_data.update({'device': device})
|
||||||
|
|
||||||
|
return self.render_configtemplate(request, configtemplate, context_data)
|
||||||
|
|
||||||
|
|
||||||
class VirtualDeviceContextViewSet(NetBoxModelViewSet):
|
class VirtualDeviceContextViewSet(NetBoxModelViewSet):
|
||||||
|
@ -2010,10 +2010,8 @@ class DeviceRenderConfigView(generic.ObjectView):
|
|||||||
|
|
||||||
def get_extra_context(self, request, instance):
|
def get_extra_context(self, request, instance):
|
||||||
# Compile context data
|
# Compile context data
|
||||||
context_data = {
|
context_data = instance.get_config_context()
|
||||||
'device': instance,
|
context_data.update({'device': instance})
|
||||||
}
|
|
||||||
context_data.update(**instance.get_config_context())
|
|
||||||
|
|
||||||
# Render the config template
|
# Render the config template
|
||||||
rendered_config = None
|
rendered_config = None
|
||||||
|
Loading…
Reference in New Issue
Block a user