From 976b76dcb245aa1d20ad5b081d4867a6502459e0 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Wed, 31 Dec 2025 15:35:24 -0500 Subject: [PATCH] Define UI layout for Platform view --- netbox/dcim/ui/panels.py | 5 +++ netbox/dcim/views.py | 21 +++++++++++ netbox/templates/dcim/platform.html | 58 ----------------------------- 3 files changed, 26 insertions(+), 58 deletions(-) diff --git a/netbox/dcim/ui/panels.py b/netbox/dcim/ui/panels.py index c6122de2e..a25ad11ce 100644 --- a/netbox/dcim/ui/panels.py +++ b/netbox/dcim/ui/panels.py @@ -166,6 +166,11 @@ class ModuleTypePanel(panels.ObjectAttributesPanel): weight = attrs.NumericAttr('weight', unit_accessor='get_weight_unit_display') +class PlatformPanel(panels.NestedGroupObjectPanel): + manufacturer = attrs.RelatedObjectAttr('manufacturer', linkify=True) + config_template = attrs.RelatedObjectAttr('config_template', linkify=True) + + class VirtualChassisMembersPanel(panels.ObjectPanel): """ A panel which lists all members of a virtual chassis. diff --git a/netbox/dcim/views.py b/netbox/dcim/views.py index 4a320a275..a948f098e 100644 --- a/netbox/dcim/views.py +++ b/netbox/dcim/views.py @@ -2410,6 +2410,27 @@ class PlatformListView(generic.ObjectListView): @register_model_view(Platform) class PlatformView(GetRelatedModelsMixin, generic.ObjectView): queryset = Platform.objects.all() + layout = layout.SimpleLayout( + left_panels=[ + panels.PlatformPanel(), + TagsPanel(), + ], + right_panels=[ + RelatedObjectsPanel(), + CustomFieldsPanel(), + CommentsPanel(), + ], + bottom_panels=[ + ObjectsTablePanel( + model='dcim.Platform', + title=_('Child Platforms'), + filters={'parent_id': lambda ctx: ctx['object'].pk}, + actions=[ + actions.AddObject('dcim.Platform', url_params={'parent': lambda ctx: ctx['object'].pk}), + ], + ), + ] + ) def get_extra_context(self, request, instance): return { diff --git a/netbox/templates/dcim/platform.html b/netbox/templates/dcim/platform.html index 4becc042b..26179d4a2 100644 --- a/netbox/templates/dcim/platform.html +++ b/netbox/templates/dcim/platform.html @@ -18,61 +18,3 @@ {% endif %} {% endblock extra_controls %} - -{% block content %} -
-
-
-

{% trans "Platform" %}

- - - - - - - - - - - - - - - - - - - - - -
{% trans "Name" %}{{ object.name }}
{% trans "Description" %}{{ object.description|placeholder }}
{% trans "Parent" %}{{ object.parent|linkify|placeholder }}
{% trans "Manufacturer" %}{{ object.manufacturer|linkify|placeholder }}
{% trans "Config Template" %}{{ object.config_template|linkify|placeholder }}
-
- {% include 'inc/panels/tags.html' %} - {% plugin_left_page object %} -
-
- {% include 'inc/panels/related_objects.html' %} - {% include 'inc/panels/custom_fields.html' %} - {% include 'inc/panels/comments.html' %} - {% plugin_right_page object %} -
-
-
-
-
-

- {% trans "Child Platforms" %} - {% if perms.dcim.add_platform %} - - {% endif %} -

- {% htmx_table 'dcim:platform_list' parent_id=object.pk %} -
- {% plugin_full_width_page object %} -
-
-{% endblock %}