Coverage for dcim/tables/template_code.py: 100%
28 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-10 18:35 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-10 18:35 +0000
1LINKTERMINATION = """
2{% for termination in value %}
3 {% if termination.parent_object %}
4 <a href="{{ termination.parent_object.get_absolute_url }}">{{ termination.parent_object }}</a>
5 <i class="mdi mdi-chevron-right"></i>
6 {% endif %}
7 <a href="{{ termination.get_absolute_url }}">{{ termination }}</a>{% if not forloop.last %}<br />{% endif %}
8{% empty %}
9 {{ ''|placeholder }}
10{% endfor %}
11"""
13INTERFACE_LINKTERMINATION = """
14{% load i18n %}
15{% if record.is_virtual and record.virtual_circuit_termination %}
16 {% for termination in record.connected_endpoints %}
17 <a href="{{ termination.interface.parent_object.get_absolute_url }}">{{ termination.interface.parent_object }}</a>
18 <i class="mdi mdi-chevron-right"></i>
19 <a href="{{ termination.interface.get_absolute_url }}">{{ termination.interface }}</a>
20 {% trans "via" %}
21 <a href="{{ termination.parent_object.get_absolute_url }}">{{ termination.parent_object }}</a>
22 {% if not forloop.last %}<br />{% endif %}
23 {% endfor %}
24{% else %}""" + LINKTERMINATION + """{% endif %}
25"""
27INTERFACE_LAG_MEMBERS_LINKTERMINATION = """
28{% for termination in value %}
29 {% if termination.parent_object %}
30 <a href="{{ termination.parent_object.get_absolute_url }}">{{ termination.parent_object }}</a>
31 <i class="mdi mdi-chevron-right"></i>
32 {% endif %}
33 <a href="{{ termination.get_absolute_url }}">{{ termination }}</a>
34 {% if termination.lag %}
35 <i class="mdi mdi-chevron-right"></i>
36 <a href="{{ termination.lag.get_absolute_url }}">{{ termination.lag }}</a>
37 <span class="text-muted">(LAG)</span>
38 {% endif %}
39 {% if not forloop.last %}<br />{% endif %}
40{% empty %}
41 {{ ''|placeholder }}
42{% endfor %}
43"""
45CABLE_LENGTH = """
46{% load helpers %}
47{% if record.length %}{{ record.length|floatformat:"-2" }} {{ record.length_unit }}{% endif %}
48"""
50WEIGHT = """
51{% load helpers %}
52{% display_weight record.weight record.weight_unit record.abs_weight %}
53"""
55DIAMETER = """
56{% load helpers %}
57{% display_diameter record.diameter record.diameter_unit record.abs_diameter %}
58"""
60MAX_FLOW = """
61{% load helpers %}
62{% display_flow_rate record.max_flow record.max_flow_unit record.abs_max_flow %}
63"""
65DEVICE_LINK = """
66{{ record.label|default:'<span class="badge text-bg-info">Unnamed device</span>' }}
67"""
69DEVICEBAY_STATUS = """
70{% if record.installed_device_id %}
71 <span class="badge text-bg-{{ record.installed_device.get_status_color }}">
72 {{ record.installed_device.get_status_display }}
73 </span>
74{% else %}
75 <span class="badge text-bg-secondary">Vacant</span>
76{% endif %}
77"""
79INTERFACE_IPADDRESSES = """
80 {% if value.count > 3 %}
81 <a href="{% url 'ipam:ipaddress_list' %}?{{ record|meta:"model_name" }}_id={{ record.pk }}">{{ value.count }}</a>
82 {% else %}
83 {% for ip in value.all %}
84 {% if ip.status != 'active' %}
85 <a href="{{ ip.get_absolute_url }}" class="badge text-bg-{{ ip.get_status_color }}" data-bs-toggle="tooltip" data-bs-placement="left" title="{{ ip.get_status_display }}">{{ ip }}</a>
86 {% else %}
87 <a href="{{ ip.get_absolute_url }}">{{ ip }}</a>
88 {% endif %}
89 {% endfor %}
90 {% endif %}
91"""
93INTERFACE_FHRPGROUPS = """
94 {% for assignment in value.all %}
95 <a href="{{ assignment.group.get_absolute_url }}">{{ assignment.group }}</a>
96 {% endfor %}
97"""
99INTERFACE_TAGGED_VLANS = """
100{% load i18n %}
101{% if record.mode == 'access' %}
102{% elif record.mode == 'tagged-all' %}
103 {% trans "All" %}
104{% else %}
105 {% if value.count > 3 %}
106 <a href="{% url 'ipam:vlan_list' %}?{{ record|meta:"model_name" }}_id={{ record.pk }}">{{ value.count }} VLANs</a>
107 {% else %}
108 {% for vlan in value.all %}
109 <a href="{{ vlan.get_absolute_url }}">{{ vlan }}</a><br />
110 {% endfor %}
111 {% endif %}
112{% endif %}
113"""
115INTERFACE_WIRELESS_LANS = """
116{% for wlan in value.all %}
117 <a href="{{ wlan.get_absolute_url }}">{{ wlan }}</a><br />
118{% endfor %}
119"""
121POWERFEED_CABLE = """
122<a href="{{ value.get_absolute_url }}">{{ value }}</a>
123<a href="{% url 'dcim:powerfeed_trace' pk=record.pk %}" class="btn btn-primary btn-sm" title="Trace">
124 <i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i>
125</a>
126"""
128POWERFEED_CABLETERMINATION = """
129<a href="{{ value.parent_object.get_absolute_url }}">{{ value.parent_object }}</a>
130<i class="mdi mdi-chevron-right"></i>
131<a href="{{ value.get_absolute_url }}">{{ value }}</a>
132"""
134LOCATION_BUTTONS = """
135<a href="{% url 'dcim:rack_elevation_list' %}?site={{ record.site.slug }}&location_id={{ record.pk }}" class="btn btn-sm btn-primary" title="View elevations">
136 <i class="mdi mdi-server"></i>
137</a>
138"""
140OUTER_UNIT = """
141{% load helpers %}
142{% if value %}{{ value }} {{ record.outer_unit }}{% endif %}
143"""
145#
146# Device component templatebuttons
147#
149MODULAR_COMPONENT_TEMPLATE_BUTTONS = """
150{% load helpers %}
151{% if perms.dcim.add_inventoryitemtemplate and record.device_type_id %}
152<a href="{% url 'dcim:inventoryitemtemplate_add' %}?device_type={{ record.device_type_id }}&component_type={{ record|content_type_id }}&component_id={{ record.pk }}&return_url={{ request.path }}" title="Add inventory item" class="btn btn-primary btn-sm">
153 <i class="mdi mdi-plus-thick" aria-hidden="true"></i>
154</a>
155{% endif %}
156"""
158#
159# Device component buttons
160#
162CONSOLEPORT_BUTTONS = """
163{% if perms.dcim.add_inventoryitem %}
164 <a href="{% url 'dcim:inventoryitem_add' %}?device={{ record.device_id }}&component_type={{ record|content_type_id }}&component_id={{ record.pk }}&return_url={% url 'dcim:device_consoleports' pk=object.pk %}" class="btn btn-sm btn-success" title="Add inventory item">
165 <i class="mdi mdi-plus-thick" aria-hidden="true"></i>
166 </a>
167{% endif %}
168{% if record.cable %}
169 <a href="{% url 'dcim:consoleport_trace' pk=record.pk %}" class="btn btn-primary btn-sm" title="Trace"><i class="mdi mdi-transit-connection-variant"></i></a>
170 {% include 'dcim/inc/cable_toggle_buttons.html' with cable=record.cable %}
171 {% if perms.dcim.change_cable or perms.dcim.delete_cable %}
172 <span class="dropdown">
173 <button type="button" class="btn btn-warning btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
174 <span class="mdi mdi-ethernet-cable" aria-hidden="true"></span>
175 </button>
176 <ul class="dropdown-menu dropdown-menu-end">
177 {% if perms.dcim.change_cable %}
178 <li><a class="dropdown-item" href="{% url 'dcim:cable_edit' pk=record.cable.pk %}?return_url={% url 'dcim:device_consoleports' pk=object.pk %}">
179 <i class="mdi mdi-pencil-outline"></i>
180 Edit cable
181 </a>
182 </li>
183 {% endif %}
184 {% if perms.dcim.delete_cable %}
185 <li><a class="dropdown-item" href="{% url 'dcim:cable_delete' pk=record.cable.pk %}?return_url={% url 'dcim:device_consoleports' pk=object.pk %}">
186 <i class="mdi mdi-trash-can-outline"></i>
187 Delete cable
188 </a>
189 </li>
190 {% endif %}
191 </ul>
192 </span>
193 {% endif %}
194{% elif perms.dcim.add_cable %}
195 <a href="#" class="btn btn-outline-secondary btn-sm disabled"><i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i></a>
196 <a href="#" class="btn btn-outline-secondary btn-sm disabled"><i class="mdi mdi-lan-connect" aria-hidden="true"></i></a>
197 <span class="dropdown">
198 <button type="button" class="btn btn-success btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
199 <span class="mdi mdi-ethernet-cable" aria-hidden="true"></span>
200 </button>
201 <ul class="dropdown-menu dropdown-menu-end">
202 <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.consoleport&a_terminations={{ record.pk }}&b_terminations_type=dcim.consoleserverport&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_consoleports' pk=object.pk %}">Console Server Port</a></li>
203 <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.consoleport&a_terminations={{ record.pk }}&b_terminations_type=dcim.frontport&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_consoleports' pk=object.pk %}">Front Port</a></li>
204 <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.consoleport&a_terminations={{ record.pk }}&b_terminations_type=dcim.rearport&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_consoleports' pk=object.pk %}">Rear Port</a></li>
205 </ul>
206 </span>
207{% else %}
208 <a href="#" class="btn btn-outline-secondary btn-sm disabled"><i class="mdi mdi-ethernet-cable" aria-hidden="true"></i></a>
209{% endif %}
210"""
212CONSOLESERVERPORT_BUTTONS = """
213{% if perms.dcim.add_inventoryitem %}
214 <a href="{% url 'dcim:inventoryitem_add' %}?device={{ record.device_id }}&component_type={{ record|content_type_id }}&component_id={{ record.pk }}&return_url={% url 'dcim:device_consoleserverports' pk=object.pk %}" class="btn btn-sm btn-success" title="Add inventory item">
215 <i class="mdi mdi-plus-thick" aria-hidden="true"></i>
216 </a>
217{% endif %}
218{% if record.cable %}
219 <a href="{% url 'dcim:consoleserverport_trace' pk=record.pk %}" class="btn btn-primary btn-sm" title="Trace"><i class="mdi mdi-transit-connection-variant"></i></a>
220 {% include 'dcim/inc/cable_toggle_buttons.html' with cable=record.cable %}
221 {% if perms.dcim.change_cable or perms.dcim.delete_cable %}
222 <span class="dropdown">
223 <button type="button" class="btn btn-warning btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
224 <span class="mdi mdi-ethernet-cable" aria-hidden="true"></span>
225 </button>
226 <ul class="dropdown-menu dropdown-menu-end">
227 {% if perms.dcim.change_cable %}
228 <li><a class="dropdown-item" href="{% url 'dcim:cable_edit' pk=record.cable.pk %}?return_url={% url 'dcim:device_consoleserverports' pk=object.pk %}">
229 <i class="mdi mdi-pencil-outline"></i>
230 Edit cable
231 </a>
232 </li>
233 {% endif %}
234 {% if perms.dcim.delete_cable %}
235 <li><a class="dropdown-item" href="{% url 'dcim:cable_delete' pk=record.cable.pk %}?return_url={% url 'dcim:device_consoleserverports' pk=object.pk %}">
236 <i class="mdi mdi-trash-can-outline"></i>
237 Delete cable
238 </a>
239 </li>
240 {% endif %}
241 </ul>
242 </span>
243 {% endif %}
244{% elif perms.dcim.add_cable %}
245 <a href="#" class="btn btn-outline-secondary btn-sm disabled"><i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i></a>
246 <a href="#" class="btn btn-outline-secondary btn-sm disabled"><i class="mdi mdi-lan-connect" aria-hidden="true"></i></a>
247 <span class="dropdown">
248 <button type="button" class="btn btn-success btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
249 <span class="mdi mdi-ethernet-cable" aria-hidden="true"></span>
250 </button>
251 <ul class="dropdown-menu dropdown-menu-end">
252 <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.consoleserverport&a_terminations={{ record.pk }}&b_terminations_type=dcim.consoleport&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_consoleserverports' pk=object.pk %}">Console Port</a></li>
253 <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.consoleserverport&a_terminations={{ record.pk }}&b_terminations_type=dcim.frontport&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_consoleserverports' pk=object.pk %}">Front Port</a></li>
254 <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.consoleserverport&a_terminations={{ record.pk }}&b_terminations_type=dcim.rearport&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_consoleserverports' pk=object.pk %}">Rear Port</a></li>
255 </ul>
256 </span>
257{% else %}
258 <a href="#" class="btn btn-outline-secondary btn-sm disabled"><i class="mdi mdi-ethernet-cable" aria-hidden="true"></i></a>
259{% endif %}
260"""
262POWERPORT_BUTTONS = """
263{% if perms.dcim.add_inventoryitem %}
264 <a href="{% url 'dcim:inventoryitem_add' %}?device={{ record.device_id }}&component_type={{ record|content_type_id }}&component_id={{ record.pk }}&return_url={% url 'dcim:device_powerports' pk=object.pk %}" class="btn btn-sm btn-primary" title="Add inventory item">
265 <i class="mdi mdi-plus-thick" aria-hidden="true"></i>
266 </a>
267{% endif %}
268{% if record.cable %}
269 <a href="{% url 'dcim:powerport_trace' pk=record.pk %}" class="btn btn-primary btn-sm" title="Trace"><i class="mdi mdi-transit-connection-variant"></i></a>
270 {% include 'dcim/inc/cable_toggle_buttons.html' with cable=record.cable %}
271 {% if perms.dcim.change_cable or perms.dcim.delete_cable %}
272 <span class="dropdown">
273 <button type="button" class="btn btn-warning btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
274 <span class="mdi mdi-ethernet-cable" aria-hidden="true"></span>
275 </button>
276 <ul class="dropdown-menu dropdown-menu-end">
277 {% if perms.dcim.change_cable %}
278 <li><a class="dropdown-item" href="{% url 'dcim:cable_edit' pk=record.cable.pk %}?return_url={% url 'dcim:device_powerports' pk=object.pk %}">
279 <i class="mdi mdi-pencil-outline"></i>
280 Edit cable
281 </a>
282 </li>
283 {% endif %}
284 {% if perms.dcim.delete_cable %}
285 <li><a class="dropdown-item" href="{% url 'dcim:cable_delete' pk=record.cable.pk %}?return_url={% url 'dcim:device_powerports' pk=object.pk %}">
286 <i class="mdi mdi-trash-can-outline"></i>
287 Delete cable
288 </a>
289 </li>
290 {% endif %}
291 </ul>
292 </span>
293 {% endif %}
294{% elif perms.dcim.add_cable %}
295 <a href="#" class="btn btn-outline-secondary btn-sm disabled"><i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i></a>
296 <a href="#" class="btn btn-outline-secondary btn-sm disabled"><i class="mdi mdi-lan-connect" aria-hidden="true"></i></a>
297 <span class="dropdown">
298 <button type="button" class="btn btn-success btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
299 <span class="mdi mdi-ethernet-cable" aria-hidden="true"></span>
300 </button>
301 <ul class="dropdown-menu dropdown-menu-end">
302 <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.powerport&a_terminations={{ record.pk }}&b_terminations_type=dcim.poweroutlet&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_powerports' pk=object.pk %}">Power Outlet</a></li>
303 <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.powerport&a_terminations={{ record.pk }}&b_terminations_type=dcim.powerfeed&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_powerports' pk=object.pk %}">Power Feed</a></li>
304 </ul>
305 </span>
306{% else %}
307 <a href="#" class="btn btn-outline-secondary btn-sm disabled"><i class="mdi mdi-ethernet-cable" aria-hidden="true"></i></a>
308{% endif %}
309"""
311POWEROUTLET_BUTTONS = """
312{% if perms.dcim.add_inventoryitem %}
313 <a href="{% url 'dcim:inventoryitem_add' %}?device={{ record.device_id }}&component_type={{ record|content_type_id }}&component_id={{ record.pk }}&return_url={% url 'dcim:device_poweroutlets' pk=object.pk %}" class="btn btn-sm btn-primary" title="Add inventory item">
314 <i class="mdi mdi-plus-thick" aria-hidden="true"></i>
315 </a>
316{% endif %}
317{% if record.cable %}
318 <a href="{% url 'dcim:poweroutlet_trace' pk=record.pk %}" class="btn btn-primary btn-sm" title="Trace"><i class="mdi mdi-transit-connection-variant"></i></a>
319 {% include 'dcim/inc/cable_toggle_buttons.html' with cable=record.cable %}
320 {% if perms.dcim.change_cable or perms.dcim.delete_cable %}
321 <span class="dropdown">
322 <button type="button" class="btn btn-warning btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
323 <span class="mdi mdi-ethernet-cable" aria-hidden="true"></span>
324 </button>
325 <ul class="dropdown-menu dropdown-menu-end">
326 {% if perms.dcim.change_cable %}
327 <li><a class="dropdown-item" href="{% url 'dcim:cable_edit' pk=record.cable.pk %}?return_url={% url 'dcim:device_poweroutlets' pk=object.pk %}">
328 <i class="mdi mdi-pencil-outline"></i>
329 Edit cable
330 </a>
331 </li>
332 {% endif %}
333 {% if perms.dcim.delete_cable %}
334 <li><a class="dropdown-item" href="{% url 'dcim:cable_delete' pk=record.cable.pk %}?return_url={% url 'dcim:device_poweroutlets' pk=object.pk %}">
335 <i class="mdi mdi-trash-can-outline"></i>
336 Delete cable
337 </a>
338 </li>
339 {% endif %}
340 </ul>
341 </span>
342 {% endif %}
343{% elif perms.dcim.add_cable %}
344 <a href="#" class="btn btn-outline-secondary btn-sm disabled"><i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i></a>
345 <a href="#" class="btn btn-outline-secondary btn-sm disabled"><i class="mdi mdi-lan-connect" aria-hidden="true"></i></a>
346 {% if not record.mark_connected %}
347 <a href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.poweroutlet&a_terminations={{ record.pk }}&b_terminations_type=dcim.powerport&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_poweroutlets' pk=object.pk %}" title="Connect" class="btn btn-success btn-sm">
348 <i class="mdi mdi-ethernet-cable" aria-hidden="true"></i>
349 </a>
350 {% else %}
351 <a href="#" class="btn btn-outline-secondary btn-sm disabled"><i class="mdi mdi-ethernet-cable" aria-hidden="true"></i></a>
352 {% endif %}
353{% endif %}
354"""
356INTERFACE_BUTTONS = """
357{% if perms.dcim.change_interface %}
358 <span class="dropdown">
359 <button type="button" class="btn btn-primary btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" title="Add">
360 <span class="mdi mdi-plus-thick" aria-hidden="true"></span>
361 </button>
362 <ul class="dropdown-menu dropdown-menu-end">
363 {% if perms.ipam.add_ipaddress %}
364 <li><a class="dropdown-item" href="{% url 'ipam:ipaddress_add' %}?interface={{ record.pk }}&return_url={% url 'dcim:device_interfaces' pk=object.pk %}">IP Address</a></li>
365 {% endif %}
366 {% if perms.dcim.add_macaddress %}
367 <li><a class="dropdown-item" href="{% url 'dcim:macaddress_add' %}?interface={{ record.pk }}&return_url={% url 'dcim:device_interfaces' pk=object.pk %}">MAC Address</a></li>
368 {% endif %}
369 {% if perms.dcim.add_inventoryitem %}
370 <li><a class="dropdown-item" href="{% url 'dcim:inventoryitem_add' %}?device={{ record.device_id }}&component_type={{ record|content_type_id }}&component_id={{ record.pk }}&return_url={% url 'dcim:device_interfaces' pk=object.pk %}">Inventory Item</a></li>
371 {% endif %}
372 {% if perms.dcim.add_interface %}
373 <li><a class="dropdown-item" href="{% url 'dcim:interface_add' %}?device={{ record.device_id }}&parent={{ record.pk }}&name={{ record.name }}.&type=virtual&return_url={% url 'dcim:device_interfaces' pk=object.pk %}">Child Interface</a></li>
374 {% endif %}
375 {% if perms.vpn.add_l2vpntermination %}
376 <li><a class="dropdown-item" href="{% url 'vpn:l2vpntermination_add' %}?device={{ object.pk }}&interface={{ record.pk }}&return_url={% url 'dcim:device_interfaces' pk=object.pk %}">L2VPN Termination</a></li>
377 {% endif %}
378 {% if perms.ipam.add_fhrpgroupassignment %}
379 <li><a class="dropdown-item" href="{% url 'ipam:fhrpgroupassignment_add' %}?interface_type={{ record|content_type_id }}&interface_id={{ record.pk }}&return_url={% url 'dcim:device_interfaces' pk=object.pk %}">Assign FHRP Group</a></li>
380 {% endif %}
381 </ul>
382 </span>
383{% endif %}
384{% if record.link %}
385 <a href="{% url 'dcim:interface_trace' pk=record.pk %}" class="btn btn-primary btn-sm" title="Trace"><i class="mdi mdi-transit-connection-variant"></i></a>
386{% endif %}
387{% if record.cable %}
388 {% include 'dcim/inc/cable_toggle_buttons.html' with cable=record.cable %}
389 {% if perms.dcim.change_cable or perms.dcim.delete_cable %}
390 <span class="dropdown">
391 <button type="button" class="btn btn-warning btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
392 <span class="mdi mdi-ethernet-cable" aria-hidden="true"></span>
393 </button>
394 <ul class="dropdown-menu dropdown-menu-end">
395 {% if perms.dcim.change_cable %}
396 <li><a class="dropdown-item" href="{% url 'dcim:cable_edit' pk=record.cable.pk %}?return_url={% url 'dcim:device_interfaces' pk=object.pk %}">
397 <i class="mdi mdi-pencil-outline"></i>
398 Edit cable
399 </a>
400 </li>
401 {% endif %}
402 {% if perms.dcim.delete_cable %}
403 <li><a class="dropdown-item" href="{% url 'dcim:cable_delete' pk=record.cable.pk %}?return_url={% url 'dcim:device_interfaces' pk=object.pk %}">
404 <i class="mdi mdi-trash-can-outline"></i>
405 Delete cable
406 </a>
407 </li>
408 {% endif %}
409 </ul>
410 </span>
411 {% endif %}
412{% elif record.wireless_link %}
413 {% if perms.wireless.delete_wirelesslink %}
414 <a href="{% url 'wireless:wirelesslink_delete' pk=record.wireless_link.pk %}?return_url={% url 'dcim:device_interfaces' pk=object.pk %}" title="Delete wireless link" class="btn btn-danger btn-sm">
415 <i class="mdi mdi-wifi-off" aria-hidden="true"></i>
416 </a>
417 {% endif %}
418{% elif record.type == 'virtual' %}
419 {% if perms.vpn.add_tunnel and not record.tunnel_termination %}
420 <a href="{% url 'vpn:tunnel_add' %}?termination1_type=dcim.device&termination1_parent={{ record.device.pk }}&termination1_termination={{ record.pk }}&return_url={% url 'dcim:device_interfaces' pk=object.pk %}" title="Create a tunnel" class="btn btn-success btn-sm">
421 <i class="mdi mdi-tunnel-outline" aria-hidden="true"></i>
422 </a>
423 {% elif perms.vpn.delete_tunneltermination and record.tunnel_termination %}
424 <a href="{% url 'vpn:tunneltermination_delete' pk=record.tunnel_termination.pk %}?return_url={% url 'dcim:device_interfaces' pk=object.pk %}" title="Remove tunnel" class="btn btn-danger btn-sm">
425 <i class="mdi mdi-tunnel-outline" aria-hidden="true"></i>
426 </a>
427 {% endif %}
428 {% if perms.circuits.add_virtualcircuittermination and not record.virtual_circuit_termination %}
429 <a href="{% url 'circuits:virtualcircuittermination_add' %}?interface={{ record.pk }}&return_url={% url 'dcim:device_interfaces' pk=object.pk %}" title="Terminate a virtual circuit" class="btn btn-success btn-sm">
430 <i class="mdi mdi-vector-line" aria-hidden="true"></i>
431 </a>
432 {% elif perms.circuits.delete_virtualcircuittermination and record.virtual_circuit_termination %}
433 <a href="{% url 'circuits:virtualcircuittermination_delete' pk=record.virtual_circuit_termination.pk %}?return_url={% url 'dcim:device_interfaces' pk=object.pk %}" title="Remove virtual circuit" class="btn btn-danger btn-sm">
434 <i class="mdi mdi-vector-line" aria-hidden="true"></i>
435 </a>
436 {% endif %}
437{% elif record.is_wired and perms.dcim.add_cable %}
438 <a href="#" class="btn btn-outline-secondary btn-sm disabled"><i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i></a>
439 <a href="#" class="btn btn-outline-secondary btn-sm disabled"><i class="mdi mdi-lan-connect" aria-hidden="true"></i></a>
440 {% if not record.mark_connected %}
441 <span class="dropdown">
442 <button type="button" class="btn btn-success btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" title="Connect cable">
443 <span class="mdi mdi-ethernet-cable" aria-hidden="true"></span>
444 </button>
445 <ul class="dropdown-menu dropdown-menu-end">
446 <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.interface&a_terminations={{ record.pk }}&b_terminations_type=dcim.interface&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_interfaces' pk=object.pk %}">Interface</a></li>
447 <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.interface&a_terminations={{ record.pk }}&b_terminations_type=dcim.frontport&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_interfaces' pk=object.pk %}">Front Port</a></li>
448 <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.interface&a_terminations={{ record.pk }}&b_terminations_type=dcim.rearport&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_interfaces' pk=object.pk %}">Rear Port</a></li>
449 <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.interface&a_terminations={{ record.pk }}&b_terminations_type=circuits.circuittermination&termination_b_site={{ object.site.pk }}&return_url={% url 'dcim:device_interfaces' pk=object.pk %}">Circuit Termination</a></li>
450 </ul>
451 </span>
452 {% else %}
453 <a href="#" class="btn btn-outline-secondary btn-sm disabled"><i class="mdi mdi-ethernet-cable" aria-hidden="true"></i></a>
454 {% endif %}
455{% elif record.is_wireless and perms.wireless.add_wirelesslink %}
456 <a href="{% url 'wireless:wirelesslink_add' %}?site_a={{ record.device.site.pk }}&location_a={{ record.device.location.pk }}&device_a={{ record.device_id }}&interface_a={{ record.pk }}&site_b={{ record.device.site.pk }}&location_b={{ record.device.location.pk }}" class="btn btn-success btn-sm">
457 <span class="mdi mdi-wifi-plus" aria-hidden="true"></span>
458 </a>
459{% endif %}
460"""
462FRONTPORT_BUTTONS = """
463{% if perms.dcim.add_inventoryitem %}
464 <a href="{% url 'dcim:inventoryitem_add' %}?device={{ record.device_id }}&component_type={{ record|content_type_id }}&component_id={{ record.pk }}&return_url={% url 'dcim:device_frontports' pk=object.pk %}" class="btn btn-sm btn-primary" title="Add inventory item">
465 <i class="mdi mdi-plus-thick" aria-hidden="true"></i>
466 </a>
467{% endif %}
468{% if record.cable %}
469 <a href="{% url 'dcim:frontport_trace' pk=record.pk %}" class="btn btn-primary btn-sm" title="Trace"><i class="mdi mdi-transit-connection-variant"></i></a>
470 {% include 'dcim/inc/cable_toggle_buttons.html' with cable=record.cable %}
471 {% if perms.dcim.change_cable or perms.dcim.delete_cable %}
472 <span class="dropdown">
473 <button type="button" class="btn btn-warning btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
474 <span class="mdi mdi-ethernet-cable" aria-hidden="true"></span>
475 </button>
476 <ul class="dropdown-menu dropdown-menu-end">
477 {% if perms.dcim.change_cable %}
478 <li><a class="dropdown-item" href="{% url 'dcim:cable_edit' pk=record.cable.pk %}?return_url={% url 'dcim:device_frontports' pk=object.pk %}">
479 <i class="mdi mdi-pencil-outline"></i>
480 Edit cable
481 </a>
482 </li>
483 {% endif %}
484 {% if perms.dcim.delete_cable %}
485 <li><a class="dropdown-item" href="{% url 'dcim:cable_delete' pk=record.cable.pk %}?return_url={% url 'dcim:device_frontports' pk=object.pk %}">
486 <i class="mdi mdi-trash-can-outline"></i>
487 Delete cable
488 </a>
489 </li>
490 {% endif %}
491 </ul>
492 </span>
493 {% endif %}
494{% elif perms.dcim.add_cable %}
495 <a href="#" class="btn btn-outline-secondary btn-sm disabled"><i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i></a>
496 <a href="#" class="btn btn-outline-secondary btn-sm disabled"><i class="mdi mdi-lan-connect" aria-hidden="true"></i></a>
497 {% if not record.mark_connected %}
498 <span class="dropdown">
499 <button type="button" class="btn btn-success btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
500 <span class="mdi mdi-ethernet-cable" aria-hidden="true"></span>
501 </button>
502 <ul class="dropdown-menu dropdown-menu-end">
503 <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.frontport&a_terminations={{ record.pk }}&b_terminations_type=dcim.interface&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_frontports' pk=object.pk %}">Interface</a></li>
504 <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.frontport&a_terminations={{ record.pk }}&b_terminations_type=dcim.consoleserverport&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_frontports' pk=object.pk %}">Console Server Port</a></li>
505 <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.frontport&a_terminations={{ record.pk }}&b_terminations_type=dcim.consoleport&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_frontports' pk=object.pk %}">Console Port</a></li>
506 <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.frontport&a_terminations={{ record.pk }}&b_terminations_type=dcim.frontport&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_frontports' pk=object.pk %}">Front Port</a></li>
507 <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.frontport&a_terminations={{ record.pk }}&b_terminations_type=dcim.rearport&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_frontports' pk=object.pk %}">Rear Port</a></li>
508 <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.frontport&a_terminations={{ record.pk }}&b_terminations_type=circuits.circuittermination&termination_b_site={{ object.site.pk }}&return_url={% url 'dcim:device_frontports' pk=object.pk %}">Circuit Termination</a></li>
509 </ul>
510 </span>
511 {% else %}
512 <a href="#" class="btn btn-outline-secondary btn-sm disabled"><i class="mdi mdi-ethernet-cable" aria-hidden="true"></i></a>
513 {% endif %}
514{% endif %}
515"""
517REARPORT_BUTTONS = """
518{% if perms.dcim.add_inventoryitem %}
519 <a href="{% url 'dcim:inventoryitem_add' %}?device={{ record.device_id }}&component_type={{ record|content_type_id }}&component_id={{ record.pk }}&return_url={% url 'dcim:device_rearports' pk=object.pk %}" class="btn btn-sm btn-primary" title="Add inventory item">
520 <i class="mdi mdi-plus-thick" aria-hidden="true"></i>
521 </a>
522{% endif %}
523{% if record.cable %}
524 <a href="{% url 'dcim:rearport_trace' pk=record.pk %}" class="btn btn-primary btn-sm" title="Trace"><i class="mdi mdi-transit-connection-variant"></i></a>
525 {% include 'dcim/inc/cable_toggle_buttons.html' with cable=record.cable %}
526 {% if perms.dcim.change_cable or perms.dcim.delete_cable %}
527 <span class="dropdown">
528 <button type="button" class="btn btn-warning btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
529 <span class="mdi mdi-ethernet-cable" aria-hidden="true"></span>
530 </button>
531 <ul class="dropdown-menu dropdown-menu-end">
532 {% if perms.dcim.change_cable %}
533 <li><a class="dropdown-item" href="{% url 'dcim:cable_edit' pk=record.cable.pk %}?return_url={% url 'dcim:device_rearports' pk=object.pk %}">
534 <i class="mdi mdi-pencil-outline"></i>
535 Edit cable
536 </a>
537 </li>
538 {% endif %}
539 {% if perms.dcim.delete_cable %}
540 <li><a class="dropdown-item" href="{% url 'dcim:cable_delete' pk=record.cable.pk %}?return_url={% url 'dcim:device_rearports' pk=object.pk %}">
541 <i class="mdi mdi-trash-can-outline"></i>
542 Delete cable
543 </a>
544 </li>
545 {% endif %}
546 </ul>
547 </span>
548 {% endif %}
549{% elif perms.dcim.add_cable %}
550 <a href="#" class="btn btn-outline-secondary btn-sm disabled"><i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i></a>
551 <a href="#" class="btn btn-outline-secondary btn-sm disabled"><i class="mdi mdi-lan-connect" aria-hidden="true"></i></a>
552 {% if not record.mark_connected %}
553 <span class="dropdown">
554 <button type="button" class="btn btn-success btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
555 <span class="mdi mdi-ethernet-cable" aria-hidden="true"></span>
556 </button>
557 <ul class="dropdown-menu dropdown-menu-end">
558 <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.rearport&a_terminations={{ record.pk }}&b_terminations_type=dcim.interface&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_rearports' pk=object.pk %}">Interface</a></li>
559 <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.rearport&a_terminations={{ record.pk }}&b_terminations_type=dcim.consoleserverport&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_rearports' pk=object.pk %}">Console Server Port</a></li>
560 <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.rearport&a_terminations={{ record.pk }}&b_terminations_type=dcim.consoleport&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_rearports' pk=object.pk %}">Console Port</a></li>
561 <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.rearport&a_terminations={{ record.pk }}&b_terminations_type=dcim.frontport&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_rearports' pk=object.pk %}">Front Port</a></li>
562 <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.rearport&a_terminations={{ record.pk }}&b_terminations_type=dcim.rearport&termination_b_site={{ object.site.pk }}&termination_b_rack={{ object.rack.pk }}&return_url={% url 'dcim:device_rearports' pk=object.pk %}">Rear Port</a></li>
563 <li><a class="dropdown-item" href="{% url 'dcim:cable_add' %}?a_terminations_type=dcim.rearport&a_terminations={{ record.pk }}&b_terminations_type=circuits.circuittermination&termination_b_site={{ object.site.pk }}&return_url={% url 'dcim:device_rearports' pk=object.pk %}">Circuit Termination</a></li>
564 </ul>
565 </span>
566 {% else %}
567 <a href="#" class="btn btn-outline-secondary btn-sm disabled"><i class="mdi mdi-ethernet-cable" aria-hidden="true"></i></a>
568 {% endif %}
569{% endif %}
570"""
572DEVICEBAY_BUTTONS = """
573{% if perms.dcim.change_devicebay %}
574 {% if record.installed_device %}
575 <a href="{% url 'dcim:devicebay_depopulate' pk=record.pk %}?return_url={% url 'dcim:device_devicebays' pk=object.pk %}" class="btn btn-danger btn-sm">
576 <i class="mdi mdi-server-minus" aria-hidden="true" title="Remove device"></i>
577 </a>
578 {% elif record.enabled %}
579 <a href="{% url 'dcim:devicebay_populate' pk=record.pk %}?return_url={% url 'dcim:device_devicebays' pk=object.pk %}" class="btn btn-success btn-sm">
580 <i class="mdi mdi-server-plus" aria-hidden="true" title="Install device"></i>
581 </a>
582 {% endif %}
583{% endif %}
584"""
586MODULEBAY_BUTTONS = """
587{% if perms.dcim.add_module %}
588 {% if record.installed_module %}
589 <a href="{% url 'dcim:module_delete' pk=record.installed_module.pk %}?return_url={% url 'dcim:device_modulebays' pk=object.pk %}" class="btn btn-danger btn-sm">
590 <i class="mdi mdi-server-minus" aria-hidden="true" title="Remove module"></i>
591 </a>
592 {% elif record.enabled %}
593 <a href="{% url 'dcim:module_add' %}?device={{ record.device_id }}&module_bay={{ record.pk }}&manufacturer={{ object.device_type.manufacturer_id }}&return_url={% url 'dcim:device_modulebays' pk=object.pk %}" class="btn btn-success btn-sm">
594 <i class="mdi mdi-server-plus" aria-hidden="true" title="Install module"></i>
595 </a>
596 {% endif %}
597{% endif %}
598"""
600MODULETYPEPROFILE_ATTRIBUTES = """
601{% if value %}{% for attr in value %}{{ attr }}{% if not forloop.last %}, {% endif %}{% endfor %}{% endif %}
602"""