mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-07 16:18:16 -06:00
Fixes #1655: Removed explicit field references
Cleaned up all (notable) .name references, and removed them so __str__ can do the lifting. Did not remove the references where it was explicitly referenced to .name (eg. in details). Extended the Secret model to also include the name in __str__, since that was weirdly absent.
This commit is contained in:
parent
e26a0574ba
commit
bd276aae20
@ -286,8 +286,8 @@ class Secret(CreatedUpdatedModel):
|
||||
super(Secret, self).__init__(*args, **kwargs)
|
||||
|
||||
def __str__(self):
|
||||
if self.role and self.device:
|
||||
return '{} for {}'.format(self.role, self.device)
|
||||
if self.role and self.device and self.name:
|
||||
return '{} for {} ({})'.format(self.role, self.device, self.name)
|
||||
return 'Secret'
|
||||
|
||||
def get_absolute_url(self):
|
||||
|
@ -65,7 +65,7 @@
|
||||
<td>
|
||||
{% if circuit.tenant %}
|
||||
{% if circuit.tenant.group %}
|
||||
<a href="{{ circuit.tenant.group.get_absolute_url }}">{{ circuit.tenant.group.name }}</a>
|
||||
<a href="{{ circuit.tenant.group.get_absolute_url }}">{{ circuit.tenant.group }}</a>
|
||||
<i class="fa fa-angle-right"></i>
|
||||
{% endif %}
|
||||
<a href="{{ circuit.tenant.get_absolute_url }}">{{ circuit.tenant }}</a>
|
||||
|
@ -28,10 +28,10 @@
|
||||
<td>
|
||||
{% if device.rack %}
|
||||
{% if device.rack.group %}
|
||||
<a href="{{ device.rack.group.get_absolute_url }}">{{ device.rack.group.name }}</a>
|
||||
<a href="{{ device.rack.group.get_absolute_url }}">{{ device.rack.group }}</a>
|
||||
<i class="fa fa-angle-right"></i>
|
||||
{% endif %}
|
||||
<a href="{% url 'dcim:rack' pk=device.rack.pk %}">{{ device.rack.name }}</a>{% if device.rack.facility_id %} ({{ device.rack.facility_id }}){% endif %}
|
||||
<a href="{% url 'dcim:rack' pk=device.rack.pk %}">{{ device.rack }}</a>
|
||||
{% else %}
|
||||
<span class="text-muted">None</span>
|
||||
{% endif %}
|
||||
@ -42,7 +42,7 @@
|
||||
<td>
|
||||
{% if device.parent_bay %}
|
||||
{% with device.parent_bay.device as parent %}
|
||||
<a href="{{ parent.get_absolute_url }}">{{ parent }}</a> <i class="fa fa-angle-right"></i> {{ device.parent_bay.name }}
|
||||
<a href="{{ parent.get_absolute_url }}">{{ parent }}</a> <i class="fa fa-angle-right"></i> {{ device.parent_bay }}
|
||||
{% if parent.position %}
|
||||
(U{{ parent.position }} / {{ parent.get_face_display }})
|
||||
{% endif %}
|
||||
@ -61,7 +61,7 @@
|
||||
<td>
|
||||
{% if device.tenant %}
|
||||
{% if device.tenant.group %}
|
||||
<a href="{{ device.tenant.group.get_absolute_url }}">{{ device.tenant.group.name }}</a>
|
||||
<a href="{{ device.tenant.group.get_absolute_url }}">{{ device.tenant.group }}</a>
|
||||
<i class="fa fa-angle-right"></i>
|
||||
{% endif %}
|
||||
<a href="{{ device.tenant.get_absolute_url }}">{{ device.tenant }}</a>
|
||||
|
@ -26,7 +26,7 @@
|
||||
<div class="form-group">
|
||||
<label class="col-md-3 control-label required">Bay</label>
|
||||
<div class="col-md-9">
|
||||
<p class="form-control-static">{{ device_bay.name }}</p>
|
||||
<p class="form-control-static">{{ device_bay }}</p>
|
||||
</div>
|
||||
</div>
|
||||
{% render_form form %}
|
||||
|
@ -13,7 +13,7 @@
|
||||
<a href="{% url 'dcim:device' pk=csp.connected_console.device.pk %}">{{ csp.connected_console.device }}</a>
|
||||
</td>
|
||||
<td>
|
||||
{{ csp.connected_console.name }}
|
||||
{{ csp.connected_console }}
|
||||
</td>
|
||||
{% else %}
|
||||
<td colspan="2">
|
||||
|
@ -8,7 +8,7 @@
|
||||
{% endif %}
|
||||
{% if device.parent_bay %}
|
||||
<li><a href="{% url 'dcim:device' pk=device.parent_bay.device.pk %}">{{ device.parent_bay.device }}</a></li>
|
||||
<li>{{ device.parent_bay.name }}</li>
|
||||
<li>{{ device.parent_bay }}</li>
|
||||
{% endif %}
|
||||
<li>{{ device }}</li>
|
||||
</ol>
|
||||
|
@ -5,7 +5,7 @@
|
||||
</td>
|
||||
{% endif %}
|
||||
<td>
|
||||
<i class="fa fa-fw fa-{% if devicebay.installed_device %}dot-circle-o{% else %}circle-o{% endif %}"></i> {{ devicebay.name }}
|
||||
<i class="fa fa-fw fa-{% if devicebay.installed_device %}dot-circle-o{% else %}circle-o{% endif %}"></i> {{ devicebay }}
|
||||
</td>
|
||||
{% if devicebay.installed_device %}
|
||||
<td>
|
||||
|
@ -6,9 +6,9 @@
|
||||
{% endif %}
|
||||
<td>
|
||||
<i class="fa fa-fw fa-{% if iface.mgmt_only %}wrench{% elif iface.is_virtual %}square{% elif iface.is_wireless %}wifi{% else %}exchange{% endif %}"></i>
|
||||
<span title="{{ iface.get_form_factor_display }}">{{ iface.name }}</span>
|
||||
<span title="{{ iface.get_form_factor_display }}">{{ iface }}</span>
|
||||
{% if iface.lag %}
|
||||
<span class="label label-primary">{{ iface.lag.name }}</span>
|
||||
<span class="label label-primary">{{ iface.lag }}</span>
|
||||
{% endif %}
|
||||
{% if iface.description %}
|
||||
<i class="fa fa-fw fa-comment-o" title="{{ iface.description }}"></i>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<tr>
|
||||
<td style="padding-left: {{ indent|add:5 }}px">{{ item.name }}</td>
|
||||
<td style="padding-left: {{ indent|add:5 }}px">{{ item }}</td>
|
||||
<td>{% if not item.discovered %}<i class="fa fa-asterisk" title="Manually created"></i>{% endif %}</td>
|
||||
<td>{{ item.manufacturer|default:"" }}</td>
|
||||
<td>{{ item.part_id }}</td>
|
||||
|
@ -5,7 +5,7 @@
|
||||
</td>
|
||||
{% endif %}
|
||||
<td>
|
||||
<i class="fa fa-fw fa-bolt"></i> {{ po.name }}
|
||||
<i class="fa fa-fw fa-bolt"></i> {{ po }}
|
||||
</td>
|
||||
<td></td>
|
||||
{% if po.connected_port %}
|
||||
@ -13,7 +13,7 @@
|
||||
<a href="{% url 'dcim:device' pk=po.connected_port.device.pk %}">{{ po.connected_port.device }}</a>
|
||||
</td>
|
||||
<td>
|
||||
{{ po.connected_port.name }}
|
||||
{{ po.connected_port }}
|
||||
</td>
|
||||
{% else %}
|
||||
<td colspan="2">
|
||||
|
@ -1,13 +1,13 @@
|
||||
<tr class="powerport{% if pp.power_outlet and not pp.connection_status %} info{% endif %}">
|
||||
<td>
|
||||
<i class="fa fa-fw fa-bolt"></i> {{ pp.name }}
|
||||
<i class="fa fa-fw fa-bolt"></i> {{ pp }}
|
||||
</td>
|
||||
{% if pp.power_outlet %}
|
||||
<td>
|
||||
<a href="{% url 'dcim:device' pk=pp.power_outlet.device.pk %}">{{ pp.power_outlet.device }}</a>
|
||||
</td>
|
||||
<td>
|
||||
{{ pp.power_outlet.name }}
|
||||
{{ pp.power_outlet }}
|
||||
</td>
|
||||
{% else %}
|
||||
<td colspan="2">
|
||||
|
@ -27,13 +27,13 @@
|
||||
{% ifequal u.device.face face_id %}
|
||||
<a href="{% url 'dcim:device' pk=u.device.pk %}" data-toggle="popover" data-trigger="hover" data-container="body" data-html="true"
|
||||
data-content="{{ u.device.device_role }}<br />{{ u.device.device_type.full_name }} ({{ u.device.device_type.u_height }}U){% if u.device.asset_tag %}<br />{{ u.device.asset_tag }}{% endif %}">
|
||||
{{ u.device.name|default:u.device.device_role }}
|
||||
{{ u.device|default:u.device.device_role }}
|
||||
{% if u.device.devicebay_count %}
|
||||
({{ u.device.get_children.count }}/{{ u.device.devicebay_count }})
|
||||
{% endif %}
|
||||
</a>
|
||||
{% else %}
|
||||
<span>{{ u.device.name|default:u.device.device_role }}</span>
|
||||
<span>{{ u.device|default:u.device.device_role }}</span>
|
||||
{% endifequal %}
|
||||
</li>
|
||||
{% else %}
|
||||
|
@ -49,7 +49,7 @@
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
<h1>{% block title %}Rack {{ rack.name }}{% endblock %}</h1>
|
||||
<h1>{% block title %}Rack {{ rack }}{% endblock %}</h1>
|
||||
{% include 'inc/created_updated.html' with obj=rack %}
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
@ -72,7 +72,7 @@
|
||||
<td>Group</td>
|
||||
<td>
|
||||
{% if rack.group %}
|
||||
<a href="{% url 'dcim:rack_list' %}?site={{ rack.site.slug }}&group={{ rack.group.slug }}">{{ rack.group.name }}</a>
|
||||
<a href="{% url 'dcim:rack_list' %}?site={{ rack.site.slug }}&group={{ rack.group.slug }}">{{ rack.group }}</a>
|
||||
{% else %}
|
||||
<span class="text-muted">None</span>
|
||||
{% endif %}
|
||||
@ -93,7 +93,7 @@
|
||||
<td>
|
||||
{% if rack.tenant %}
|
||||
{% if rack.tenant.group %}
|
||||
<a href="{{ rack.tenant.group.get_absolute_url }}">{{ rack.tenant.group.name }}</a>
|
||||
<a href="{{ rack.tenant.group.get_absolute_url }}">{{ rack.tenant.group }}</a>
|
||||
<i class="fa fa-angle-right"></i>
|
||||
{% endif %}
|
||||
<a href="{{ rack.tenant.get_absolute_url }}">{{ rack.tenant }}</a>
|
||||
@ -173,7 +173,7 @@
|
||||
{% for device in nonracked_devices %}
|
||||
<tr{% if device.device_type.u_height %} class="warning"{% endif %}>
|
||||
<td>
|
||||
<a href="{% url 'dcim:device' pk=device.pk %}">{{ device.name }}</a>
|
||||
<a href="{% url 'dcim:device' pk=device.pk %}">{{ device }}</a>
|
||||
</td>
|
||||
<td>{{ device.device_role }}</td>
|
||||
<td>{{ device.device_type.full_name }}</td>
|
||||
|
@ -14,7 +14,7 @@
|
||||
{% for rack in page %}
|
||||
<div style="display: inline-block; width: 266px">
|
||||
<div class="rack_header">
|
||||
<strong><a href="{% url 'dcim:rack' pk=rack.pk %}">{{ rack.name|truncatechars:"25" }}</a></strong>
|
||||
<strong><a href="{% url 'dcim:rack' pk=rack.pk %}">{{ rack|truncatechars:"25" }}</a></strong>
|
||||
<p><small class="text-muted">{{ rack.facility_id|truncatechars:"30" }}</small></p>
|
||||
</div>
|
||||
{% if face_id %}
|
||||
@ -24,7 +24,7 @@
|
||||
{% endif %}
|
||||
<div class="clearfix"></div>
|
||||
<div class="rack_header">
|
||||
<strong><a href="{% url 'dcim:rack' pk=rack.pk %}">{{ rack.name|truncatechars:"25" }}</a></strong>
|
||||
<strong><a href="{% url 'dcim:rack' pk=rack.pk %}">{{ rack|truncatechars:"25" }}</a></strong>
|
||||
<p><small class="text-muted">{{ rack.facility_id|truncatechars:"30" }}</small></p>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -76,7 +76,7 @@
|
||||
<td>
|
||||
{% if site.tenant %}
|
||||
{% if site.tenant.group %}
|
||||
<a href="{{ site.tenant.group.get_absolute_url }}">{{ site.tenant.group.name }}</a>
|
||||
<a href="{{ site.tenant.group.get_absolute_url }}">{{ site.tenant.group }}</a>
|
||||
<i class="fa fa-angle-right"></i>
|
||||
{% endif %}
|
||||
<a href="{{ site.tenant.get_absolute_url }}">{{ site.tenant }}</a>
|
||||
@ -221,7 +221,7 @@
|
||||
<table class="table table-hover panel-body">
|
||||
{% for rg in rack_groups %}
|
||||
<tr>
|
||||
<td><i class="fa fa-fw fa-folder-o"></i> <a href="{{ rg.get_absolute_url }}">{{ rg.name }}</a></td>
|
||||
<td><i class="fa fa-fw fa-folder-o"></i> <a href="{{ rg.get_absolute_url }}">{{ rg }}</a></td>
|
||||
<td>{{ rg.rack_count }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
@ -1,5 +1,5 @@
|
||||
<tr>
|
||||
<td>{{ service.name }}</td>
|
||||
<td>{{ service }}</td>
|
||||
<td>
|
||||
{{ service.get_protocol_display }}/{{ service.port }}
|
||||
</td>
|
||||
|
@ -30,13 +30,13 @@
|
||||
<td>
|
||||
{% if prefix.tenant %}
|
||||
{% if prefix.tenant.group %}
|
||||
<a href="{{ prefix.tenant.group.get_absolute_url }}">{{ prefix.tenant.group.name }}</a>
|
||||
<a href="{{ prefix.tenant.group.get_absolute_url }}">{{ prefix.tenant.group }}</a>
|
||||
<i class="fa fa-angle-right"></i>
|
||||
{% endif %}
|
||||
<a href="{{ prefix.tenant.get_absolute_url }}">{{ prefix.tenant }}</a>
|
||||
{% elif prefix.vrf.tenant %}
|
||||
{% if prefix.vrf.tenant.group %}
|
||||
<a href="{{ prefix.vrf.tenant.group.get_absolute_url }}">{{ prefix.vrf.tenant.group.name }}</a>
|
||||
<a href="{{ prefix.vrf.tenant.group.get_absolute_url }}">{{ prefix.vrf.tenant.group }}</a>
|
||||
<i class="fa fa-angle-right"></i>
|
||||
{% endif %}
|
||||
<a href="{{ prefix.vrf.tenant.get_absolute_url }}">{{ prefix.vrf.tenant }}</a>
|
||||
@ -75,7 +75,7 @@
|
||||
<td>
|
||||
{% if prefix.vlan %}
|
||||
{% if prefix.vlan.group %}
|
||||
<a href="{{ prefix.vlan.group.get_absolute_url }}">{{ prefix.vlan.group.name }}</a>
|
||||
<a href="{{ prefix.vlan.group.get_absolute_url }}">{{ prefix.vlan.group }}</a>
|
||||
<i class="fa fa-angle-right"></i>
|
||||
{% endif %}
|
||||
<a href="{% url 'ipam:vlan' pk=prefix.vlan.pk %}">{{ prefix.vlan.display_name }}</a>
|
||||
|
@ -9,9 +9,9 @@
|
||||
<li><a href="{% url 'ipam:vlan_list' %}?site={{ vlan.site.slug }}">{{ vlan.site }}</a></li>
|
||||
{% endif %}
|
||||
{% if vlan.group %}
|
||||
<li><a href="{% url 'ipam:vlan_list' %}?group={{ vlan.group.slug }}">{{ vlan.group.name }}</a></li>
|
||||
<li><a href="{% url 'ipam:vlan_list' %}?group={{ vlan.group.slug }}">{{ vlan.group }}</a></li>
|
||||
{% endif %}
|
||||
<li>{{ vlan.name }} ({{ vlan.vid }})</li>
|
||||
<li>{{ vlan }}</li>
|
||||
</ol>
|
||||
</div>
|
||||
<div class="col-sm-4 col-md-3">
|
||||
@ -68,7 +68,7 @@
|
||||
<td>Group</td>
|
||||
<td>
|
||||
{% if vlan.group %}
|
||||
<a href="{{ vlan.group.get_absolute_url }}">{{ vlan.group.name }}</a>
|
||||
<a href="{{ vlan.group.get_absolute_url }}">{{ vlan.group }}</a>
|
||||
{% else %}
|
||||
<span class="text-muted">None</span>
|
||||
{% endif %}
|
||||
@ -87,7 +87,7 @@
|
||||
<td>
|
||||
{% if vlan.tenant %}
|
||||
{% if vlan.tenant.group %}
|
||||
<a href="{{ vlan.tenant.group.get_absolute_url }}">{{ vlan.tenant.group.name }}</a>
|
||||
<a href="{{ vlan.tenant.group.get_absolute_url }}">{{ vlan.tenant.group }}</a>
|
||||
<i class="fa fa-angle-right"></i>
|
||||
{% endif %}
|
||||
<a href="{{ vlan.tenant.get_absolute_url }}">{{ vlan.tenant }}</a>
|
||||
|
@ -1,7 +1,7 @@
|
||||
{% load secret_helpers %}
|
||||
<tr>
|
||||
<td><a href="{% url 'secrets:secret' pk=secret.pk %}">{{ secret.role }}</a></td>
|
||||
<td>{{ secret.name }}</td>
|
||||
<td>{{ secret }}</td>
|
||||
<td id="secret_{{ secret.pk }}">********</td>
|
||||
<td class="text-right">
|
||||
{% if secret|decryptable_by:request.user %}
|
||||
|
@ -5,7 +5,7 @@
|
||||
</td>
|
||||
{% endif %}
|
||||
<td>
|
||||
<i class="fa fa-fw fa-square"></i> <span>{{ iface.name }}</span>
|
||||
<i class="fa fa-fw fa-square"></i> <span>{{ iface }}</span>
|
||||
{% if iface.description %}
|
||||
<i class="fa fa-fw fa-comment-o" title="{{ iface.description }}"></i>
|
||||
{% endif %}
|
||||
|
@ -49,7 +49,7 @@
|
||||
<table class="table table-hover panel-body attr-table">
|
||||
<tr>
|
||||
<td>Name</td>
|
||||
<td>{{ vm.name }}</td>
|
||||
<td>{{ vm }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Status</td>
|
||||
@ -82,7 +82,7 @@
|
||||
<td>
|
||||
{% if vm.tenant %}
|
||||
{% if vm.tenant.group %}
|
||||
<a href="{{ vm.tenant.group.get_absolute_url }}">{{ vm.tenant.group.name }}</a>
|
||||
<a href="{{ vm.tenant.group.get_absolute_url }}">{{ vm.tenant.group }}</a>
|
||||
<i class="fa fa-angle-right"></i>
|
||||
{% endif %}
|
||||
<a href="{{ vm.tenant.get_absolute_url }}">{{ vm.tenant }}</a>
|
||||
|
Loading…
Reference in New Issue
Block a user