{% extends "egonomy_base.html" %}
{% load static %}
{% load i18n %}
{% load thumbnail %}
{% load egonomy_thumbnail %}

{% block title %}{% trans "Annotate a picture" %}{% endblock %}

{% block content %}
                <div class="fullwidth">
                    <div class="column column-half">
                        <h2>{{ img.metadata.titre|default:_("No title") }}</h2>
                        <div class="fullphoto center-image">
                          {% with img.info.image_file as image %}
                          {% if image|ratio > 0.8 %}
                           {% thumbnail image "476" format="PNG" crop="center" as im %}
                            <img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"/>
                           {% empty %}
                            <img src="{% static 'egonomy/img/empty.gif' %}" width="476" height="476" class="placeholder" />
                           {% endthumbnail %}
                          {% else %}
                           {% thumbnail image "x600" format="PNG" crop="center" as im %}
                            <img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"/>
                           {% empty %}
                            <img src="{% static 'egonomy/img/empty.gif' %}" width="476" height="476" class="placeholder" />
                           {% endthumbnail %}
                          {% endif %}
                          {% endwith %}
                        </div>
                    </div>
                    <div class="column column-half">
                        <form action="#">
                        <table class="image-metadata">
                            <tr>
                                <th>{% trans "Description" %}&nbsp;:</th>
                                <td>{{ img.metadata.description|default:"" }}</td>
                            </tr>
                            <tr>
                                <th>{% trans "Author" %}&nbsp;:</th>
                                <td>{{ img.metadata.auteur|default:"" }}</td>
                            </tr>
                            <tr>
                                <th>{% trans "Period" %}&nbsp;:</th>
                                <td>{{ img.metadata.periode|default:"" }}</td>
                            </tr>
                            <tr>
                                <th>{% trans "Production site" %}&nbsp;:</th>
                                <td>{{ img.metadata.site|default:"" }}</td>
                            </tr>
                            <tr>
                                <th>{% trans "Localization" %}&nbsp;:</th>
                                <td>{{ img.metadata.lieu|default:"" }}</td>
                            </tr>
                            <tr>
                                <th>{% trans "RMN keywords" %}&nbsp;:</th>
                                <td>{{ img.metadata.mots_cles|default:"" }}</td>
                            </tr>
                            <tr>
                                <th>&nbsp;</th>
                                <td>&nbsp;</td>
                            </tr>
                            <tr>
                                <th>{% trans "Pertimm title" %}&nbsp;:</th>
                                <td>{{ img.metadata.titre_pertimm|default:"" }}</td>
                            </tr>
                            <tr>
                                <th>{% trans "Pertimm description" %}&nbsp;:</th>
                                <td>{{ img.metadata.description_pertimm|default:"" }}</td>
                            </tr>
                            <tr>
                                <th>{% trans "Pertimm thesaurus" %}&nbsp;:</th>
                                <td>{{ img.metadata.thesaurus_pertimm_list|join:","|default:"" }}</td>
                            </tr>
                            <!--tr>
                                <th> </th>
                                <td><input class="user-submit" type="submit" value="{% trans 'Save keywords' %}" /></td>
                            </tr-->
                            <tr>
                                <th>{% trans "Last fragment created" %}&nbsp;:</th>
                                <td>{% if last_frg %}<a href="{% url 'view_fragment' fragment_pk=last_frg.pk %}">{{ last_frg.title }}</a>, {{ last_frg.date_saved }} {% trans 'by' %} <strong><a href="{% url 'user_fragments' username=last_frg.author %}">{{ last_frg.author }}</a></strong>{% endif %}</td>
                            </tr>
                        </table>
                        </form>
                        <div class="fullwidth">
                            <a href="{% url 'create_fragment' image_id=img.id %}" class="big-button">{% trans "Create a fragment" %}</a>
                        </div>
                    </div>
                </div>
                <div class="fullwidth">
                    <div class="column column-full">
                        <h2>{% trans "Fragments from this picture" %}</h2>
                        <ul class="fullwidth">
                          {% for fragment in fragment_list %}
                            <li class="subcol subcol-eighth">
                                <a href="{% url 'view_fragment' fragment_pk=fragment.pk  %}">
                                <div class="center-image">
                                    <div class="image-and-fragment">
                                     {% include "partial/picture_and_red_fragment.html" %}
                                    </div>
                                </div>
                                <h3>{{ fragment.title }}</h3></a>
                                <p>{% trans "Annotated by" %} <strong><a href="{% url 'user_fragments' username=fragment.author %}">{{ fragment.author }}</a></strong></p>
                            </li>
                          {% endfor %}
                        </ul>
                    </div>
                </div>
{% endblock %}

