{% extends "admin/base_site.html" %}
{% load i18n admin_urls admin_kubi_tags %}

{% block breadcrumbs %}
  {% spaceless %}
    <nav class="breadcrumb">
      {% breadcrumbs_icon opts %}
      <a class="breadcrumb-item" href="{% url opts|admin_urlname:'changelist' %}">{{ module_name }}</a>
      <a class="breadcrumb-item" href="{% url opts|admin_urlname:'change' object.pk|admin_urlquote %}">{{ object|truncatewords:"18" }}</a>
      <span class="breadcrumb-item active">{% trans 'History' %}</span>
    </nav>
  {% endspaceless %}
{% endblock %}

{% block content %}
<div id="content-main" class="container-fluid mt-3 mb-3">
	<div class="module">

		{% regroup action_list|dictsortreversed:"action_time" by action_time.date as actions_date_list %}
		<div class="history timeline">
		{% for item in actions_date_list %}
			{% ifchanged %}<h3>{{ item.grouper|date:"Y" }}</h3>{% endifchanged %}
			<div class="item {% cycle 'left' 'right' %}">
				<span class="date">
					<b>{{ item.grouper|date:"d" }}</b>
					<small>{{ item.grouper|date:"M" }}</small>
				</span>

				<div class="actions">
					<table id="change-history" class="table table-bordered table-striped">
						<thead>
						<tr>
							<th scope="col">{% trans 'Date/time' %}</th>
							<th scope="col">{% trans 'User' %}</th>
							<th scope="col">{% trans 'Action' %}</th>
						</tr>
						</thead>
						<tbody>
						{% for action in item.list %}
						<tr>
							<th scope="row">{{ action.action_time|date:"H:i" }}</th>
							<td>{{ action.user.get_username }}{% if action.user.get_full_name %} ({{ action.user.get_full_name }}){% endif %}</td>
							<td>{{ action.get_change_message }}</td>
						</tr>
						{% endfor %}
						</tbody>
					</table>
				</div>
			</div>
		{% endfor %}
		</div>

	</div>
</div>
{% endblock %}
