{% extends "webpage/base.html" %}
{% block Titel %} See all Places {% endblock %}
{% block content %}

<div class="card card-default">
	<div class="card-heading">
		<h1>All Places</h1>
		<!--<div>
			<a class="btn btn-primary btn-lg" href="{% url 'apis:apis_entities:place_create' %}">create new Place</a>
		</div>-->
	</div>
	<div class="card-body">
	<form method='get' action="{% url 'apis:apis_entities:place_list' %}?page=1">
		{% load crispy_forms_tags %}
		{% crispy SearchForm SearchForm.helper %}
	</form>
		{% if object_list %}
        <h4> {{ page_obj.paginator.count }} Hit(s)</h4>
		<table class="table table-striped">
			<thead>
				<th>Name</th><th>Status</th>
				<!-- <th>lives/lived</th>
				<th>places</th> -->
			</thead>
			<tbody>
			{% for object in object_list %}
				<tr>
					<td><a href="{% url 'apis:apis_entities:place_edit' pk=object.id %}">{{ object }}</a></td><td>{{ object.status }}</td>
					<!-- <td>{{ object.start_date_written }} {% if object.end_date_written %} - {{ object.end_date_written }} {% endif %}</td>
					<td>{{ object.isoCode }}</a></td> -->
				</tr>
			{% endfor %}
			</tbody>
		</table>
		{% endif %}
		{% if is_paginated %}
        <div class="pagination">
            <span class="page-links">
                {% if page_obj.has_previous %}
                	{% if search %}
                    	<a href="{% url 'apis:apis_entities:place_list' %}?page={{ page_obj.previous_page_number }}&search={{ search }}">previous</a>
                	{% else %}
                		<a href="{% url 'apis:apis_entities:place_list' %}?page={{ page_obj.previous_page_number }}">previous</a>
                	{% endif %}
                {% endif %}
                <span class="page-current">
                    Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}.
                </span>
                {% if page_obj.has_next %}
                	{% if search %}
                    	<a href="{% url 'apis:apis_entities:place_list' %}?page={{ page_obj.next_page_number }}&search={{ search }}">next</a>
                    {% else %}
                    	<a href="{% url 'apis:apis_entities:place_list' %}?page={{ page_obj.next_page_number }}">next</a>
                    {% endif %}
                {% endif %}
            </span>
        </div>
    {% endif %}
	</div>
</div>
{% endblock %}
