LINKTERMINATION = """
{% for termination in value %}
{% if termination.parent_object %}
{{ termination.parent_object }}
{% endif %}
{{ termination }} {% if not forloop.last %} {% endif %}
{% empty %}
{{ ''|placeholder }}
{% endfor %}
"""
INTERFACE_LINKTERMINATION = """
{% load i18n %}
{% if record.is_virtual and record.virtual_circuit_termination %}
{% for termination in record.connected_endpoints %}
{{ termination.interface.parent_object }}
{{ termination.interface }}
{% trans "via" %}
{{ termination.parent_object }}
{% if not forloop.last %} {% endif %}
{% endfor %}
{% else %}""" + LINKTERMINATION + """{% endif %}
"""
INTERFACE_LAG_MEMBERS_LINKTERMINATION = """
{% for termination in value %}
{% if termination.parent_object %}
{{ termination.parent_object }}
{% endif %}
{{ termination }}
{% if termination.lag %}
{{ termination.lag }}
(LAG)
{% endif %}
{% if not forloop.last %} {% endif %}
{% empty %}
{{ ''|placeholder }}
{% endfor %}
"""
CABLE_LENGTH = """
{% load helpers %}
{% if record.length %}{{ record.length|floatformat:"-2" }} {{ record.length_unit }}{% endif %}
"""
WEIGHT = """
{% load helpers %}
{% if value %}{{ value|floatformat:"-2" }} {{ record.weight_unit }}{% endif %}
"""
DEVICE_LINK = """
{{ record.label|default:'Unnamed device ' }}
"""
DEVICEBAY_STATUS = """
{% if record.installed_device_id %}
{{ record.installed_device.get_status_display }}
{% else %}
Vacant
{% endif %}
"""
INTERFACE_IPADDRESSES = """
{% if value.count > 3 %}
{{ value.count }}
{% else %}
{% for ip in value.all %}
{% if ip.status != 'active' %}
{{ ip }}
{% else %}
{{ ip }}
{% endif %}
{% endfor %}
{% endif %}
"""
INTERFACE_FHRPGROUPS = """
{% for assignment in value.all %}
{{ assignment.group }}
{% endfor %}
"""
INTERFACE_TAGGED_VLANS = """
{% load i18n %}
{% if record.mode == 'access' %}
{% elif record.mode == 'tagged-all' %}
{% trans "All" %}
{% else %}
{% if value.count > 3 %}
{{ value.count }} VLANs
{% else %}
{% for vlan in value.all %}
{{ vlan }}
{% endfor %}
{% endif %}
{% endif %}
"""
INTERFACE_WIRELESS_LANS = """
{% for wlan in value.all %}
{{ wlan }}
{% endfor %}
"""
POWERFEED_CABLE = """
{{ value }}
"""
POWERFEED_CABLETERMINATION = """
{{ value.parent_object }}
{{ value }}
"""
LOCATION_BUTTONS = """
"""
OUTER_UNIT = """
{% load helpers %}
{% if value %}{{ value }} {{ record.outer_unit }}{% endif %}
"""
#
# Device component templatebuttons
#
MODULAR_COMPONENT_TEMPLATE_BUTTONS = """
{% load helpers %}
{% if perms.dcim.add_inventoryitemtemplate and record.device_type_id %}
{% endif %}
"""
#
# Device component buttons
#
CONSOLEPORT_BUTTONS = """
{% if perms.dcim.add_inventoryitem %}
{% endif %}
{% if record.cable %}
{% include 'dcim/inc/cable_toggle_buttons.html' with cable=record.cable %}
{% if perms.dcim.change_cable or perms.dcim.delete_cable %}
{% endif %}
{% elif perms.dcim.add_cable %}
{% else %}
{% endif %}
"""
CONSOLESERVERPORT_BUTTONS = """
{% if perms.dcim.add_inventoryitem %}
{% endif %}
{% if record.cable %}
{% include 'dcim/inc/cable_toggle_buttons.html' with cable=record.cable %}
{% if perms.dcim.change_cable or perms.dcim.delete_cable %}
{% endif %}
{% elif perms.dcim.add_cable %}
{% else %}
{% endif %}
"""
POWERPORT_BUTTONS = """
{% if perms.dcim.add_inventoryitem %}
{% endif %}
{% if record.cable %}
{% include 'dcim/inc/cable_toggle_buttons.html' with cable=record.cable %}
{% if perms.dcim.change_cable or perms.dcim.delete_cable %}
{% endif %}
{% elif perms.dcim.add_cable %}
{% else %}
{% endif %}
"""
POWEROUTLET_BUTTONS = """
{% if perms.dcim.add_inventoryitem %}
{% endif %}
{% if record.cable %}
{% include 'dcim/inc/cable_toggle_buttons.html' with cable=record.cable %}
{% if perms.dcim.change_cable or perms.dcim.delete_cable %}
{% endif %}
{% elif perms.dcim.add_cable %}
{% if not record.mark_connected %}
{% else %}
{% endif %}
{% endif %}
"""
INTERFACE_BUTTONS = """
{% if perms.dcim.change_interface %}
{% endif %}
{% if record.link %}
{% endif %}
{% if record.cable %}
{% include 'dcim/inc/cable_toggle_buttons.html' with cable=record.cable %}
{% if perms.dcim.change_cable or perms.dcim.delete_cable %}
{% endif %}
{% elif record.wireless_link %}
{% if perms.wireless.delete_wirelesslink %}
{% endif %}
{% elif record.type == 'virtual' %}
{% if perms.vpn.add_tunnel and not record.tunnel_termination %}
{% elif perms.vpn.delete_tunneltermination and record.tunnel_termination %}
{% endif %}
{% if perms.circuits.add_virtualcircuittermination and not record.virtual_circuit_termination %}
{% elif perms.circuits.delete_virtualcircuittermination and record.virtual_circuit_termination %}
{% endif %}
{% elif record.is_wired and perms.dcim.add_cable %}
{% if not record.mark_connected %}
{% else %}
{% endif %}
{% elif record.is_wireless and perms.wireless.add_wirelesslink %}
{% endif %}
"""
FRONTPORT_BUTTONS = """
{% if perms.dcim.add_inventoryitem %}
{% endif %}
{% if record.cable %}
{% include 'dcim/inc/cable_toggle_buttons.html' with cable=record.cable %}
{% if perms.dcim.change_cable or perms.dcim.delete_cable %}
{% endif %}
{% elif perms.dcim.add_cable %}
{% if not record.mark_connected %}
{% else %}
{% endif %}
{% endif %}
"""
REARPORT_BUTTONS = """
{% if perms.dcim.add_inventoryitem %}
{% endif %}
{% if record.cable %}
{% include 'dcim/inc/cable_toggle_buttons.html' with cable=record.cable %}
{% if perms.dcim.change_cable or perms.dcim.delete_cable %}
{% endif %}
{% elif perms.dcim.add_cable %}
{% if not record.mark_connected %}
{% else %}
{% endif %}
{% endif %}
"""
DEVICEBAY_BUTTONS = """
{% if perms.dcim.change_devicebay %}
{% if record.installed_device %}
{% else %}
{% endif %}
{% endif %}
"""
MODULEBAY_BUTTONS = """
{% if perms.dcim.add_module %}
{% if record.installed_module %}
{% else %}
{% endif %}
{% endif %}
"""
MODULETYPEPROFILE_ATTRIBUTES = """
{% if value %}{% for attr in value %}{{ attr }}{% if not forloop.last %}, {% endif %}{% endfor %}{% endif %}
"""