mirror of
https://github.com/netbox-community/netbox.git
synced 2025-12-14 20:39:35 -06:00
Define layouts for regions, site groups, locations
This commit is contained in:
parent
c392988212
commit
21bb734dcb
@ -20,8 +20,8 @@ from ipam.tables import InterfaceVLANTable, VLANTranslationRuleTable
|
|||||||
from netbox.object_actions import *
|
from netbox.object_actions import *
|
||||||
from netbox.ui import actions, layout
|
from netbox.ui import actions, layout
|
||||||
from netbox.ui.panels import (
|
from netbox.ui.panels import (
|
||||||
CommentsPanel, CustomFieldsPanel, ImageAttachmentsPanel, ObjectsTablePanel, PluginContentPanel,
|
CommentsPanel, CustomFieldsPanel, ImageAttachmentsPanel, NestedGroupObjectPanel, ObjectsTablePanel,
|
||||||
RelatedObjectsPanel, TagsPanel,
|
PluginContentPanel, RelatedObjectsPanel, TagsPanel,
|
||||||
)
|
)
|
||||||
from netbox.views import generic
|
from netbox.views import generic
|
||||||
from utilities.forms import ConfirmationForm
|
from utilities.forms import ConfirmationForm
|
||||||
@ -228,6 +228,34 @@ class RegionListView(generic.ObjectListView):
|
|||||||
@register_model_view(Region)
|
@register_model_view(Region)
|
||||||
class RegionView(GetRelatedModelsMixin, generic.ObjectView):
|
class RegionView(GetRelatedModelsMixin, generic.ObjectView):
|
||||||
queryset = Region.objects.all()
|
queryset = Region.objects.all()
|
||||||
|
layout = layout.Layout(
|
||||||
|
layout.Row(
|
||||||
|
layout.Column(
|
||||||
|
NestedGroupObjectPanel(),
|
||||||
|
TagsPanel(),
|
||||||
|
CustomFieldsPanel(),
|
||||||
|
CommentsPanel(),
|
||||||
|
PluginContentPanel('left_page'),
|
||||||
|
),
|
||||||
|
layout.Column(
|
||||||
|
RelatedObjectsPanel(),
|
||||||
|
PluginContentPanel('right_page'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
layout.Row(
|
||||||
|
layout.Column(
|
||||||
|
ObjectsTablePanel(
|
||||||
|
model='dcim.Region',
|
||||||
|
title=_('Child Regions'),
|
||||||
|
filters={'parent_id': lambda obj: obj.pk},
|
||||||
|
actions=[
|
||||||
|
actions.AddObject('dcim.Region', url_params={'parent': lambda obj: obj.pk}),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
PluginContentPanel('full_width_page'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
def get_extra_context(self, request, instance):
|
def get_extra_context(self, request, instance):
|
||||||
regions = instance.get_descendants(include_self=True)
|
regions = instance.get_descendants(include_self=True)
|
||||||
@ -339,6 +367,34 @@ class SiteGroupListView(generic.ObjectListView):
|
|||||||
@register_model_view(SiteGroup)
|
@register_model_view(SiteGroup)
|
||||||
class SiteGroupView(GetRelatedModelsMixin, generic.ObjectView):
|
class SiteGroupView(GetRelatedModelsMixin, generic.ObjectView):
|
||||||
queryset = SiteGroup.objects.all()
|
queryset = SiteGroup.objects.all()
|
||||||
|
layout = layout.Layout(
|
||||||
|
layout.Row(
|
||||||
|
layout.Column(
|
||||||
|
NestedGroupObjectPanel(),
|
||||||
|
TagsPanel(),
|
||||||
|
CustomFieldsPanel(),
|
||||||
|
CommentsPanel(),
|
||||||
|
PluginContentPanel('left_page'),
|
||||||
|
),
|
||||||
|
layout.Column(
|
||||||
|
RelatedObjectsPanel(),
|
||||||
|
PluginContentPanel('right_page'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
layout.Row(
|
||||||
|
layout.Column(
|
||||||
|
ObjectsTablePanel(
|
||||||
|
model='dcim.SiteGroup',
|
||||||
|
title=_('Child Groups'),
|
||||||
|
filters={'parent_id': lambda obj: obj.pk},
|
||||||
|
actions=[
|
||||||
|
actions.AddObject('dcim.Region', url_params={'parent': lambda obj: obj.pk}),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
PluginContentPanel('full_width_page'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
def get_extra_context(self, request, instance):
|
def get_extra_context(self, request, instance):
|
||||||
groups = instance.get_descendants(include_self=True)
|
groups = instance.get_descendants(include_self=True)
|
||||||
@ -608,6 +664,59 @@ class LocationListView(generic.ObjectListView):
|
|||||||
@register_model_view(Location)
|
@register_model_view(Location)
|
||||||
class LocationView(GetRelatedModelsMixin, generic.ObjectView):
|
class LocationView(GetRelatedModelsMixin, generic.ObjectView):
|
||||||
queryset = Location.objects.all()
|
queryset = Location.objects.all()
|
||||||
|
layout = layout.Layout(
|
||||||
|
layout.Row(
|
||||||
|
layout.Column(
|
||||||
|
panels.LocationPanel(),
|
||||||
|
TagsPanel(),
|
||||||
|
CustomFieldsPanel(),
|
||||||
|
CommentsPanel(),
|
||||||
|
PluginContentPanel('left_page'),
|
||||||
|
),
|
||||||
|
layout.Column(
|
||||||
|
RelatedObjectsPanel(),
|
||||||
|
ImageAttachmentsPanel(),
|
||||||
|
PluginContentPanel('right_page'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
layout.Row(
|
||||||
|
layout.Column(
|
||||||
|
ObjectsTablePanel(
|
||||||
|
model='dcim.Location',
|
||||||
|
title=_('Child Locations'),
|
||||||
|
filters={'parent_id': lambda obj: obj.pk},
|
||||||
|
actions=[
|
||||||
|
actions.AddObject(
|
||||||
|
'dcim.Location',
|
||||||
|
url_params={
|
||||||
|
'site': lambda obj: obj.site.pk if obj.site else None,
|
||||||
|
'parent': lambda obj: obj.pk,
|
||||||
|
}
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
ObjectsTablePanel(
|
||||||
|
model='dcim.Device',
|
||||||
|
title=_('Non-Racked Devices'),
|
||||||
|
filters={
|
||||||
|
'location_id': lambda obj: obj.pk,
|
||||||
|
'rack_id': settings.FILTERS_NULL_CHOICE_VALUE,
|
||||||
|
'parent_bay_id': settings.FILTERS_NULL_CHOICE_VALUE,
|
||||||
|
},
|
||||||
|
actions=[
|
||||||
|
actions.AddObject(
|
||||||
|
'dcim.Device',
|
||||||
|
url_params={
|
||||||
|
'site': lambda obj: obj.site.pk if obj.site else None,
|
||||||
|
'parent': lambda obj: obj.pk,
|
||||||
|
}
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
PluginContentPanel('full_width_page'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
def get_extra_context(self, request, instance):
|
def get_extra_context(self, request, instance):
|
||||||
locations = instance.get_descendants(include_self=True)
|
locations = instance.get_descendants(include_self=True)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user