Fixed pagiatation
This commit is contained in:
parent
9f29ea603f
commit
4ea8d16253
@ -512,12 +512,12 @@ body {
|
|||||||
height: 60px;
|
height: 60px;
|
||||||
box-shadow: 0 0 2px #C09F80;
|
box-shadow: 0 0 2px #C09F80;
|
||||||
grid-area: header;
|
grid-area: header;
|
||||||
background-color: white; }
|
background-color: white;
|
||||||
|
padding-left: 25px; }
|
||||||
.LP-Header__Navigation {
|
.LP-Header__Navigation {
|
||||||
flex-grow: 2; }
|
flex-grow: 2; }
|
||||||
.LP-Header__Logo {
|
.LP-Header__Logo {
|
||||||
height: 45px;
|
height: 45px;
|
||||||
margin: 25px;
|
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
max-height: 100%;
|
max-height: 100%;
|
||||||
width: 225px;
|
width: 225px;
|
||||||
@ -550,8 +550,8 @@ body {
|
|||||||
|
|
||||||
@media (max-width: 650px) {
|
@media (max-width: 650px) {
|
||||||
.LP-Header {
|
.LP-Header {
|
||||||
padding-left: 40px;
|
padding-left: 60px;
|
||||||
width: calc(100% - 40px);
|
width: calc(100% - 60px);
|
||||||
position: fixed;
|
position: fixed;
|
||||||
z-index: 10; } }
|
z-index: 10; } }
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
{% load lostplaces %}
|
||||||
|
|
||||||
{% if is_paginated %}
|
{% if is_paginated %}
|
||||||
<div class="LP-Pagination">
|
<div class="LP-Pagination">
|
||||||
<ul class="LP-Pagination__List">
|
<ul class="LP-Pagination__List">
|
||||||
@ -16,15 +18,17 @@
|
|||||||
<span class="LP-Pagination__Previous">previous</span>
|
<span class="LP-Pagination__Previous">previous</span>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% for i in page_obj.paginator %}
|
|
||||||
{% if i.number == page_obj.number %}
|
{% for i in page_obj.paginator|proper_paginate:page_obj.number %}
|
||||||
|
{% if i == page_obj.number %}
|
||||||
<li class="LP-Pagination__Item LP-Pagination__Item--number LP-Pagination__Item--current">
|
<li class="LP-Pagination__Item LP-Pagination__Item--number LP-Pagination__Item--current">
|
||||||
{% else %}
|
{% else %}
|
||||||
<li class="LP-Pagination__Item LP-Pagination__Item--number">
|
<li class="LP-Pagination__Item LP-Pagination__Item--number">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<a href="?page={{i.number}}" class="LP-Link"><span class="LP-Pagination__Number">{{i.number}}</span></a>
|
<a href="?page={{i}}" class="LP-Link"><span class="LP-Pagination__Number">{{i}}</span></a>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% if page_obj.has_next %}
|
{% if page_obj.has_next %}
|
||||||
<li class="LP-Pagination__Item LP-Pagination__Item--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">next</span></a>
|
<a href="?page={{ page_obj.next_page_number }}" class="LP-Link"><span class="LP-Pagination__Next">next</span></a>
|
||||||
|
0
lostplaces/lostplaces_app/templatetags/__init__.py
Normal file
0
lostplaces/lostplaces_app/templatetags/__init__.py
Normal file
22
lostplaces/lostplaces_app/templatetags/lostplaces.py
Normal file
22
lostplaces/lostplaces_app/templatetags/lostplaces.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
from django import template
|
||||||
|
|
||||||
|
register = template.Library()
|
||||||
|
|
||||||
|
@register.filter(name='proper_paginate')
|
||||||
|
def proper_paginate(paginator, current_page, neighbors=2):
|
||||||
|
if paginator.num_pages > 2*neighbors:
|
||||||
|
start_index = max(1, current_page-neighbors)
|
||||||
|
end_index = min(paginator.num_pages, current_page + neighbors)
|
||||||
|
if end_index < start_index + 2*neighbors:
|
||||||
|
end_index = start_index + 2*neighbors
|
||||||
|
elif start_index > end_index - 2*neighbors:
|
||||||
|
start_index = end_index - 2*neighbors
|
||||||
|
if start_index < 1:
|
||||||
|
end_index -= start_index
|
||||||
|
start_index = 1
|
||||||
|
elif end_index > paginator.num_pages:
|
||||||
|
start_index -= (end_index-paginator.num_pages)
|
||||||
|
end_index = paginator.num_pages
|
||||||
|
page_list = [f for f in range(start_index, end_index+1)]
|
||||||
|
return page_list[:(2*neighbors + 1)]
|
||||||
|
return paginator.page_range
|
@ -50,7 +50,7 @@ class SignUpView(SuccessMessageMixin, CreateView):
|
|||||||
success_message = 'User created.'
|
success_message = 'User created.'
|
||||||
|
|
||||||
class PlaceListView(IsAuthenticated, ListView):
|
class PlaceListView(IsAuthenticated, ListView):
|
||||||
paginate_by = 5
|
paginate_by = 2
|
||||||
model = Place
|
model = Place
|
||||||
template_name = 'place/place_list.html'
|
template_name = 'place/place_list.html'
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user