{% load i18n wise_icons %} {% comment %} A record's activity: who created, changed or deleted what, and when, newest first - one card per change, a Field / Before / After table for an edit. It renders what it is handed and knows nothing about where the log lives (django-simple-history, an audit table, your own model), so the same feed serves them all. Pass `entries`, a list of dicts: {'action': 'Updated', # the badge's text 'badge': 'orange', # badge colour: green (created), orange (updated), red (deleted), grey 'actor': 'Sami', # who (optional) 'at': datetime, # when 'subject': 'Sale line', # optional: what the change touched, when it is not the record itself 'detail': '2 × Paracetamol', # optional: and which one 'updated': True, # an edit: Before and After columns instead of a single Value one 'changes': [{'label': 'Quantity', 'old': '1', 'new': '2'}]} # optional Beside it, the usual `_pagination.html` for a long log. With no entries it shows an empty state, `empty_title` / `empty_text` overriding its words. The change table keeps its columns on a phone (`data-table-scroll`) so each entry stays one card rather than splitting into a card per field. {% endcomment %}
{% for entry in entries %}
{{ entry.action }} {% if entry.subject %} {{ entry.subject|capfirst }} {% if entry.detail %}{{ entry.detail }}{% endif %} {% endif %}
{% if entry.actor %}{% lucide "user" size=14 %}{{ entry.actor }}{% endif %}
{% if entry.changes %} {% if entry.updated %} {% else %} {% endif %} {% for change in entry.changes %} {% if entry.updated %} {% endif %} {% endfor %}
{% trans "Field" %}{% trans "Before" %} {% trans "After" %}{% trans "Value" %}
{{ change.label|capfirst }}{{ change.old|default:"—"|linebreaksbr }}{{ change.new|default:"—"|linebreaksbr }}
{% endif %}
{% empty %} {% trans "No activity yet" as default_title %} {% trans "Changes to this record will show up here." as default_text %} {% include 'wise_core/components/_no_data.html' with title=empty_title|default:default_title text=empty_text|default:default_text illustration="empty" heading_level=4 %} {% endfor %}