Added pagination in PlaceList template.

This commit is contained in:
Marcus Scholz 2020-08-12 23:20:32 +02:00
parent 2f1f356eb0
commit f27fc71a01

View File

@ -7,43 +7,69 @@
<div class="LP-PlaceList"> <div class="LP-PlaceList">
<h1 class="LP-Headline">Listing our places</h1> <h1 class="LP-Headline">Listing our places</h1>
<ul class="LP-PlaceList__List"> <ul class="LP-PlaceList__List">
{% for place in place_list %} {% for place in place_list %}
<li class="LP-PlaceList__Item"> <li class="LP-PlaceList__Item">
<a href="{% url 'place_detail' pk=place.pk %}" class="LP-Link"> <a href="{% url 'place_detail' pk=place.pk %}" class="LP-Link">
<article class="LP-PlaceTeaser LP-PlaceTeaser--extended"> <article class="LP-PlaceTeaser LP-PlaceTeaser--extended">
<div class="LP-PlaceTeaser__Image"> <div class="LP-PlaceTeaser__Image">
<img class="LP-Image" src="{{ place.images.first.filename.thumbnail.url }}" /> <img class="LP-Image" src="{{ place.images.first.filename.thumbnail.url }}" />
</div> </div>
<div class="LP-PlaceTeaser__Meta"> <div class="LP-PlaceTeaser__Meta">
<div class="LP-PlaceTeaser__Info"> <div class="LP-PlaceTeaser__Info">
<span class="LP-PlaceTeaser__Title"> <span class="LP-PlaceTeaser__Title">
<h2 class="LP-Headline LP-Headline--teaser">{{place.name}}</h2> <h2 class="LP-Headline LP-Headline--teaser">{{place.name}}</h2>
</span> </span>
<span class="LP-PlaceTeaser__Detail"> <span class="LP-PlaceTeaser__Detail">
<p class="LP-Paragraph">{{place.location}}</p> <p class="LP-Paragraph">{{place.location}}</p>
</span> </span>
</div> </div>
<div class="LP-PlaceTeaser__Description"> <div class="LP-PlaceTeaser__Description">
<p class="LP-Paragraph"> <p class="LP-Paragraph">
{% if place.description|length > 210 %} {% if place.description|length > 210 %}
{{place.description|truncatechars:210|truncatewords:-1}} {{place.description|truncatechars:210|truncatewords:-1}}
{% else %} {% else %}
{{place.description}} {{place.description}}
{% endif %} {% endif %}
</p> </p>
</div> </div>
<div class="LP-PlaceTeaser__Icons"> <div class="LP-PlaceTeaser__Icons">
<ul class="LP-Icon__List"> <ul class="LP-Icon__List">
<li class="LP-Icon__Item"><img class="LP-Icon" src="{% static '/icons/favourite.svg' %}" /></li> <li class="LP-Icon__Item"><img class="LP-Icon" src="{% static '/icons/favourite.svg' %}" /></li>
<li class="LP-Icon__Item"><img class="LP-Icon" src="{% static '/icons/location.svg' %}" /></li> <li class="LP-Icon__Item"><img class="LP-Icon" src="{% static '/icons/location.svg' %}" /></li>
<li class="LP-Icon__Item"><img class="LP-Icon" src="{% static '/icons/flag.svg' %}" /></li> <li class="LP-Icon__Item"><img class="LP-Icon" src="{% static '/icons/flag.svg' %}" /></li>
</ul> </ul>
</div> </div>
</div> </div>
</article> </article>
</a> </a>
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>
<div class="LP-Pagination">
<ul class="LP-Pagination__List">
{% if page_obj.has_previous %}
<li class="LP-Pagination__Item LP-Pagination__Item--previous">
<a href="?page=1"><class="LP-Link"><span class="LP-Pagination__Previous">&lt; &lt; first</span></a>
</li>
<li class="LP-Pagination__Item LP-Pagination__Item--number">
<a href="?page={{ page_obj.previous_page_number }}"><class="LP-Link"><span class="LP-Pagination__Number">&lt; previous</span></a>
</li>
{% endif %}
{% for page_obj in page_obj.paginator %}
<li class="LP-Pagination__Item LP-Pagination__Item--number">
<a href="?page={{page_obj.number}}"><class="LP-Link"><span class="LP-Pagination__Number">{{page_obj.number}}</span></a>
</li>
{% endfor %}
{% if page_obj.has_next %}
<li class="LP-Pagination__Item LP-Pagination__Item--next">
<a href="?page={{ page_obj.next_page_number }}"><class="LP-Link"><span class="LP-Pagination__Next">&gt; next</span></a>
</li>
<li class="LP-Pagination__Item LP-Pagination__Item--next">
<a href="?page={{ page_obj.paginator.num_pages }}"><class="LP-Link"><span class="LP-Pagination__Next">&gt; &gt; last</span></a>
</li>
{% endif %}
</ul>
</div>
</div> </div>
{% endblock maincontent %} {% endblock maincontent %}