def restore(): validated = validate_jwt(request) if (validated): return validated else: return jsonify({'validated': False})
def restore(): auth_header = request.headers['Authorization'] validated = validate_jwt(request) # print(validated,"THIS IS VALLEYDATED") if (validated): return jsonify(validated) else: return jsonify(None)
def user_follows(user_id): validated = validate_jwt(request) jwt_user_id = validated['user']['id'] if (jwt_user_id != int(user_id)): return jsonify(False) follows = Follow.query.filter(Follow.user_id == int(user_id)).all() follows_dict = [follow.wine.to_dict() for follow in follows] return jsonify(follows_dict)
def wine_details(id): wine = Wine.query.get(id).to_dict() if not wine: pass # Next part is to see if the user follows the wine validated = validate_jwt(request) user_id = validated['user']['id'] user_follows = None follow = Follow.query.filter(Follow.user_id == user_id, Follow.wine_id == wine['id']).first() if follow: user_follows = True else: user_follows = False wine['user_follows'] = user_follows return jsonify(wine)
def toggle_follow(): data = request.json wine_id = data validated = validate_jwt(request) user_id = validated['user']['id'] # Check to see if the user follows already or not follow = Follow.query.filter(Follow.wine_id == wine_id, Follow.user_id == user_id).first() following = None if not follow: new_follow = Follow(user_id=user_id, wine_id=wine_id) db.session.add(new_follow) following = True else: db.session.delete(follow) following = False db.session.commit() return jsonify(following)
def restore(): validated = validate_jwt(request) if (validated): return validated else: return jsonify(None)