mirror of
https://github.com/netbox-community/netbox.git
synced 2025-12-14 04:19:36 -06:00
Add region & site group panels
This commit is contained in:
parent
1acd567706
commit
83de784196
@ -17,6 +17,7 @@ from extras.views import ObjectConfigContextView, ObjectRenderConfigView
|
||||
from ipam.models import ASN, IPAddress, Prefix, VLANGroup, VLAN
|
||||
from ipam.tables import InterfaceVLANTable, VLANTranslationRuleTable
|
||||
from netbox.object_actions import *
|
||||
from netbox.ui.components import NestedGroupObjectPanel
|
||||
from netbox.views import generic
|
||||
from utilities.forms import ConfirmationForm
|
||||
from utilities.paginator import EnhancedPaginator, get_paginate_count
|
||||
@ -227,6 +228,7 @@ class RegionView(GetRelatedModelsMixin, generic.ObjectView):
|
||||
regions = instance.get_descendants(include_self=True)
|
||||
|
||||
return {
|
||||
'region_panel': NestedGroupObjectPanel(instance, _('Region')),
|
||||
'related_models': self.get_related_models(
|
||||
request,
|
||||
regions,
|
||||
@ -338,6 +340,7 @@ class SiteGroupView(GetRelatedModelsMixin, generic.ObjectView):
|
||||
groups = instance.get_descendants(include_self=True)
|
||||
|
||||
return {
|
||||
'sitegroup_panel': NestedGroupObjectPanel(instance, _('Site Group')),
|
||||
'related_models': self.get_related_models(
|
||||
request,
|
||||
groups,
|
||||
|
||||
@ -2,7 +2,9 @@ from abc import ABC, ABCMeta, abstractmethod
|
||||
from functools import cached_property
|
||||
|
||||
from django.template.loader import render_to_string
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from netbox.ui import attrs
|
||||
from netbox.ui.attrs import Attr
|
||||
from utilities.string import title
|
||||
|
||||
@ -52,3 +54,9 @@ class ObjectPanel(Component, metaclass=ObjectDetailsPanelMeta):
|
||||
|
||||
def __str__(self):
|
||||
return self.render()
|
||||
|
||||
|
||||
class NestedGroupObjectPanel(ObjectPanel):
|
||||
name = attrs.TextAttr('name', label=_('Name'))
|
||||
description = attrs.TextAttr('description', label=_('Description'))
|
||||
parent = attrs.NestedObjectAttr('parent', label=_('Parent'), linkify=True)
|
||||
|
||||
@ -22,23 +22,7 @@
|
||||
{% block content %}
|
||||
<div class="row mb-3">
|
||||
<div class="col col-12 col-md-6">
|
||||
<div class="card">
|
||||
<h2 class="card-header">{% trans "Region" %}</h2>
|
||||
<table class="table table-hover attr-table">
|
||||
<tr>
|
||||
<th scope="row">{% trans "Name" %}</th>
|
||||
<td>{{ object.name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Description" %}</th>
|
||||
<td>{{ object.description|placeholder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Parent" %}</th>
|
||||
<td>{{ object.parent|linkify|placeholder }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
{{ region_panel }}
|
||||
{% include 'inc/panels/tags.html' %}
|
||||
{% include 'inc/panels/custom_fields.html' %}
|
||||
{% include 'inc/panels/comments.html' %}
|
||||
|
||||
@ -22,23 +22,7 @@
|
||||
{% block content %}
|
||||
<div class="row mb-3">
|
||||
<div class="col col-12 col-md-6">
|
||||
<div class="card">
|
||||
<h2 class="card-header">{% trans "Site Group" %}</h2>
|
||||
<table class="table table-hover attr-table">
|
||||
<tr>
|
||||
<th scope="row">{% trans "Name" %}</th>
|
||||
<td>{{ object.name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Description" %}</th>
|
||||
<td>{{ object.description|placeholder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Parent" %}</th>
|
||||
<td>{{ object.parent|linkify|placeholder }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
{{ sitegroup_panel }}
|
||||
{% include 'inc/panels/tags.html' %}
|
||||
{% include 'inc/panels/custom_fields.html' %}
|
||||
{% include 'inc/panels/comments.html' %}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user