mirror of
https://github.com/netbox-community/netbox.git
synced 2026-01-09 13:22:18 -06:00
Add PluginContentPanel
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user