mirror of
https://github.com/netbox-community/netbox.git
synced 2026-03-21 20:18:38 -06:00
Cleanup
This commit is contained in:
@@ -308,24 +308,6 @@ class VirtualChassisPanel(panels.ObjectAttributesPanel):
|
||||
description = attrs.TextAttr('description')
|
||||
|
||||
|
||||
class VirtualChassisDetailMembersPanel(panels.ObjectPanel):
|
||||
"""
|
||||
A panel which lists all members of a virtual chassis on the VirtualChassis detail view.
|
||||
"""
|
||||
template_name = 'dcim/panels/virtual_chassis_detail_members.html'
|
||||
title = _('Members')
|
||||
|
||||
def get_context(self, context):
|
||||
return {
|
||||
**super().get_context(context),
|
||||
'members': context.get('members'),
|
||||
}
|
||||
|
||||
def render(self, context):
|
||||
ctx = self.get_context(context)
|
||||
return render_to_string(self.template_name, ctx, request=ctx.get('request'))
|
||||
|
||||
|
||||
class PowerPanelPanel(panels.ObjectAttributesPanel):
|
||||
site = attrs.RelatedObjectAttr('site', linkify=True)
|
||||
location = attrs.NestedObjectAttr('location', linkify=True)
|
||||
@@ -382,10 +364,7 @@ class VirtualDeviceContextPanel(panels.ObjectAttributesPanel):
|
||||
class MACAddressPanel(panels.ObjectAttributesPanel):
|
||||
mac_address = attrs.TextAttr('mac_address', label=_('MAC address'), style='font-monospace', copy_button=True)
|
||||
description = attrs.TextAttr('description')
|
||||
assignment = attrs.TemplatedAttr(
|
||||
'assigned_object',
|
||||
template_name='dcim/macaddress/attrs/assignment.html',
|
||||
)
|
||||
assignment = attrs.RelatedObjectAttr('assigned_object', linkify=True, grouped_by='parent_object')
|
||||
is_primary = attrs.BooleanAttr('is_primary', label=_('Primary for interface'))
|
||||
|
||||
|
||||
@@ -423,9 +402,6 @@ class InventoryItemsPanel(panels.ObjectPanel):
|
||||
title = _('Inventory Items')
|
||||
|
||||
def render(self, context):
|
||||
obj = context['object']
|
||||
if not obj.inventory_items.exists():
|
||||
return ''
|
||||
ctx = self.get_context(context)
|
||||
return render_to_string(self.template_name, ctx, request=ctx.get('request'))
|
||||
|
||||
@@ -466,6 +442,7 @@ class VirtualChassisMembersPanel(panels.ObjectPanel):
|
||||
def get_context(self, context):
|
||||
return {
|
||||
**super().get_context(context),
|
||||
'virtual_chassis': context.get('virtual_chassis'),
|
||||
'vc_members': context.get('vc_members'),
|
||||
}
|
||||
|
||||
|
||||
+11
-5
@@ -1577,7 +1577,7 @@ class ModuleTypeProfileListView(generic.ObjectListView):
|
||||
|
||||
|
||||
@register_model_view(ModuleTypeProfile)
|
||||
class ModuleTypeProfileView(GetRelatedModelsMixin, generic.ObjectView):
|
||||
class ModuleTypeProfileView(generic.ObjectView):
|
||||
template_name = 'generic/object.html'
|
||||
queryset = ModuleTypeProfile.objects.all()
|
||||
layout = layout.SimpleLayout(
|
||||
@@ -2555,6 +2555,7 @@ class DeviceView(generic.ObjectView):
|
||||
vc_members = []
|
||||
|
||||
return {
|
||||
'virtual_chassis': instance.virtual_chassis,
|
||||
'vc_members': vc_members,
|
||||
'svg_extra': f'highlight=id:{instance.pk}',
|
||||
}
|
||||
@@ -3951,6 +3952,11 @@ class InventoryItemRoleView(GetRelatedModelsMixin, generic.ObjectView):
|
||||
],
|
||||
)
|
||||
|
||||
def get_extra_context(self, request, instance):
|
||||
return {
|
||||
'related_models': self.get_related_models(request, instance),
|
||||
}
|
||||
|
||||
|
||||
@register_model_view(InventoryItemRole, 'add', detail=False)
|
||||
@register_model_view(InventoryItemRole, 'edit')
|
||||
@@ -4273,16 +4279,16 @@ class VirtualChassisView(generic.ObjectView):
|
||||
CustomFieldsPanel(),
|
||||
],
|
||||
right_panels=[
|
||||
panels.VirtualChassisDetailMembersPanel(),
|
||||
panels.VirtualChassisMembersPanel(),
|
||||
CommentsPanel(),
|
||||
],
|
||||
)
|
||||
|
||||
def get_extra_context(self, request, instance):
|
||||
members = Device.objects.restrict(request.user).filter(virtual_chassis=instance)
|
||||
|
||||
vc_members = Device.objects.restrict(request.user).filter(virtual_chassis=instance).order_by('vc_position')
|
||||
return {
|
||||
'members': members,
|
||||
'virtual_chassis': instance,
|
||||
'vc_members': vc_members,
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
{% load helpers %}
|
||||
{% if value %}
|
||||
{{ value.parent_object|linkify }} /
|
||||
{{ value|linkify }}
|
||||
{% else %}
|
||||
{{ ''|placeholder }}
|
||||
{% endif %}
|
||||
@@ -20,7 +20,7 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Path Status" %}</th>
|
||||
<th scope="row">{% trans "Path status" %}</th>
|
||||
<td>
|
||||
{% if object.path.is_complete and object.path.is_active %}
|
||||
<span class="badge text-bg-success">{% trans "Reachable" %}</span>
|
||||
@@ -30,7 +30,7 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Path Endpoints" %}</th>
|
||||
<th scope="row">{% trans "Path endpoints" %}</th>
|
||||
<td>
|
||||
{% for endpoint in object.connected_endpoints %}
|
||||
{% if endpoint.parent_object %}
|
||||
@@ -57,7 +57,7 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Connection Status" %}</th>
|
||||
<th scope="row">{% trans "Connection status" %}</th>
|
||||
<td>
|
||||
{% if object.cable.status %}
|
||||
<span class="badge text-bg-success">{{ object.cable.get_status_display }}</span>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<td>{{ device|linkify }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Device Type" %}</th>
|
||||
<th scope="row">{% trans "Device type" %}</th>
|
||||
<td>{{ device.device_type }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -14,15 +14,15 @@
|
||||
<td>{{ module.module_type.manufacturer|linkify }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Module Type" %}</th>
|
||||
<th scope="row">{% trans "Module type" %}</th>
|
||||
<td>{{ module.module_type|linkify }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Serial Number" %}</th>
|
||||
<th scope="row">{% trans "Serial number" %}</th>
|
||||
<td class="font-monospace">{{ module.serial|placeholder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Asset Tag" %}</th>
|
||||
<th scope="row">{% trans "Asset tag" %}</th>
|
||||
<td class="font-monospace">{{ module.asset_tag|placeholder }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
{% extends "ui/panels/_base.html" %}
|
||||
{% load helpers i18n %}
|
||||
|
||||
{% block panel_content %}
|
||||
<table class="table table-hover object-list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{% trans "Device" %}</th>
|
||||
<th>{% trans "Position" %}</th>
|
||||
<th>{% trans "Master" %}</th>
|
||||
<th>{% trans "Priority" %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for vc_member in members %}
|
||||
<tr>
|
||||
<td>{{ vc_member|linkify }}</td>
|
||||
<td>{% badge vc_member.vc_position show_empty=True %}</td>
|
||||
<td>
|
||||
{% if object.master == vc_member %}
|
||||
{% checkmark True %}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ vc_member.vc_priority|placeholder }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% if perms.dcim.change_virtualchassis and object.master %}
|
||||
<div class="card-footer text-end">
|
||||
<a href="{% url 'dcim:virtualchassis_add_member' pk=object.pk %}?site={{ object.master.site.pk }}&rack={{ object.master.rack.pk }}&return_url={{ object.get_absolute_url }}" class="btn btn-sm btn-primary">
|
||||
<i class="mdi mdi-plus-thick" aria-hidden="true"></i> {% trans "Add Member" %}
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endblock panel_content %}
|
||||
@@ -17,7 +17,7 @@
|
||||
<td>{{ vc_member|linkify }}</td>
|
||||
<td>{% badge vc_member.vc_position show_empty=True %}</td>
|
||||
<td>
|
||||
{% if object.virtual_chassis.master == vc_member %}
|
||||
{% if virtual_chassis.master == vc_member %}
|
||||
{% checkmark True %}
|
||||
{% else %}
|
||||
{{ ''|placeholder }}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
{% extends 'generic/object.html' %}
|
||||
{% load helpers i18n %}
|
||||
|
||||
{% block breadcrumbs %}
|
||||
{{ block.super }}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
{% extends 'generic/object.html' %}
|
||||
{% load helpers i18n %}
|
||||
|
||||
{% block breadcrumbs %}
|
||||
{{ block.super }}
|
||||
|
||||
Reference in New Issue
Block a user