{% extends "core/base.jinja" %}
{% from "core/macros.jinja" import paginate_jinja %}

{% block title %}
  {%- trans %}Election list{% endtrans %}
{%- endblock %}

{% block head %}
  {{ super() -}}
  <style>
    small {
      font-size: smaller;
    }

    time {
      font-weight: bolder;
    }
  </style>
{%- endblock %}

{% block content %}
  <h3>{% trans %}Current elections{% endtrans %}</h3>
  <a class="btn btn-blue" href="{{ url("election:create") }}">
    <i class="fa fa-plus"></i>{% trans %}New election{% endtrans %}
  </a>
  {%- for election in object_list %}
    <hr>
    <section>
      <h4>
        <a href="{{ url('election:detail', election_id=election.id) }}">{{ election }}</a>
      </h4>
      <p>
        {% trans %}Applications open from{% endtrans %}
        <time datetime="{{ election.start_candidature }}">{{ election.start_candidature|localtime|date(DATETIME_FORMAT) }}</time>
        {% trans %} at {% endtrans %}<time>{{ election.start_candidature|localtime|time(DATETIME_FORMAT) }}</time>
        {% trans %}to{% endtrans %}
        <time datetime="{{ election.end_candidature }}">{{ election.end_candidature|localtime|date(DATETIME_FORMAT) }}</time>
        {% trans %} at {% endtrans %}<time>{{ election.end_candidature|localtime|time(DATETIME_FORMAT) }}</time>
      </p>
      <p>
        {% trans %}Polls open from{% endtrans %}
        <time datetime="{{ election.start_date }}">{{ election.start_date|localtime|date(DATETIME_FORMAT) }}</time>
        {% trans %} at {% endtrans %}<time>{{ election.start_date|localtime|time(DATETIME_FORMAT) }}</time>
        {% trans %}to{% endtrans %}
        <time datetime="{{ election.end_date }}">{{ election.end_date|localtime|date(DATETIME_FORMAT) }}</time>
        {% trans %} at {% endtrans %}<time>{{ election.end_date|localtime|time(DATETIME_FORMAT) }}</time>
      </p>
      <p>{{ election.description }}</p>
    </section>
  {%- endfor %}
  {% if is_paginated %}
    {{ paginate_jinja(request, page_obj, paginator) }}
  {% endif %}
{%- endblock %}

