{% extends "places/base.html" %}
{% load i18n %}
{% load molly_utils %}

{% block pagetitle %}{{ entity_types.0.verbose_name_plural|capfirst }}{% endblock %}
{% block title %}{{ entity_types.0.verbose_name_plural|capfirst }}{% endblock %}

{% block content %}

<div class="section">
  <div class="header">
    {# Defines an H2 title which defines which category this page is showing #}
    <h2>
      {% blocktrans with entity_types.0.verbose_name as name and entity_types.0.verbose_name_plural as name_plural count count as count %}Found {{ count }} {{ name }}{% plural %}Found {{ count }} {{ name_plural }}{% endblocktrans %}
  
      {# Also show other categories if this is an 'and' search #}
      {% ifnotequal entity_types|length 1 %}
          {% blocktrans count count as count %}that is also{% plural %}that are also{% endblocktrans %}
          {% for et in entity_types|slice:"1:" %}
              {% if not forloop.first %}, 
                  {% if forloop.last %}{% trans "and" %} {% endif %}
              {% endif %}
              {{ et.verbose_name_singular }}
          {% endfor %}
      {% endifnotequal %}
    </h2>
  </div>

    {% if not found_entity_types|length_is:0 and not found_entity_types|length_is:1 %}
        <div class="note"><div class="bubble pad-10">
            {% trans "Limit to:" %}
            {% for et in found_entity_types %}
                {% if entity %}
                <a href="{% url places:entity-category-list entity.identifier_scheme entity.identifier_value %}{{ et.slug }}{% for oet in entity_types %}{% if not et.subtype_of.all|contains:oet %};{{ oet.slug }}{% endif %}{% endfor %}/">
                    {{ et.verbose_name_plural }}</a>
                {% else %}
                <a href="{% url places:category-list %}{{ et.slug }}{% for oet in entity_types %}{% if not et.subtype_of_completion.all|contains:oet %};{{ oet.slug }}{% endif %}{% endfor %}/">
                    {{ et.verbose_name_plural }}</a>
                {% endif %}
                {% if not forloop.last %} | {% endif %} 
            {% endfor %}
        </div></div>
    {% endif %}

    <ul class="link-list" id="category-list">
        {% for entity in entities.object_list %}{% if entity.title %}
            <li><a href="{{ entity.get_absolute_url }}">
              {{ entity.title|capfirst }}
            </a></li>
        {% endif %}{% endfor %}
    </ul>

    {% ifnotequal entities.paginator.num_pages 1 %}
        <div class="section-content">
           <div class="note"><div class="bubble pad-10">
            {% blocktrans with entities.number as page and entities.paginator.num_pages as pages %}Page <span class="current-page">{{ page }}</span> of {{ pages }}{% endblocktrans %}
             
           </div></div>
        </div>
        <ul class="link-list">
          {% if entities.has_previous %}
            <li><a class="go-back" href="?page={{ entities.previous_page_number }}">{% trans "Previous page" %}</a></li>
          {% endif %}
          {% if entities.has_next %}
            <li class="next"><a href="?page={{ entities.next_page_number }}">{% trans "Next page" %}</a></li>
          {% endif %}
        </ul>
    {% endifnotequal %}

</div>

{% endblock %}
