mirror of
https://github.com/netbox-community/netbox.git
synced 2026-04-04 16:37:15 +02:00
Replace candidate template panels with ObjectAttributesPanel subclasses
This commit is contained in:
@@ -267,6 +267,15 @@ class ModuleBayPanel(panels.ObjectAttributesPanel):
|
||||
description = attrs.TextAttr('description')
|
||||
|
||||
|
||||
class InstalledModulePanel(panels.ObjectAttributesPanel):
|
||||
title = _('Installed Module')
|
||||
module = attrs.RelatedObjectAttr('installed_module', linkify=True)
|
||||
manufacturer = attrs.RelatedObjectAttr('installed_module.module_type.manufacturer', linkify=True)
|
||||
module_type = attrs.RelatedObjectAttr('installed_module.module_type', linkify=True)
|
||||
serial = attrs.TextAttr('installed_module.serial', label=_('Serial number'), style='font-monospace')
|
||||
asset_tag = attrs.TextAttr('installed_module.asset_tag', style='font-monospace')
|
||||
|
||||
|
||||
class DeviceBayPanel(panels.ObjectAttributesPanel):
|
||||
device = attrs.RelatedObjectAttr('device', linkify=True)
|
||||
name = attrs.TextAttr('name')
|
||||
@@ -274,6 +283,12 @@ class DeviceBayPanel(panels.ObjectAttributesPanel):
|
||||
description = attrs.TextAttr('description')
|
||||
|
||||
|
||||
class InstalledDevicePanel(panels.ObjectAttributesPanel):
|
||||
title = _('Installed Device')
|
||||
device = attrs.RelatedObjectAttr('installed_device', linkify=True)
|
||||
device_type = attrs.RelatedObjectAttr('installed_device.device_type')
|
||||
|
||||
|
||||
class InventoryItemPanel(panels.ObjectAttributesPanel):
|
||||
device = attrs.RelatedObjectAttr('device', linkify=True)
|
||||
parent = attrs.RelatedObjectAttr('parent', linkify=True, label=_('Parent item'))
|
||||
|
||||
@@ -3739,10 +3739,7 @@ class ModuleBayView(generic.ObjectView):
|
||||
],
|
||||
right_panels=[
|
||||
CustomFieldsPanel(),
|
||||
TemplatePanel(
|
||||
title=_('Installed Module'),
|
||||
template_name='dcim/panels/installed_module.html',
|
||||
),
|
||||
panels.InstalledModulePanel(),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -3814,10 +3811,7 @@ class DeviceBayView(generic.ObjectView):
|
||||
TagsPanel(),
|
||||
],
|
||||
right_panels=[
|
||||
TemplatePanel(
|
||||
title=_('Installed Device'),
|
||||
template_name='dcim/panels/installed_device.html',
|
||||
),
|
||||
panels.InstalledDevicePanel(),
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
{% extends "ui/panels/_base.html" %}
|
||||
{% load helpers i18n %}
|
||||
|
||||
{% block panel_content %}
|
||||
{% if object.installed_device %}
|
||||
{% with device=object.installed_device %}
|
||||
<table class="table table-hover attr-table">
|
||||
<tr>
|
||||
<th scope="row">{% trans "Device" %}</th>
|
||||
<td>{{ device|linkify }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Device type" %}</th>
|
||||
<td>{{ device.device_type }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
{% endwith %}
|
||||
{% else %}
|
||||
<div class="card-body text-muted">{% trans "None" %}</div>
|
||||
{% endif %}
|
||||
{% endblock panel_content %}
|
||||
@@ -1,33 +0,0 @@
|
||||
{% extends "ui/panels/_base.html" %}
|
||||
{% load helpers i18n %}
|
||||
|
||||
{% block panel_content %}
|
||||
{% if object.installed_module %}
|
||||
{% with module=object.installed_module %}
|
||||
<table class="table table-hover attr-table">
|
||||
<tr>
|
||||
<th scope="row">{% trans "Module" %}</th>
|
||||
<td>{{ module|linkify }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Manufacturer" %}</th>
|
||||
<td>{{ module.module_type.manufacturer|linkify }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Module type" %}</th>
|
||||
<td>{{ module.module_type|linkify }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Serial number" %}</th>
|
||||
<td class="font-monospace">{{ module.serial|placeholder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Asset tag" %}</th>
|
||||
<td class="font-monospace">{{ module.asset_tag|placeholder }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
{% endwith %}
|
||||
{% else %}
|
||||
<div class="card-body text-muted">{% trans "None" %}</div>
|
||||
{% endif %}
|
||||
{% endblock panel_content %}
|
||||
@@ -1,34 +0,0 @@
|
||||
{% load helpers %}
|
||||
{% load i18n %}
|
||||
|
||||
<div class="card">
|
||||
<h2 class="card-header">{% trans "IKE Policy" %}</h2>
|
||||
<table class="table table-hover attr-table">
|
||||
<tr>
|
||||
<th scope="row">{% trans "Name" %}</th>
|
||||
<td>{{ object.ike_policy|linkify }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Description" %}</th>
|
||||
<td>{{ object.ike_policy.description|placeholder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Version" %}</th>
|
||||
<td>{{ object.ike_policy.get_version_display }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Mode" %}</th>
|
||||
<td>{{ object.ike_policy.get_mode_display }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Proposals" %}</th>
|
||||
<td>
|
||||
<ul class="list-unstyled mb-0">
|
||||
{% for proposal in object.ike_policy.proposals.all %}
|
||||
<li><a href="{{ proposal.get_absolute_url }}">{{ proposal }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
@@ -1,30 +0,0 @@
|
||||
{% load helpers %}
|
||||
{% load i18n %}
|
||||
|
||||
<div class="card">
|
||||
<h2 class="card-header">{% trans "IPSec Policy" %}</h2>
|
||||
<table class="table table-hover attr-table">
|
||||
<tr>
|
||||
<th scope="row">{% trans "Name" %}</th>
|
||||
<td>{{ object.ipsec_policy|linkify }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Description" %}</th>
|
||||
<td>{{ object.ipsec_policy.description|placeholder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Proposals" %}</th>
|
||||
<td>
|
||||
<ul class="list-unstyled mb-0">
|
||||
{% for proposal in object.ipsec_policy.proposals.all %}
|
||||
<li><a href="{{ proposal.get_absolute_url }}">{{ proposal }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "PFS Group" %}</th>
|
||||
<td>{{ object.ipsec_policy.get_pfs_group_display }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
@@ -71,6 +71,23 @@ class IPSecProfilePanel(panels.ObjectAttributesPanel):
|
||||
mode = attrs.ChoiceAttr('mode')
|
||||
|
||||
|
||||
class IPSecProfileIKEPolicyPanel(panels.ObjectAttributesPanel):
|
||||
title = _('IKE Policy')
|
||||
name = attrs.RelatedObjectAttr('ike_policy', linkify=True)
|
||||
description = attrs.TextAttr('ike_policy.description')
|
||||
version = attrs.ChoiceAttr('ike_policy.version', label=_('IKE version'))
|
||||
mode = attrs.ChoiceAttr('ike_policy.mode')
|
||||
proposals = attrs.RelatedObjectListAttr('ike_policy.proposals', linkify=True)
|
||||
|
||||
|
||||
class IPSecProfileIPSecPolicyPanel(panels.ObjectAttributesPanel):
|
||||
title = _('IPSec Policy')
|
||||
name = attrs.RelatedObjectAttr('ipsec_policy', linkify=True)
|
||||
description = attrs.TextAttr('ipsec_policy.description')
|
||||
proposals = attrs.RelatedObjectListAttr('ipsec_policy.proposals', linkify=True)
|
||||
pfs_group = attrs.ChoiceAttr('ipsec_policy.pfs_group', label=_('PFS group'))
|
||||
|
||||
|
||||
class L2VPNPanel(panels.ObjectAttributesPanel):
|
||||
name = attrs.TextAttr('name')
|
||||
identifier = attrs.TextAttr('identifier')
|
||||
|
||||
@@ -10,7 +10,6 @@ from netbox.ui.panels import (
|
||||
ObjectsTablePanel,
|
||||
PluginContentPanel,
|
||||
RelatedObjectsPanel,
|
||||
TemplatePanel,
|
||||
)
|
||||
from netbox.views import generic
|
||||
from utilities.query import count_related
|
||||
@@ -589,8 +588,8 @@ class IPSecProfileView(generic.ObjectView):
|
||||
CommentsPanel(),
|
||||
],
|
||||
right_panels=[
|
||||
TemplatePanel('vpn/panels/ipsecprofile_ike_policy.html'),
|
||||
TemplatePanel('vpn/panels/ipsecprofile_ipsec_policy.html'),
|
||||
panels.IPSecProfileIKEPolicyPanel(),
|
||||
panels.IPSecProfileIPSecPolicyPanel(),
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user