def getuser(id): res = call_stored_procedure("get_user", [int(id)]) if not res: return jsonify({ 'status': 'Error', 'message': 'Results Not Found' }), 404 rec = res[0] print rec data = { 'id': str(id), 'email': rec[0], 'fname': rec[1], 'mname': rec[2], 'lname': rec[3], 'birthday': rec[4], 'gender': rec[5], 'acc_level': str(rec[6]), 'title': rec[7], 'status': rec[8] } return jsonify(data)
def new_question(): data = json.loads(request.data) res = call_stored_procedure( "newquestion", (data['name'], int(data['one_way_interview_id'])), False) if 'Error' in res[0][0]: return jsonify({'status': 'ok', 'message': res[0][0]}) return jsonify({'status': 'ok', 'message': 'Question Added'})
def new_one_way_interview(): data = json.loads(request.data) res = call_stored_procedure( "new_one_way_interview", (int(data['interviewer_id']), int(data['applicant_id'])), False) if 'Error' in res[0][0]: return jsonify({'status': 'ok', 'message': res[0][0]}) return jsonify({'status': 'ok', 'message': 'Success!'})
def new_user(): data = json.loads(request.data) if is_valid_email(data['email']): return jsonify({'status': 'error', 'message': 'Error'}) res = call_stored_procedure( "newuser", (data['email'], data['fname'], data['mname'], data['lname'], data['password'], data['birthday'], data['gender'], int(data['acc_level']), data['title'], data['status']), False) if 'Error' in res[0][0]: return jsonify({'status': 'ok', 'message': res[0][0]}) return jsonify({'status': 'ok', 'message': res[0][0]})
def upload_file(): uploaded_files = request.files.getlist("file[]") filenames = [] for file in uploaded_files: # Check if the file is one of the allowed types/extensions if file and allowed_file(file.filename): # Make the filename safe, remove unsupported chars filename = secure_filename(file.filename) # Move the file form the temporal folder to the upload # folder we setup file.save(os.path.join(flask_app.config['UPLOAD_FOLDER'], filename)) # Save the filename into a list, we'll use it later else: return jsonify({'status': 'error'}) hotel_id = g.id[0][0] res = call_stored_procedure('newimage', (filename, int(hotel_id)), True) return jsonify({'status': 'OK'})
def login(): data = json.loads(request.data) if is_valid_email(data['email']): status = False return jsonify({'status': status, 'message': 'Invalid Email address'}) res = call_stored_procedure( "loginauth", (''.join(data['email']), ''.join(data['password']))) if res[0][0] == 'ERROR': status = False return jsonify({'status': status, 'message': res[0][0]}) else: status = True token = jwt.dumps({'user': data['email'], 'id': res}) return jsonify({ 'status': status, 'token': token, 'message': res[0][0] })