aboutsummaryrefslogtreecommitdiff
path: root/gn3/auth/authorisation/data
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-03-23 17:55:29 +0300
committerFrederick Muriuki Muriithi2023-03-23 17:59:50 +0300
commit6630f9fca98826872a62651c89f95eecb7c8a898 (patch)
treed7f1f33706ca27a2a1dd1d8e7b92a58760c3a719 /gn3/auth/authorisation/data
parent7cf0c43020736d1ec4fa2efddad7d2fcd8fb5840 (diff)
downloadgenenetwork3-6630f9fca98826872a62651c89f95eecb7c8a898.tar.gz
auth: list the species in the database.
Diffstat (limited to 'gn3/auth/authorisation/data')
-rw-r--r--gn3/auth/authorisation/data/views.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/gn3/auth/authorisation/data/views.py b/gn3/auth/authorisation/data/views.py
index 47c3fe8..b1550d7 100644
--- a/gn3/auth/authorisation/data/views.py
+++ b/gn3/auth/authorisation/data/views.py
@@ -9,6 +9,7 @@ from functools import reduce
from typing import Sequence, Iterable
import redis
+from MySQLdb.cursors import DictCursor
from email_validator import validate_email, EmailNotValidError
from authlib.integrations.flask_oauth2.errors import _HTTPException
from flask import request, jsonify, Response, Blueprint, current_app as app
@@ -40,6 +41,14 @@ from gn3.auth.authentication.users import User, user_by_email, set_user_password
data = Blueprint("data", __name__)
+@data.route("species")
+def list_species() -> Response:
+ """List all available species information."""
+ with (gn3db.database_connection() as gn3conn,
+ gn3conn.cursor(DictCursor) as cursor):
+ cursor.execute("SELECT * FROM Species")
+ return jsonify(tuple(dict(row) for row in cursor.fetchall()))
+
@data.route("/authorisation", methods=["GET"])
def authorisation() -> Response:
"""Retrive the authorisation level for datasets/traits for the user."""