def edit_query(): print 'edit_query called ' print 'request.form in all is ' + str(request.form) print 'request.form.get in sqlid is ' + str(request.form.get('sqlid',None)) form = DsQueryForm(csrf_enabled=False) dsquery = DsQuery.get_or_404(form.data['sqlid']) if dsquery: dsquery = dsquery.update(**form.data) if request.form.get('users', None) is not None: __add_dsquery_admin(form.data['sqlid'], request.form['users']) query = DsQuery.query.filter(DsQuery.sqlid == DsQueryAdmin.sqlid).filter(DsQueryAdmin.adminid==g.user.id) data = query_to_list_json(query) return json.dumps(data)
def add_dsquery(): print 'add_dsquery called ' print 'request.form in all is ' + str(request.form) # print 'request.form.get in sqlid is ' + str(request.form.get('sqlid',None)) form = DsQueryForm(csrf_enabled=False) if request.method == 'POST' and form.validate(): print 'form.data[sqlid] is ' + str(form.data) instance = DsQuery.create(**form.data) if request.form['users']: __add_dsquery_admin(instance.sqlid, request.form['users']) print form.errors query = DsQuery.query.filter(DsQuery.sqlid == DsQueryAdmin.sqlid).filter(DsQueryAdmin.adminid==g.user.id) data = query_to_list_json(query) return json.dumps(data)