{% extends "base.html" %} {% from "macros.html" import icon, btn, badge %} {% block title %}{{ model_label }}{% endblock %} {% block content %}
{% if total == 0 %}{{ t('No records') }} {% elif total == 1 %}1 {{ t('record') }} {% else %}{{ total }} {{ t('records') }}{% endif %}
| {# Show the actions column whenever there is any per-row action — including "View", so read-only models (can_edit/can_delete false) still expose the detail icon like every other table. #} {% set has_actions = can_edit or can_delete or user_can_view %} {% for s in sort_links %} | {{ s.col }}{% if s.arrow %} {{ s.arrow }}{% endif %} | {% endfor %} {% if has_actions %}{{ t('ACTIONS') }} | {% endif %}
|---|---|---|
| {% for col in columns %} {# Epoch-int timestamp columns (last_seen, revoked_at, ...) are formatted as dates; other columns keep the plain date/passthrough filter. The filter must stay top-level in {{ }} (it is not supported inside {% set %}). #} {% set is_ts_col = col.endswith('_at') or col.endswith('_seen') %} | {% if loop.first %} {# Read-only models (can_edit=False) link to the detail view, not the edit form — no point routing to a page that 403s on save. #} {% if is_ts_col %}{{ row[col] | epoch }}{% else %}{{ row[col] | date }}{% endif %} {% else %} {% if is_ts_col %}{{ row[col] | epoch }}{% else %}{{ row[col] | date }}{% endif %} {% endif %} | {% endfor %} {% if has_actions %}
{% if is_auth_model and row.id != request.user.id and not trash %}
{% endif %}
{# View button - always show if user has view permission #}
{% if user_can_view and not trash %}
{{ icon('search', 16) }}
{% endif %}
{# Edit button - only show if model and user allow edit #}
{% if can_edit and user_can_edit and not trash %}
{{ icon('edit', 16) }}
{% endif %}
{% if trash %}
{% if user_can_delete %}
{% endif %}
{# Delete button - only show if model and user allow delete #}
{% elif can_delete and user_can_delete %}
{% endif %}
|
{% endif %}
{{ t('No records found') }}
{% if q %}{{ t('Try a different search term or filter.') }} {% else %}{{ t('Get started by adding your first record.') }}{% endif %}
{% if can_add and not trash %} {{ icon('plus', 16) }} {{ t('Add first record') }} {% endif %}