{% extends "admin/base_site.html" %}
{% load i18n admin_static log %}

{% block extrastyle %}{{ block.super }}<link rel="stylesheet" type="text/css" href="{% static "admin/css/dashboard.css" %}" />{% endblock %}

{% block coltype %}colMS{% endblock %}

{% block bodyclass %}{{ block.super }} dashboard{% endblock %}

{% block content %}
    <div class="dashboard-item">
        <div class="dashboard-item-header">
            <span class="dashboard-item-header-title">
                {% trans "Applications" %}
            </span>
        </div>
        <div class="dashboard-item-content">
            {% if app_list %}
                <ul>
                    {% for app in app_list %}
                        <li class="contrast">
                            {% if app.name != app.app_label|capfirst|escape %}
                                <a href="{{ app.app_url }}" title="{% blocktrans with name=app.name %}Models in the {{ name }} application{% endblocktrans %}">{{ app.name }}</a>
                            {% else %}
                                {% trans app.app_label as app_label %}
                                <a href="{{ app.app_url }}" title="{% blocktrans with name=app_label %}Models in the {{ name }} application{% endblocktrans %}">{{ app_label }}</a>
                            {% endif %}
                        </li>

                        {% for model in app.models %}
                            <li>
                                <span class="float-right">
                                    {% if model.add_url %}
                                        <a href="{{ model.add_url }}" class="addlink" title="{% trans 'Add' %}"><span class="icon-add3"></span></a>
                                    {% else %}
                                        &nbsp;
                                    {% endif %}

                                    {% if model.admin_url %}
                                        <a href="{{ model.admin_url }}" class="changelink" title="{% trans 'Change' %}"><span class="icon-edit"></span></a>
                                    {% else %}
                                        &nbsp;
                                    {% endif %}
                                </span>

                                {% if model.admin_url %}
                                    <a href="{{ model.admin_url }}">{{ model.name }}</a>
                                {% else %}
                                    {{ model.name }}
                                {% endif %}
                            </li>
                        {% endfor %}
                    {% endfor %}
                </ul>
            {% else %}
                <p>{% trans "You don't have permission to edit anything." %}</p>
            {% endif %}
        </div>
    </div>
{% endblock %}

{% block sidebar %}
    {% get_admin_log 10 as admin_log for_user user %}

    <div class="dashboard-item">
        <div class="dashboard-item-header">
            <span class="dashboard-item-header-title">
                {% trans 'Recent Actions' %}
            </span>
        </div>
        <div class="dashboard-item-content">
            <ul>
                {% if not admin_log %}
                    <li>
                        {% trans 'None available' %}
                    </li>
                {% else %}
                    {% for entry in admin_log %}
                        <li class="nowrap">
                            <span class="float-right">
                                <span class="icon-user tooltip" title="{{ entry.user }}"></span>
                                <span class="icon-clock tooltip" title="{{ entry.action_time }}"></span>
                            </span>

                            {% if entry.is_addition %}
                                <span class="icon-add3"></span>
                            {% endif %}
                            {% if entry.is_change %}
                                <span class="icon-edit"></span>
                            {% endif %}
                            {% if entry.is_deletion %}
                                <span class="icon-cross"></span>
                            {% endif %}

                            {% if entry.content_type %}
                                <span class="mini quiet">{% filter capfirst %}{{ entry.content_type }}{% endfilter %}</span>
                            {% else %}
                                <span class="mini quiet">{% trans 'Unknown content' %}</span>
                            {% endif %}

                            {% if entry.is_deletion or not entry.get_admin_url %}
                                {{ entry.object_repr }}
                            {% else %}
                                <a href="{{ entry.get_admin_url }}">{{ entry.object_repr }}</a>
                            {% endif %}
                        </li>
                    {% endfor %}
                {% endif %}
            </ul>
        </div>
    </div>
{% endblock %}