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

inject origional context as obj_context

This commit is contained in:
John Anderson
2020-03-17 00:03:58 -04:00
parent 2522b88fc6
commit 457354c244
2 changed files with 24 additions and 19 deletions

View File

@@ -18,15 +18,20 @@ class PluginTemplateContent:
"""
model = None
def __init__(self, obj):
def __init__(self, obj, context):
self.obj = obj
self.context = context
def render(self, template, extra_context=None):
"""
Convenience menthod for rendering the provided template name. The detail page object is automatically
passed into the template context as `obj` but an additional context dictionary may be passed as `extra_context`.
passed into the template context as `obj` and the origional detail page's context is available as
`obj_context`. An additional context dictionary may be passed as `extra_context`.
"""
context = {'obj': self.obj}
context = {
'obj': self.obj,
'obj_context': self.context
}
if isinstance(extra_context, dict):
context.update(extra_context)