aboutsummaryrefslogtreecommitdiff
path: root/uploader/genotypes
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2026-09-17 15:01:03 -0500
committerFrederick Muriuki Muriithi2026-09-17 15:04:52 -0500
commit186649ef562c6a77d32201a393cdeecea8b5b529 (patch)
treecaa8d35ccece5cbee44e00e4c67eca739b5a0d8b /uploader/genotypes
parent3cc13543fb10790d96af61f28477f3403fbab284 (diff)
downloadgn-uploader-186649ef562c6a77d32201a393cdeecea8b5b529.tar.gz
Use 'Accept' header in ajax requests for content negotiation.
The endpoint can return either HTML or JSON depending on the 'Accept' header.
Diffstat (limited to 'uploader/genotypes')
-rw-r--r--uploader/genotypes/views.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/uploader/genotypes/views.py b/uploader/genotypes/views.py
index 648b38e..e475986 100644
--- a/uploader/genotypes/views.py
+++ b/uploader/genotypes/views.py
@@ -227,8 +227,17 @@ def create_dataset(species: dict, population: dict, **kwargs):# pylint: disable=
dataset_by_id=genotype_dataset)
def add_genotype_records(species: dict, population: dict, dataset: dict, **kwargs):
"""Add new Genotype records to the dataset."""
- return render_template("genotypes/add-genotypes-records-csv.html",
- species=species,
- population=population,
- dataset=dataset,
- activelink="add-genotypes-records")
+ if request.method == "GET":
+ return render_template("genotypes/add-genotypes-records-csv.html",
+ species=species,
+ population=population,
+ dataset=dataset,
+ activelink="add-genotypes-records")
+
+ if "application/json" in request.headers.get("Accept"):
+ return make_response(
+ jsonify({
+ "message": ("Upload successful. Follow the 'redirect-to' URI "
+ "to continue")
+ }),
+ 200)