diff --git a/python/nav/django/templatetags/maintenance.py b/python/nav/django/templatetags/maintenance.py index e30b5557bd..799b1d0e5f 100644 --- a/python/nav/django/templatetags/maintenance.py +++ b/python/nav/django/templatetags/maintenance.py @@ -46,6 +46,18 @@ def component_name(component): return component.pk +@register.filter +def component_description(component): + """Returns a description of a component useful as a link title tooltip. Returns + an empty string if there is no further description than the component's name. + """ + if isinstance(component, MissingComponent): + return str(component) + if hasattr(component, "ip"): + return str(component.ip) + return getattr(component, "description", "") + + @register.filter def component_db_table(component): """Returns the database table name of a model object used as a maintenance diff --git a/python/nav/web/templates/maintenance/frag-component-trail.html b/python/nav/web/templates/maintenance/frag-component-trail.html index 1b64cb2670..fc91b656cc 100644 --- a/python/nav/web/templates/maintenance/frag-component-trail.html +++ b/python/nav/web/templates/maintenance/frag-component-trail.html @@ -1,10 +1,10 @@ {% load maintenance %} {% for element in trail %} - {% with element|component_name as title %} + {% with element|component_name as name %} {% if element.get_absolute_url %} - {{ title }} + {{ name }} {% else %} - {{ title }} + {{ name }} {% endif %} {% endwith %} {% if not forloop.last %} → {% endif %}