From 7ab16e0fcbc2efe2f446adc52a9df3a900d8561d Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 8 Apr 2024 09:12:08 +0300 Subject: bug: Check that Genotype dataset name is not duplicated. --- qc_app/upload/rqtl2.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/qc_app/upload/rqtl2.py b/qc_app/upload/rqtl2.py index 60aeba7..860a6a9 100644 --- a/qc_app/upload/rqtl2.py +++ b/qc_app/upload/rqtl2.py @@ -13,6 +13,7 @@ from redis import Redis from MySQLdb.cursors import DictCursor from flask import ( flash, + escape, request, url_for, redirect, @@ -453,6 +454,19 @@ def create_geno_dataset(species_id: int, population_id: int): "pub": public, "isetid": population_id } + cursor.execute("SELECT * FROM GenoFreeze WHERE Name=%s", + (datasetname,)) + results = cursor.fetchall() + if bool(results): + flash( + f"A genotype dataset with name '{escape(datasetname)}' " + "already exists.", + errorclasses) + return redirect(url_for("upload.rqtl2.select_dataset_info", + species_id=species_id, + population_id=population_id, + pgsrc="error"), + code=307) cursor.execute( "INSERT INTO GenoFreeze(" "Name, FullName, ShortName, CreateTime, public, InbredSetId" -- cgit v1.2.3