Skip to content

Commit 4d5f8e9

Browse files
committed
Add PluginContentPanel
1 parent 77613b3 commit 4d5f8e9

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

netbox/dcim/views.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
from ipam.tables import InterfaceVLANTable, VLANTranslationRuleTable
1919
from netbox.object_actions import *
2020
from netbox.ui import layout
21-
from netbox.ui.panels import CommentsPanel, CustomFieldsPanel, ImageAttachmentsPanel, RelatedObjectsPanel, TagsPanel
21+
from netbox.ui.panels import (
22+
CommentsPanel, CustomFieldsPanel, ImageAttachmentsPanel, PluginContentPanel, RelatedObjectsPanel, TagsPanel,
23+
)
2224
from netbox.views import generic
2325
from utilities.forms import ConfirmationForm
2426
from utilities.paginator import EnhancedPaginator, get_paginate_count
@@ -473,12 +475,19 @@ class SiteView(GetRelatedModelsMixin, generic.ObjectView):
473475
CustomFieldsPanel(),
474476
TagsPanel(),
475477
CommentsPanel(),
478+
PluginContentPanel('left_page'),
476479
),
477480
layout.Column(
478481
RelatedObjectsPanel(),
479482
ImageAttachmentsPanel(),
483+
PluginContentPanel('right_page'),
480484
),
481-
)
485+
),
486+
layout.Row(
487+
layout.Column(
488+
PluginContentPanel('full_width_page'),
489+
),
490+
),
482491
)
483492

484493
def get_extra_context(self, request, instance):

netbox/netbox/ui/panels.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from netbox.ui import attrs
77
from netbox.ui.attrs import Attr
88
from utilities.string import title
9+
from utilities.templatetags.plugins import _get_registered_content
910

1011
__all__ = (
1112
'CommentsPanel',
@@ -15,6 +16,7 @@
1516
'ObjectPanel',
1617
'RelatedObjectsPanel',
1718
'Panel',
19+
'PluginContentPanel',
1820
'TagsPanel',
1921
)
2022

@@ -142,3 +144,14 @@ def render(self, context):
142144
'request': context.get('request'),
143145
'object': context.get('object'),
144146
})
147+
148+
149+
class PluginContentPanel(Panel):
150+
151+
def __init__(self, method, **kwargs):
152+
super().__init__(**kwargs)
153+
self.method = method
154+
155+
def render(self, context):
156+
obj = context.get('object')
157+
return _get_registered_content(obj, self.method, context)

0 commit comments

Comments
 (0)