<div class="list-group-item list-group-item-action">
  <a class="main-link" href="{% url 'management:election' pk=election.pk %}"></a>
  <span><b>{{ election.title }}</b></span>
  <button type="button" class="close btn btn-danger btn-lg float-right" data-toggle="modal"
          data-target="#deleteModel{{ election.pk }}"
          aria-label="remove election from session">
    <span aria-hidden="true">&times;</span>
  </button>

  <small class="float-right">
    {% if not election.started and election.start_date %}
      <span class="right-margin">Starts at {{ election.start_date|date:"Y-m-d H:i:s" }}</span>
      {# Time for automatic reload #}
      <div class="d-none time">{{ election.start_date|date:"U" }}|</div>
    {% elif not election.started %}
      <span class="right-margin">Needs to be started manually</span>
    {% elif election.is_open and election.end_date %}
      <span class="right-margin">Open until {{ election.end_date|date:"Y-m-d H:i:s" }}</span>
      {# Time for automatic reload #}
      <div class="d-none time">{{ election.end_date|date:"U" }}|</div>
    {% elif election.closed %}
      <span class="right-margin">Closed</span>
    {% else %}
      <span class="right-margin">Open, needs to be closed manually</span>
    {% endif %}
  </small>
</div>

<div class="modal fade" id="deleteModel{{ election.pk }}" role="dialog">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <h4 class="modal-title">Delete Election</h4>
          <button type="button" class="close" data-dismiss="modal">&times;</button>
        </div>
        <div class="modal-body">
          <p>Are you sure you want to delete {{ election.title }}?</p>
        </div>
        <div class="modal-footer">
          <form action="{% url 'management:delete_election' pk=election.pk %}" method="post">
            {% csrf_token %}
            <button type="submit" class="btn btn-danger">Delete</button>
          </form>
          <button type="button" class="btn btn-light" data-dismiss="modal">Close</button>
        </div>
      </div>
    </div>
  </div>
