From 84223d35a1e50148d64a7df9bc37cc2d87f3844e Mon Sep 17 00:00:00 2001 From: Vermaas <vermaas@astron.nl> Date: Tue, 9 Jan 2024 13:30:21 +0100 Subject: [PATCH] update pagination --- atdb/atdb/settings/base.py | 1 - atdb/requirements/base.txt | 6 ++-- .../templates/taskdatabase/index.html | 1 + .../templates/taskdatabase/pagination.html | 31 ++++++++++++++++--- 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/atdb/atdb/settings/base.py b/atdb/atdb/settings/base.py index ae95daa1..5511fbbd 100644 --- a/atdb/atdb/settings/base.py +++ b/atdb/atdb/settings/base.py @@ -33,7 +33,6 @@ INSTALLED_APPS = [ 'corsheaders', 'django_filters', 'django_extensions', - 'bootstrap_pagination', 'django_tables2', 'bootstrap3', 'fontawesome_free', diff --git a/atdb/requirements/base.txt b/atdb/requirements/base.txt index bf22f774..deebf059 100644 --- a/atdb/requirements/base.txt +++ b/atdb/requirements/base.txt @@ -1,8 +1,8 @@ astronauth==0.3.3 -Django==3.2 +Django==4.1.3 django-allauth==0.57.0 # note allauth only supports Django >= 3.2 -django-bootstrap-pagination==1.7.0 -django-bootstrap3==14.2.0 +django-bootstrap-pagination==1.7.1 +django-bootstrap3==23.6 django-cors-headers==3.6.0 django-extensions==3.1.0 django-filter==2.3.0 diff --git a/atdb/taskdatabase/templates/taskdatabase/index.html b/atdb/taskdatabase/templates/taskdatabase/index.html index 1f4b938b..968d5826 100644 --- a/atdb/taskdatabase/templates/taskdatabase/index.html +++ b/atdb/taskdatabase/templates/taskdatabase/index.html @@ -10,6 +10,7 @@ <div class="row"> <div class="col-sm-12 col-md-12 col-lg-12"> {% include 'taskdatabase/pagination.html' %} + {% if my_tasks %} <div class="panel panel-success"> diff --git a/atdb/taskdatabase/templates/taskdatabase/pagination.html b/atdb/taskdatabase/templates/taskdatabase/pagination.html index 56987349..b2c90efa 100644 --- a/atdb/taskdatabase/templates/taskdatabase/pagination.html +++ b/atdb/taskdatabase/templates/taskdatabase/pagination.html @@ -1,5 +1,28 @@ -{% load bootstrap_pagination %} +{% if my_tasks %} -<div> - {% bootstrap_paginate my_tasks range=20 show_prev_next="true" show_first_last="true" previous_label="Previous" first_label="First" next_label="Next" last_label="Last" %} -</div> \ No newline at end of file + {% if my_tasks.has_other_pages %} + <div class="btn-group" role="group" aria-label="Item pagination"> + {% if my_tasks.has_previous %} + <a href="?page={{ my_tasks.previous_page_number }}" class="btn btn-outline-primary">«</a> + {% endif %} + + {% for page_number in my_tasks.paginator.page_range %} + {% if my_tasks.number == page_number %} + <button class="btn btn-outline-primary active"> + <span>{{ page_number }} <span class="sr-only">(current)</span></span> + </button> + {% else %} + <a href="?page={{ page_number }}" class="btn btn-outline-primary"> + {{ page_number }} + </a> + {% endif %} + {% endfor %} + + {% if my_tasks.has_next %} + <a href="?page={{ my_tasks.next_page_number }}" class="btn btn-outline-primary">»</a> + {% endif %} + </div> + {% endif %} +{% else %} + <p>No items found.</p> +{% endif %} \ No newline at end of file -- GitLab