{% extends "events/page.html" %}
{% load i18n comments thumbnail %}

{% block title %}
{% trans 'Event Archive' %} {% if month %}{{ month|date:'F Y' }} {% else %}{% if year %}{{year}}{% endif %}{% endif %}
{% endblock %}

{% block teaser %}
<h1>{% trans 'Event Archive' %} {% if month %}{{ month|date:'F Y' }}{% elif year %}{{year|date:'Y'}}{% endif %}</h1>
{% endblock %}

{% block redbox %}
<h2>Archive</h2>
<ul>
    {% if year %}
    {% for date in date_list %}
    <li><a href="{% url 'event-archive' year|date:'Y' date|date:'m' %}">{{ date|date:'F' }}</a></li>
    {% endfor %}
    {% elif month %}
    <li><a href="{% url 'event-archive'  month|date:'Y' %}">{{ month|date:'Y' }}</a></li>
    {% else %}
    {% for date in date_list %}
    <li><a href="{% url 'event-archive'  date|date:'Y' %}">{{ date|date:'Y' }}</a></li>
    {% endfor %}
    {% endif %}
</ul>
{% endblock %}

{% block maincontent %}
{% regroup event_list by start|date:'F Y' as month_list %}
{% for month in month_list %}
<h3 class="grid_12">{{ month.grouper }}</h3>
{% for event in month.list %}
{% get_comment_count for event as comment_count %}

<div class="grid_6">
    <a href="{{ event.get_absolute_url }}" class="thumbnail"><img src="{{ event.get_image|thumbnail_url:'thumbnail' }}"
       alt="{% trans 'Event Image' %}" width="140" height="140"/></a>

    <h4><a href="{{ event.get_absolute_url }}">{{ event.name }}</a></h4>
    <p>
        <span class="fa fa-calendar-o" title="{% trans 'Date' %}" aria-label="{% trans 'Date' %}"></span>
        <time datetime="{{event.start|date:'c'}}">
           {{ event.start|date:'D' }}
           {{ event.start|date:'SHORT_DATE_FORMAT' }} {{hanchan.start|time:'H:i'}}
        </time>
        <span class="fa fa-clock-o" title="{% trans 'Time' %}" aria-label="{% trans 'Time' %}"></span>
        {% if event.end %}
            {% trans "from" %} {{ event.start|time:'H:i' }} {% trans "to" %} {{ event.end|time:'H:i' }}
        {% else %}
            {{ event.start|time:'H:i' }}
        {% endif %}
    </p>

    <p>{{event.description|truncatewords_html:20|safe}}</p>
    <ul class="info">
        <li><span class="fa fa-map-marker" title="{% trans 'Location' %}"></span> {{ event.location }}</li>
        <li><span class="fa fa-comments" title="{% trans 'Comments' %}"></span> <a href="{{event.get_absolute_url}}#comments">{{ comment_count }}</a></li>
        <li><span class="fa fa-camera-retro" title="{% trans 'Photos' %}"></span> <a href="{% url 'event-photo-list' event.pk %}">{{ event.photo_count }}</a></li>
        <li><span class="fa fa-table" title="{% trans 'Hanchans' %}"></span> <a href="{% url 'event-hanchan-list' event.pk %}">{{ event.hanchan_set.count }}</a></li>
        <li><span class="fa fa-glass" title="{% trans 'Hanchans' %}"></span> <a href="{% url 'maistar-game-list' event.pk %}">{{ event.maistargame_set.count }}</a></li>
    </ul>
    {% if perms.events.change_event %}
    <p class="right"><a href="{{ event.get_edit_url }}" class="button"><span class="fa fa-pencil"></span></a></p>
    {% endif %}
</div>
{% endfor %}
{% endfor %}
{% endblock %}
