From 6630f9fca98826872a62651c89f95eecb7c8a898 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Thu, 23 Mar 2023 17:55:29 +0300 Subject: auth: list the species in the database. --- gn3/auth/authorisation/data/views.py | 9 +++++++++ 1 file changed, 9 insertions(+) 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.""" -- cgit v1.2.3