{% extends 'base.html' %}

{% load i18n %}
{% load tags %}

{% block title %}{% trans 'Files' %} – {{ block.super }}{% endblock %}

{% block content %}
    <h1>{% trans 'Files' %}
        <small class="pull-right">
        {% if perms.mediafile.can_upload %}
            <a href="{% url 'mediafile_create' %}" class="btn btn-mini btn-primary" rel="tooltip" data-original-title="{% trans 'New file' %}"><i class="icon-plus icon-white"></i> {% trans "New" %}</a>
        {% endif %}
        </small>
    </h1>
    <table class="table table-striped table-bordered">
        <tr>
            <th>{% trans 'Title' %}</th>
            <th class="optional">{% trans 'Type' %}</th>
            <th class="optional-small">{% trans 'Size' %}</th>
            <th class="optional">{% trans 'Upload time' %}</th>
            <th class="optional">{% trans 'Uploaded by' %}</th>
            {% if perms.mediafile.can_manage or perms.mediafile.can_upload %}
                <th class="mini_width">{% trans "Actions" %}</th>
            {% endif %}
        </tr>
        {% for mediafile in mediafile_list %}
        <tr class="{% if mediafile.is_active_slide %}activeline{% endif %}">
            <td><a href="{{ mediafile.mediafile.url }}">{{ mediafile }}</a></td>
            <td class="optional">{% trans mediafile.filetype %}</td>
            <td class="optional-small">{{ mediafile.get_filesize }}</td>
            <td class="optional">{{ mediafile.timestamp }}</td>
            <td class="optional"><a href="{{ mediafile.uploader|absolute_url }}">{{ mediafile.uploader }}</a></td>
            {% if perms.mediafile.can_manage or perms.mediafile.can_upload %}
            <td>
                {% if mediafile.with_action_buttons %}
                <span style="width: 1px; white-space: nowrap;">
                    <a href="{{ mediafile|absolute_url:'update' }}" rel="tooltip" data-original-title="{% trans 'Edit' %}" class="btn btn-mini"><i class="icon-pencil"></i></a>
                    <a href="{{ mediafile|absolute_url:'delete' }}" rel="tooltip" data-original-title="{% trans 'Delete' %}" class="btn btn-mini"><i class="icon-remove"></i></a>
                    {% if perms.mediafile.can_manage and mediafile.is_presentable %}{% if mediafile.filetype in mediafile.PRESENTABLE_FILE_TYPES %}
                    <a href="{{ mediafile|absolute_url:'projector' }}" class="activate_link choose-pdf btn {% if mediafile.is_active_slide %}btn-primary{% endif %} btn-mini" title="{% trans 'Show' %}">
                        <i class="icon-facetime-video {% if mediafile.is_active_slide %}icon-white{% endif %}">
                        </i>
                    </a>
                    {% endif %}{% endif %}
                </span>
                {% else %}
                    &nbsp;
                {% endif %}
            </td>
            {% endif %}
        </tr>
        {% empty %}
        <tr>
            <td colspan="6"><i>{% trans 'No files available.' %}</i></td>
        </tr>
        {% endfor %}
    </table>
{% endblock %}
