Add a paginator to all list views.

This commit is contained in:
Christopher Charbonneau Wells 2017-09-10 17:02:57 -04:00
parent aba6fdff15
commit 10ff754e67
9 changed files with 53 additions and 2 deletions

View File

@ -0,0 +1,30 @@
{% if is_paginated %}
<nav aria-label="Page navigation">
<ul class="pagination justify-content-center">
{% if page_obj.has_previous %}
<li class="page-item">
<a class="page-link" href="?page={{ page_obj.previous_page_number }}" aria-label="Previous">
<i class="fa fa-chevron-left" aria-hidden="true"></i>
<span class="sr-only">Previous</span>
</a>
</li>
{% endif %}
{% for num in page_obj.paginator.page_range %}
<li class="page-item{% if num == page_obj.number %} active{% endif %}">
<a class="page-link" href="?page={{ num }}">{{ num }}</a>
</li>
{% endfor %}
{% if page_obj.has_next %}
<li class="page-item">
<a class="page-link" href="?page={{ page_obj.next_page_number }}" aria-label="Next">
<i class="fa fa-chevron-right" aria-hidden="true"></i>
<span class="sr-only">Next</span>
</a>
</li>
{% endif %}
</ul>
</nav>
{% endif %}

View File

@ -52,6 +52,8 @@
{% endfor %}
</tbody>
</table>
{% include 'babyblotter/paginator.html' %}
</div>
{% if perms.core.add_child %}

View File

@ -11,8 +11,8 @@
<thead class="thead-inverse">
<tr>
<th>Child</th>
<th>Wet</th>
<th>Solid</th>
<th class="text-center">Wet</th>
<th class="text-center">Solid</th>
<th>Color</th>
<th>Time</th>
<th class="text-center">Actions</th>
@ -51,6 +51,8 @@
{% endfor %}
</tbody>
</table>
{% include 'babyblotter/paginator.html' %}
</div>
{% if perms.core.add_diaperchange %}

View File

@ -57,6 +57,8 @@
{% endfor %}
</tbody>
</table>
{% include 'babyblotter/paginator.html' %}
</div>
{% if perms.core.add_feeding %}

View File

@ -46,6 +46,8 @@
{% endfor %}
</tbody>
</table>
{% include 'babyblotter/paginator.html' %}
</div>
{% if perms.core.add_note %}

View File

@ -49,6 +49,8 @@
{% endfor %}
</tbody>
</table>
{% include 'babyblotter/paginator.html' %}
</div>
{% if perms.core.add_sleep %}

View File

@ -36,5 +36,7 @@
{% endfor %}
</tbody>
</table>
{% include 'babyblotter/paginator.html' %}
</div>
{% endblock %}

View File

@ -51,6 +51,8 @@
{% endfor %}
</tbody>
</table>
{% include 'babyblotter/paginator.html' %}
</div>
{% if perms.core.add_tummytime %}

View File

@ -16,6 +16,7 @@ from .forms import (ChildForm, DiaperChangeForm, FeedingForm, SleepForm,
class ChildList(PermissionRequiredMixin, ListView):
model = Child
permission_required = ('core.view_child',)
paginate_by = 10
class ChildAdd(PermissionRequiredMixin, CreateView):
@ -41,6 +42,7 @@ class ChildDelete(PermissionRequiredMixin, DeleteView):
class DiaperChangeList(PermissionRequiredMixin, ListView):
model = DiaperChange
permission_required = ('core.view_diaperchange',)
paginate_by = 10
class DiaperChangeAdd(PermissionRequiredMixin, CreateView):
@ -66,6 +68,7 @@ class DiaperChangeDelete(PermissionRequiredMixin, DeleteView):
class FeedingList(PermissionRequiredMixin, ListView):
model = Feeding
permission_required = ('core.view_feeding',)
paginate_by = 10
class FeedingAdd(PermissionRequiredMixin, CreateView):
@ -97,6 +100,7 @@ class FeedingDelete(PermissionRequiredMixin, DeleteView):
class NoteList(PermissionRequiredMixin, ListView):
model = Note
permission_required = ('core.view_note',)
paginate_by = 10
class NoteAdd(PermissionRequiredMixin, CreateView):
@ -122,6 +126,7 @@ class NoteDelete(PermissionRequiredMixin, DeleteView):
class SleepList(PermissionRequiredMixin, ListView):
model = Sleep
permission_required = ('core.view_sleep',)
paginate_by = 10
class SleepAdd(PermissionRequiredMixin, CreateView):
@ -153,6 +158,7 @@ class SleepDelete(PermissionRequiredMixin, DeleteView):
class TimerList(PermissionRequiredMixin, ListView):
model = Timer
permission_required = ('core.view_timer',)
paginate_by = 10
class TimerDetail(PermissionRequiredMixin, DetailView):
@ -232,6 +238,7 @@ class TimerDelete(PermissionRequiredMixin, DeleteView):
class TummyTimeList(PermissionRequiredMixin, ListView):
model = TummyTime
permission_required = ('core.view_tummytime',)
paginate_by = 10
class TummyTimeAdd(PermissionRequiredMixin, CreateView):