{% load helpers %}
{% if changelog and perms.extras.view_objectchange %}
    {% for change in changelog %}
        {% with action=change.get_action_display|lower %}
            <div class="list-group-item">
                {% if action == 'created' %}
                    <span class="label label-success">Created</span>
                {% elif action == 'updated' %}
                    <span class="label label-warning">Modified</span>
                {% elif action == 'deleted' %}
                    <span class="label label-danger">Deleted</span>
                {% endif %}
                {{ change.changed_object_type.name|bettertitle }}
                {% if change and change.changed_object and change.changed_object.get_absolute_url %}
                    {{ change.changed_object|hyperlinked_object }}
                {% elif change and change.changed_object %}
                    {{ change.changed_object|default:change.object_repr }}
                {% elif change %}
                    {{ change.object_repr }}
                {% endif %}
                <br />
                <small>
                    <span class="text-muted">{{ change.user_name }} -</span>
                    <a href="{{ change.get_absolute_url }}" class="text-muted">{{ change.time|date:settings.SHORT_DATETIME_FORMAT }}</a>
                </small>
            </div>
        {% endwith %}
        {% if forloop.last %}
            <div class="list-group-item text-right">
                <a href="{% url 'extras:objectchange_list' %}">View All Changes</a>
            </div>
        {% endif %}
    {% endfor %}
{% elif perms.extras.view_objectchange %}
    <div class="panel-body text-muted">
        No change history found
    </div>
{% else %}
    <div class="panel-body text-muted">
        <i class="mdi mdi-lock"></i> No permission
    </div>
{% endif %}
