{% load inventory_monitor %} {% comment %} Renders a date range as a colored status bar. record -- object carrying the dates (must expose get__status) status_type -- warning threshold key, e.g. 'service' or 'warranty' start_date -- period start, shown in the tooltip end_date -- period end, shown in the tooltip Pairs with date_badge.html, which renders the same status against a single date. Both read get__status(), so the two can never disagree. {% endcomment %} {% with status=record|get_status:status_type from_text=start_date|date:"Y-m-d"|default:"?" to_text=end_date|date:"Y-m-d"|default:"∞" %} {% if status %} {% elif start_date or end_date %} {{ from_text }} — {{ to_text }} {% else %} {{ ''|placeholder }} {% endif %} {% endwith %}