{% load file_tags %}
{% load tagging_tags %}
{% load i18n %}

{% tags_for_object file as tags %}

<div class="file-wrap">
    <div class="options">
        <div class="quick-options">
            {% file_options request.user file %}           
        </div>
    </div>

    {% if file.icon %}
    <div class="icon"><img src="{{ file.icon }}" /></div>
    {% endif %}

    <h2><a href="{% url file file.pk %}">{{ file.get_name }}</a></h2>

    <div class="download">
        <a title="Download {{ file.ext }}" href="{% url file file.pk 'download' %}">{% trans "Download" %} this {{ file.type }}</a>
    </div>

    <div class="meta">
        {% with file.category_set as file_cat %}
        {% if file_cat %}
        <div class="categories">
            <strong>{% trans "Category:" %} </strong><a href="{% url files %}?q=category:{{ file_cat.category }}">{{ file_cat.category }}</a>
        {% if file_cat.sub_category %}
            | <strong>{% trans "Sub Category:" %} </strong><a href="{% url files %}?q=sub_category:{{ file_cat.sub_category }}">{{ file_cat.sub_category }}</a>
        {% endif %}
        </div>
        {% endif %}
        {% endwith %}
    
        {% if tags %}
        <div class="tags">
            <strong>Tags: </strong>
        {% for tag in tags %}
            <a href="{% url files %}?q=tag:{{ tag }}">{{ tag }}</a>{% if not forloop.last %}, {% endif %}
        {% endfor %}
        </div>
        {% endif %}
        <div class="submitted"><a href="{% url event_log.search %}?source=files&object_id={{ file.pk }}">{% trans "Updated" %} {{ file.update_dt|date:"D d M Y P" }} {% trans "by" %} {{ file.owner }}</a></div>
    </div>

    <!-- delete-file form -->
    <form name="file-delete" method="POST" action="{% url file.delete file.pk %}">{% csrf_token %}
        <input type="hidden" name="action" value="delete">
    </form>
</div>
