def group_myprojects(): if 'group' in session['user']: connect = MySQLdb.connect(db=config.DB_NAME, host=config.DB_HOST, port=config.DB_PORT, user=config.DB_USER, passwd=config.DB_PASSWD) result = ProjectService.loadMyProjectList(connect, user=session['user'], group_id=session['user']['group']['id']) connect.close() return json.dumps(result) else: return '[]'
def pload(): if 'user' in session: connect = MySQLdb.connect(db=config.DB_NAME, host=config.DB_HOST, port=config.DB_PORT, user=config.DB_USER, passwd=config.DB_PASSWD) result = ProjectService.loadProject(session['user'], request.form['pid']) connect.close() for joinInfo in session['user']['joinInfos']: if joinInfo['id'] == result['group_id']: result['group'] = joinInfo return json.dumps(result) return 'false'
def editor(pid): if 'user' in session: connect = MySQLdb.connect(db=config.DB_NAME, host=config.DB_HOST, port=config.DB_PORT, user=config.DB_USER, passwd=config.DB_PASSWD) result = ProjectService.loadProject(connect, session['user'], pid) connect.close() if not result == None: return render_template('editorjs.html', userinfo=json.dumps(session['user']), project=json.dumps(result)) else: return redirect(url_for('login_view')) return render_template('request_deny.html')
def createp(): if 'user' in session: sample = False if 'sample' in request.form: sample = True connect = MySQLdb.connect(db=config.DB_NAME, host=config.DB_HOST, port=config.DB_PORT, user=config.DB_USER, passwd=config.DB_PASSWD) if 'group' in session['user']: project = ProjectService.createProject(connect, session['user'], request.form['name'], request.form['xml'], request.form['metamodel_id'], group_id=session['user']['group']['id'], _is_sample=sample) connect.close() return json.dumps(project) else: project = ProjectService.createProject(connect, session['user'], request.form['name'], request.form['xml'], request.form['metamodel_id'],_is_sample=sample) connect.close() return json.dumps(project) return 'false'
def project_list(): if 'user' in session: connect = MySQLdb.connect(db=config.DB_NAME, host=config.DB_HOST, port=config.DB_PORT, user=config.DB_USER, passwd=config.DB_PASSWD) myprojects = ProjectService.loadMyOwnProjectList(session['user'], connect) mytools = MetaModelService.loadMyAllMetaModelList(session['user'], connect) connect.close() for p in myprojects: for t in mytools: if p['meta_id'] == t['id']: p['tool_id'] = t['id'] p['tool_name'] = t['name'] return json.dumps(myprojects) return 'false'
def editorjs(pid): if 'user' in session: connect = MySQLdb.connect(db=config.DB_NAME, host=config.DB_HOST, port=config.DB_PORT, user=config.DB_USER, passwd=config.DB_PASSWD) result = ProjectService.loadProject(session['user'], pid, connect) if not result == None: gid = int(result['group_id']) cur = connect.cursor() cur.execute('SELECT GroupInfo.id AS id1,role,name,service FROM GroupInfo INNER JOIN JoinInfo ON GroupInfo.id = JoinInfo.group_id AND JoinInfo.user_id=%s AND group_id=%s;',(session['user']['id'], gid)) rows = cur.fetchall() cur.close() connect.close() if not len(rows) == 0: joinInfo = {} joinInfo['id'] = int(rows[0][0]) joinInfo['role'] = int(rows[0][1]) joinInfo['name'] = rows[0][2] joinInfo['service'] = rows[0][3] result['group'] = joinInfo return render_template('editorjs.html', pid = pid, project = json.dumps(result)) else: return redirect(url_for('login_view')) return render_template('request_deny.html')
def psave(): return json.dumps(ProjectService.saveProject(session['user'], request.form['pid'], request.form['xml']))
def deletep(): if 'user' in session: result = ProjectService.deleteProject(session['user'], request.form['pid']) return json.dumps(result) else: return 'false'