From dc9799a7f2c5771b770a8d3d825fff6cf5e78d58 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 7 Oct 2024 10:58:00 -0500 Subject: Generalise pagination and paginate phenotypes Generalise the code generating table pagination UI, and use it to paginate the list of phenotypes. --- uploader/phenotypes/views.py | 2 ++ uploader/templates/macro-table-pagination.html | 26 +++++++++++++++++++++++++ uploader/templates/phenotypes/view-dataset.html | 6 +++--- 3 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 uploader/templates/macro-table-pagination.html (limited to 'uploader') diff --git a/uploader/phenotypes/views.py b/uploader/phenotypes/views.py index 63e0b84..47fbd51 100644 --- a/uploader/phenotypes/views.py +++ b/uploader/phenotypes/views.py @@ -170,6 +170,8 @@ def view_dataset(# pylint: disable=[unused-argument] offset=start_at, limit=count), start=start_at+1), + start_from=start_at, + count=count, activelink="view-dataset") diff --git a/uploader/templates/macro-table-pagination.html b/uploader/templates/macro-table-pagination.html new file mode 100644 index 0000000..292c531 --- /dev/null +++ b/uploader/templates/macro-table-pagination.html @@ -0,0 +1,26 @@ +{%macro table_pagination(start_at, page_count, total_count, base_uri, name)%} +{%set ns = namespace(forward_uri=base_uri, back_uri=base_uri)%} +{%set ns.forward_uri="brr"%} +
This dataset has a total of {{phenotype_count}} phenotypes.
-- - Display pagination controls here …
+ + {{table_pagination(start_from, count, phenotype_count, url_for('species.populations.phenotypes.view_dataset', species_id=species.SpeciesId, population_id=population.Id, dataset_id=dataset.Id), "phenotypes")}}