about summary refs log tree commit diff
path: root/uploader/phenotypes/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'uploader/phenotypes/views.py')
-rw-r--r--uploader/phenotypes/views.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/uploader/phenotypes/views.py b/uploader/phenotypes/views.py
index 7ad32ad..88cb89c 100644
--- a/uploader/phenotypes/views.py
+++ b/uploader/phenotypes/views.py
@@ -14,7 +14,7 @@ from uploader.request_checks import with_species, with_population
 from uploader.population.models import (populations_by_species,
                                         population_by_species_and_id)
 
-from .models import datasets_by_population
+from .models import datasets_by_population, phenotypes_data
 
 phenotypesbp = Blueprint("phenotypes", __name__)
 
@@ -83,3 +83,18 @@ def list_datasets(species: int, population: int, **kwargs):
                                    species["SpeciesId"],
                                    population["Id"]),
                                activelink="list-datasets")
+
+
+@phenotypesbp.route(
+    "<int:species_id>/populations/<int:population_id>/phenotypes/datasets"
+    "/<int:dataset_id>/view",
+    methods=["GET"])
+@require_login
+@with_population(species_redirect_uri="species.populations.phenotypes.index",
+                 redirect_uri="species.populations.phenotypes.select_population")
+def view_dataset(species: int, population: int, dataset_id: int, **kwargs):
+    """View a specific dataset"""
+    with database_connection(app.config["SQL_URI"]) as conn:
+        from flask import jsonify
+        return jsonify(phenotypes_data(
+            conn, population["Id"], dataset_id, offset=0, limit=20))