mirror of
https://github.com/netbox-community/netbox.git
synced 2026-04-05 00:47:17 +02:00
Pass the value returned by get_context() to should_render()
This commit is contained in:
@@ -64,12 +64,8 @@ class CustomFieldsPanel(panels.ObjectPanel):
|
||||
'custom_fields': obj.get_custom_fields_by_group(),
|
||||
}
|
||||
|
||||
def render(self, context):
|
||||
ctx = self.get_context(context)
|
||||
# Hide the panel if no custom fields exist
|
||||
if not ctx['custom_fields']:
|
||||
return ''
|
||||
return super().render(context)
|
||||
def should_render(self, context):
|
||||
return bool(context['custom_fields'])
|
||||
|
||||
|
||||
class ImageAttachmentsPanel(panels.ObjectsTablePanel):
|
||||
|
||||
@@ -89,9 +89,9 @@ class Panel:
|
||||
Parameters:
|
||||
context (dict): The template context
|
||||
"""
|
||||
if not self.should_render(context):
|
||||
return ''
|
||||
ctx = self.get_context(context)
|
||||
if not self.should_render(ctx):
|
||||
return ''
|
||||
return render_to_string(self.template_name, ctx, request=ctx.get('request'))
|
||||
|
||||
|
||||
@@ -427,4 +427,4 @@ class ContextTablePanel(ObjectPanel):
|
||||
}
|
||||
|
||||
def should_render(self, context):
|
||||
return self._resolve_table(context) is not None
|
||||
return context.get('table') is not None
|
||||
|
||||
Reference in New Issue
Block a user