{% load cat_extra %}
{% load utils_extra %}
{% load event_extra %}


<article class="{% if not duplicate.representative %}duplicate_tofix{% endif %}">
    <header><h2><a href="{% url 'view_duplicate' duplicate.pk %}">
        {% if duplicate.representative %}Duplication{% else %}Possible duplication{% endif %}
        &nbsp;:</a> {{ events|length }} événements le {{ events.0.start_day }}</h2>
    </header>
    <h3>Versions</h3>
    <ul>
        {% for e in events %}
        <li>{{ e.start_day }}{% if e.start_time %} à {{ e.start_time }}{% endif %}&nbsp;: {{ e|picto_status }} <a href="{{ e.get_absolute_url }}">{{ e.title }}</a>{% if e.modified_date %} dernière modification le {{ e.modified_date }}{% else %}créé le {{ e.created_date }}{% endif %}</li>
    {% endfor %}
    </ul>
    {% with duplicate.get_import_messages as messages %}
    {% if messages|length > 0 %}
    <h3>Messages d'import et de mise à jour</h3>
    <ul>
        {% for m in messages %}
            <li>
                {{ m.date }}, {% if m.message_type %}{{ m.get_message_type_display }}{% endif %}&nbsp;: <a href="{% url 'message' m.pk %}">{{ m.subject }}</a>
                pour événement <a href="{{ obj.related_event.get_absolute_url }}">{{ m.related_event.pk }}</a>&nbsp;: <em>{{ m.message }}</em>
            </li>
        {% endfor %}
    </ul>
    {% endif %}
    {% endwith %}
    {% if perms.agenda_culturel.change_duplicatedevents %}
    <footer class="infos-and-buttons">
        <div class="infos"></div>
        <div class="buttons">
            <a role="button" href="{% url 'view_duplicate' duplicate.pk %}">Consulter {% picto_from_name "eye" %}</a>
            <a role="button" href="{% url 'fix_duplicate' duplicate.pk %}">{% if duplicate.representative %}Modifier{% else %}Corriger{% endif %} {% picto_from_name "tool" %}</a>
        </div>
    </footer>
    {% endif %}
</article>
