about summary refs log tree commit diff
path: root/uploader/genotypes
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2026-09-10 17:39:51 -0500
committerFrederick Muriuki Muriithi2026-09-10 17:43:08 -0500
commit2c61890e62a1db764755cd049242adadbb9d7be4 (patch)
tree4b692b06bb4bff84c085ed9d25a5b2750e29041e /uploader/genotypes
parenta72c8bf3132a80c4c93de85ec8d94c0812ee1573 (diff)
downloadgn-uploader-2c61890e62a1db764755cd049242adadbb9d7be4.tar.gz
Enable use of DataTables for UI.
Diffstat (limited to 'uploader/genotypes')
-rw-r--r--uploader/genotypes/views.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/uploader/genotypes/views.py b/uploader/genotypes/views.py
index 2a0e0f8..8c0795d 100644
--- a/uploader/genotypes/views.py
+++ b/uploader/genotypes/views.py
@@ -3,6 +3,7 @@ import logging
 
 from MySQLdb.cursors import DictCursor
 from pymonad.either import Left, Right, Either
+from gn_libs.requests import request_json
 from gn_libs.mysqldb import database_connection
 from werkzeug.exceptions import UnsupportedMediaType
 from flask import (flash,
@@ -37,15 +38,16 @@ render_template = make_template_renderer("genotypes")
 
 @genotypesbp.route(
     "/<int:species_id>/populations/<int:population_id>/genotypes",
-    methods=["GET"])
+    methods=["GET", "POST"])
 @require_login
 @with_population(species_redirect_uri="species.list_species",
                  redirect_uri="species.populations.list_species_populations")
 def index(species: dict, population: dict, **kwargs):# pylint: disable=[unused-argument]
     """Entry-point to the genotypes management section."""
     with database_connection(app.config["SQL_URI"]) as conn:
-        offset = int(request.args.get("start", "0"))
-        number_of_records = int(request.args.get("count", "10"))
+        form = request_json()
+        offset = int(form.get("start", "0"))
+        number_of_records = int(form.get("length", "10"))
         _markers, _total_markers, = genotype_markers(
             conn, species["SpeciesId"], population["Id"])
         _genotype_records, _count = genotype_records(
@@ -68,7 +70,8 @@ def index(species: dict, population: dict, **kwargs):# pylint: disable=[unused-a
                     "genotype_records": _genotype_records,
                     "total_genotype_records": _count,
                     "fetched_genotype_records": len(_genotype_records),
-                    "sample_order": _samples
+                    "samples_order": _samples,
+                    "draw": int(request.args.get("draw", "0"))
                 }), 200)
 
         if "text/html" in request.headers["Accept"]: