def get_user(token): token = request.args.get('token') user_id = User.verify_auth_token(token) user = session.query(User).filter_by(id=user_id).one() if not user: abort(400) return jsonify(user.serialize)
def up_meetup(id): token = request.args.get('token') user_id = user_id = User.verify_auth_token(token) user = session.query(User).filter_by(id = user_id).one() request = session.query(Request).filter_by(id = id).one() if request: if user: if user_id == request.user_id: meal_type = request.json.get('meal_type') location_string = request.json.get('location_string') latitude = request.json.get('latitude') longitude = request.json.get('longitude') meal_time = request.json.get('meal_time') filled = request.json.get('filled') request.meal_type = meal_type request.location_string = location_string request.latitude = latitude request.longiture = longitude request.meal_time = mean_time request.filled = filled sesson.add(request) session.commit() else: return jsonify(),400 else: return jsonify(),400 else: return jsonify(),400
def get_all_request(token): user_id = User.verify_auth_token(token) user = session.query(User).filter_by(id = user_id).one() if user: requests = session.query(Request).all() return jsonify(Requests = [i.serialize for i in users]) else: return jsonify(), 400
def delete_user(token): user_id = User.verify_auth_token(token) user = session.query(User).filter_by(id = user_id).one() if user: session.delete(user) session.commit() else: return jsonify(), 400
def get_user_all(token): user_id = User.verify_auth_token(token) if user_id: users = session.query(User).all() return jsonify(Users=[i.serialize for i in users]) else: print "token is not available" return jsonify(), 400
def update_user(token): email_u = request.json.get('email') picture = request.json.get('picture') user_id = User.verify_auth_token(token) User = session.query(User).filter_by(id = user_id).one() User.email = email User.picture = picture session.add(User) session.commit()
def meet_up_proposal(): token = request.args.get('token') user_id = User.verify_auth_token(token) requests = session.query(Request).filter_by(user_id = user_id).all() proposals = [] for i in requests: request_id = i.id proposal_user = session.query(Proposal).filter_by(request_id = request_id).one() proposals.append(proposal_user) return jsonify(Proposals = [i.serialize for i in proposals])
def delete_propose(id): token = request.args.get('token') user_id = User.verify_auth_token(token) user = session.query(User).filter_by(id = user_id).one() if user: propose = session.query(Proposal).filter_by(id = id).first() if user.email = propose.user_proposed_from: session.delete(propose) session.commit() else: return jsonify(), 400
def verify_password(username_or_token, password): #Try to see if it's a token first user_id = User.verify_auth_token(username_or_token) if user_id: user = session.query(User).filter_by(id = user_id).one() else: user = session.query(User).filter_by(username = username_or_token).first() if not user or not user.verify_password(password): return False g.user = user return True
def up_propose(id): token = request.args.get('token') user_id = User.verify_auth_token(token) user = session.query(User).filter_by(id = user_id).one() if user: propose = session.query(Proposal).filter_by(id = id).first() if user.email = propose.user_proposed_from: propose.user_proposed_from = user.email propose.user_proposed_to = request.json.get('user_proposed_to') else: return jsonify(), 400
def delete_request(id): token = request.args.get('token') user_id = User.verify_auth_token(token) user = session.query(User).filter_by(id = user_id).one() request = session.query(Request).filter_by(id = id).one() if request: if user: if user_id == request.user_id: session.delete(request) session.commit() token = request.args.get('token') else:
def get_specific(id): token = request.args.get('token') user_id = User.verify_auth_token(token) user = session.query(User).filter_by(id = user_id).one() if user: request = session.query(Request).filter_by(id = id).one() if request: return jsonify(request.serialize) else: return jsonify(), 400 else: return jsonify(), 400
def get_proposal(id): token = request.args.get('token') user_id = User.verify_auth_token(token) user1 = session.query(User).filter_by(id = user_id).first() if user1: user = session.query(User).filter_by(id = user_id).first() if session.query(Proposal).filter_by(user_proposed_to = user.email).first(): propose = session.query(Proposal).filter_by(user_proposed_to = user.email).first() elif session.query(Proposal).filter_by(user_proposed_from = user.email).first(): propose = session.query(Proposal).filter_by(user_proposed_from = user.email).first() return jsonify(propose.serialize) else: return jsonify(Proposals = [i.serialize for i in proposals])
def post_proposal(): token = request.args.get('token') request_id = request.args.get('request_id') request_u = session.query(Request).filter_by(request_id = request_id).one() user_id = User.verify_auth_token(token) user = session.query(User).filter_by(id = user_id).one() user2 = session.query(User).filter_by(id = request_u.user_id) if user: proposals = Proposal(user_proposed_from = user.email, user_proposed_to = user2.email, request_id = request_id) session.add(proposals) session.commit() else: return jsonify(),400
def get_date: token = request.args.get('token') user_id = User.verify_auth_token(token) user = session.query(User).filter_by(id = user_id).one() if user: user1 = session.query(MealDate).filter_by(user1 = user.email).all() user2 = session.query(MealDate).filter_by(user2 = user.email).all() if user1 and user2: user1.append(user2) return jsonify(users = [i.serialize for i in user1]) elif user1: return jsonify(users = [i.serialize for i in user1]) elif user2: return jsonify(users = [i.serialize for i in user2]) else: return jsonify(),400 else: return jsonify(),400