diff options
author | Frederick Muriuki Muriithi | 2024-10-07 15:54:33 -0500 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2024-10-07 16:01:18 -0500 |
commit | f461e4f29a8f32ec954cf858fb21de936f3b325b (patch) | |
tree | 89bbfdab37fce018f36e38b3ed930646d85051e2 /uploader/samples/views.py | |
parent | 4c0186d281ff77b28fa1abe1f84da0e8cb72dea1 (diff) | |
download | gn-uploader-f461e4f29a8f32ec954cf858fb21de936f3b325b.tar.gz |
linting: Fix minor linting issues.
Diffstat (limited to 'uploader/samples/views.py')
-rw-r--r-- | uploader/samples/views.py | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/uploader/samples/views.py b/uploader/samples/views.py index 9ba1df8..b8ec4d4 100644 --- a/uploader/samples/views.py +++ b/uploader/samples/views.py @@ -3,11 +3,8 @@ import os import sys import uuid from pathlib import Path -from typing import Iterator -import MySQLdb as mdb from redis import Redis -from MySQLdb.cursors import DictCursor from flask import (flash, request, url_for, @@ -20,11 +17,11 @@ from uploader.files import save_file from uploader.ui import make_template_renderer from uploader.authorisation import require_login from uploader.input_validation import is_integer_input -from uploader.datautils import order_by_family, enumerate_sequence -from uploader.db_utils import ( - with_db_connection, - database_connection, - with_redis_connection) +from uploader.datautils import safe_int, order_by_family, enumerate_sequence +from uploader.population.models import population_by_id, populations_by_species +from uploader.db_utils import (with_db_connection, + database_connection, + with_redis_connection) from uploader.species.models import (all_species, species_by_id, order_species_by_family) @@ -110,9 +107,7 @@ def list_samples(species_id: int, population_id: int): all_samples = enumerate_sequence(samples_by_species_and_population( conn, species_id, population_id)) total_samples = len(all_samples) - offset = int(request.args.get("from") or 0) - if offset < 0: - offset = 0 + offset = max(safe_int(request.args.get("from") or 0), 0) count = int(request.args.get("count") or 20) return render_template("samples/list-samples.html", species=species, |