Commit e242536c authored by Penom Nom's avatar Penom Nom
Browse files

uniqproject as a type

parent 876086e8
......@@ -164,7 +164,25 @@ class t3MySQLdb(object):
conn.close()
if exists: raise ValueError("Impossible to create project {0}, this name is already used!".format(name))
return project_id
def project_exists(self,name):
"""
Return true if the project associated with name exists
"""
exists = False
conn = connect(self.host, self.user, self.passwd, self.db)
curs = conn.cursor()
req = "SELECT uid FROM tx_nG6_project WHERE name = '" + str(name) + "'"
curs.execute(req)
try:
project_id = curs.fetchall()[0][0]
exists = True
except :
pass
curs.close()
conn.close()
return exists
def select_project(self, project_id):
"""
Return the run infos
......
......@@ -42,8 +42,10 @@ admin_login.required = True
project_name.name = Project name
project_name.flag = --name
project_name.help = Give a name to your project (has to be unique)
project_name.type = uniqproject
project_name.required = True
project_description.name = Project description
project_description.flag = --description
project_description.help = Give a description to your project
......
......@@ -51,3 +51,14 @@ def adminlogin(login):
return login
except:
raise argparse.ArgumentTypeError("Login '" + login + "' does not exists! Please provide a valid login!")
def uniqproject(name):
t3mysql = t3MySQLdb()
if t3mysql.project_exists(name) :
raise argparse.ArgumentTypeError("The project name '" + name + "' exists already")
return name
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment