Add PluginContentPanel

This commit is contained in:
Jeremy Stretch
2025-10-31 14:50:21 -04:00
parent 77613b37b2
commit 4d5f8e9460
2 changed files with 24 additions and 2 deletions

View File

@@ -18,7 +18,9 @@ from ipam.models import ASN, IPAddress, Prefix, VLANGroup, VLAN
from ipam.tables import InterfaceVLANTable, VLANTranslationRuleTable
from netbox.object_actions import *
from netbox.ui import layout
from netbox.ui.panels import CommentsPanel, CustomFieldsPanel, ImageAttachmentsPanel, RelatedObjectsPanel, TagsPanel
from netbox.ui.panels import (
CommentsPanel, CustomFieldsPanel, ImageAttachmentsPanel, PluginContentPanel, RelatedObjectsPanel, TagsPanel,
)
from netbox.views import generic
from utilities.forms import ConfirmationForm
from utilities.paginator import EnhancedPaginator, get_paginate_count
@@ -473,12 +475,19 @@ class SiteView(GetRelatedModelsMixin, generic.ObjectView):
CustomFieldsPanel(),
TagsPanel(),
CommentsPanel(),
PluginContentPanel('left_page'),
),
layout.Column(
RelatedObjectsPanel(),
ImageAttachmentsPanel(),
PluginContentPanel('right_page'),
),
)
),
layout.Row(
layout.Column(
PluginContentPanel('full_width_page'),
),
),
)
def get_extra_context(self, request, instance):

View File

@@ -6,6 +6,7 @@ from django.utils.translation import gettext_lazy as _
from netbox.ui import attrs
from netbox.ui.attrs import Attr
from utilities.string import title
from utilities.templatetags.plugins import _get_registered_content
__all__ = (
'CommentsPanel',
@@ -15,6 +16,7 @@ __all__ = (
'ObjectPanel',
'RelatedObjectsPanel',
'Panel',
'PluginContentPanel',
'TagsPanel',
)
@@ -142,3 +144,14 @@ class ImageAttachmentsPanel(Panel):
'request': context.get('request'),
'object': context.get('object'),
})
class PluginContentPanel(Panel):
def __init__(self, method, **kwargs):
super().__init__(**kwargs)
self.method = method
def render(self, context):
obj = context.get('object')
return _get_registered_content(obj, self.method, context)