Commit 26b2ea85 authored by Jerome Mariette's avatar Jerome Mariette
Browse files

add user handling from ergatis

parent 7111b8d3
......@@ -73,42 +73,32 @@ class t3MySQLdb(object):
except:
crdate = time.mktime(datetime.date.today().timetuple())
if fe_group: # If the front end group is specified
req = "SELECT uid FROM fe_groups WHERE title = '" + str(fe_group) + "'"
if admin_login: # If the administrator login is specified
req = "SELECT uid FROM fe_users WHERE username = '" + str(admin_login) + "'"
curs.execute(req)
try:
fe_group_id = curs.fetchall()[0][0]
admin_id = curs.fetchall()[0][0]
except:
req = "INSERT INTO fe_groups (pid, tstamp, title, description) VALUES ('" + str(self.cfg_reader.get_pid()) + "','" + str(crdate) + "','" + str(fe_group) + "','" + fe_group_description.replace("'", "\'") + "')"
curs.execute(req)
fe_group_id = conn.insert_id()
raise Exception('t3MySQLdb', 'The administration login ' + admin_login + ' does not exist.')
req = "SELECT subgroup FROM fe_groups WHERE title='" + str(fe_group_parent) + "'"
req = "SELECT right_level_id FROM fe_rights_levels WHERE right_level_label = 'administrator'"
curs.execute(req)
try:
gps_str = curs.fetchall()[0][0]
if gps_str == '':
parent_subgroups = str(fe_group_id)
else :
gps = str(gps_str).split(",")
if fe_group_id not in gps:
gps.append(fe_group_id)
parent_subgroups = ""
for gp in gps:
parent_subgroups += str(gp) + ","
parent_subgroups = parent_subgroups[:-1]
req = "UPDATE fe_groups SET subgroup='" + str(parent_subgroups) + "' WHERE title='" + str(fe_group_parent) + "'"
curs.execute(req)
right_level_id = curs.fetchall()[0][0]
except:
pass
req = "INSERT INTO tx_nG6_project (pid, tstamp, crdate, fe_group, description, name, hidden) VALUES ('" + str(self.cfg_reader.get_pid()) + "','" + str(crdate) + "','" + str(crdate) + "','" + str(fe_group_id) + "','" + pdescription.replace("'", "\'") + "','" + name.replace("'", "\'") + "','" + str(hidden) + "')"
raise Exception('t3MySQLdb', 'The administration value does not exist in the fe_rights_levels table.')
req = "INSERT INTO tx_nG6_project (pid, tstamp, crdate, description, name, hidden) VALUES ('" + str(self.cfg_reader.get_pid()) + "','" + str(crdate) + "','" + str(crdate) + "','" + pdescription.replace("'", "\'") + "','" + name.replace("'", "\'") + "','" + str(hidden) + "')"
curs.execute(req)
project_id = conn.insert_id()
else :
req = "INSERT INTO tx_nG6_project (pid, tstamp, crdate, fe_group, description, name, hidden) VALUES ('" + str(self.cfg_reader.get_pid()) + "','" + str(crdate) + "','" + str(crdate) + "',0,'" + pdescription.replace("'", "\'") + "','" + name.replace("'", "\'") + "','" + str(hidden) + "')"
req = "INSERT INTO fe_rights (fe_user_id, project_id, right_id) VALUES ('" + str(admin_id) + "','" + str(project_id) + "','" + str(right_level_id) + "')"
curs.execute(req)
project_id = conn.insert_id()
else :
raise Exception('t3MySQLdb', 'The administration login is required.')
curs.close()
conn.close()
return project_id
......
Supports Markdown
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