{% load inventory_monitor %} {% comment %} Renders a single end date as a colored badge. record -- object carrying the dates (must expose get__status) status_type -- warning threshold key, e.g. 'service' or 'warranty' date_value -- the end date used as the badge label (may be None) The color comes from the same get__status() that the status bar uses, so the two columns can never disagree. An object with no dates at all has no status and falls back to the placeholder; an object with a start but no end is active coverage and is labelled with an infinity sign. The icon is not decoration: it carries the "needs attention" states for readers who cannot rely on the badge color (color blindness, greyscale printing). See WCAG 1.4.1. {% endcomment %} {% with status=record|get_status:status_type date_text=date_value|date:"Y-m-d"|default:"∞" %} {% if status %} {% if status.color == 'danger' %} {% elif status.color == 'warning' %} {% endif %} {{ date_text }} {% elif date_value %} {{ date_text }} {% else %} {{ ''|placeholder }} {% endif %} {% endwith %}