{% load dict_key_extras %}

<table class="table table-bordered table-striped table-hover">
    <thead>
        <th>Template name</th>
        <th>Filename</th>
        {% if come_from_admin %}
            <th>User</th>
        {% endif %}
        <th>Actions</th>
    </thead>
    <tbody>
        {% for object in objects %}
            <tr objectid="{{object.template_version.id}}">
                <td>{{ object.title }}</td>
                <td>{{ object.template.filename }}</td>
                {% if come_from_admin %}
                    <td>
                        {{object.user}}
                    </td>
                {% endif %}
                <td>
                    {% if object.template_version.is_disabled %}
                    <a class="btn btn-default restore-{{data.document}}-btn" objectid="{{ object.template_version.id }}">
                        <i class="fa fa-undo"></i> Restore
                    </a>
                    {% else %}
                        {% if come_from_admin %}
                            <a class="btn btn-default view-{{data.document}}-btn" href="{% url 'admin:core_main_app_manage_template_versions' object.template_version.id %}">
                                <i class="fa fa-list"></i> Versions
                            </a>
                            {% url 'admin:core_dashboard_app_edit_template' object.template_version.id as edit_url %}
                            {% include 'core_main_app/common/buttons/edit.html' %}
                        {% else %}
                            <a class="btn btn-default view-{{data.document}}-btn" href="{% url 'core_main_app_manage_template_versions' object.template_version.id %}">
                                <i class="fa fa-list"></i> Versions
                            </a>
                            {% url 'core_dashboard_app_edit_template' object.template_version.id as edit_url %}
                            {% include 'core_main_app/common/buttons/edit.html' %}
                        {% endif %}
                        <a class="btn btn-default disable-{{data.document}}-btn" objectid="{{ object.template_version.id }}">
                            <i class="fa fa-trash"></i> Disable
                        </a>
                    {% endif %}

                </td>
            </tr>
        {% endfor %}
    </tbody>
</table>
