def get(self): """ Return all the heart rates """ heart_rates = HeartRate.query.all() heart_rates = list_to_array(heart_rates) return custom_response(200, "All Heart Rates", heart_rates)
def get(self): """ Return all the activities """ activities = Activity.query.all() activities = list_to_array(activities) return custom_response(200, "All activities", activities)
def get(self): """ Return all the steps """ steps = Step.query.all() steps = list_to_array(steps) return custom_response(200, "All steps", steps)
def get(self, id): """ Return all the calories for the specified user """ current_user = User.find_by_username(get_jwt_identity()['username']) if current_user.is_admin() or current_user.has_child(id): user = User.query.filter_by(id=id).first() if user is None: return custom_response( 404, "User {} not found".format(id) ) calories = Calorie.query.with_parent(user).all() calories = list_to_array(calories) return custom_response( 200, "{} calories".format(user.username), calories ) else: return custom_response( 401, "Permission denied. User {} not a child".format(id) )
def get(self): """ Return all the users' personal info """ personal_info = PersonalInfo.query.all() personal_info = list_to_array(personal_info) return custom_response(200, "All personal info", personal_info)
def get(self): """ Return all the meters """ meters = Meter.query.all() meters = list_to_array(meters) return custom_response(200, "All meters", meters)
def get(self): """ Return all the users """ users = User.query.all() users = list_to_array(users) return custom_response(200, "All users", users)
def get(self): """ Return all the heart rates for the caller user """ current_user = User.find_by_username(get_jwt_identity()['username']) heart_rates = HeartRate.query.with_parent(current_user).all() heart_rates = list_to_array(heart_rates) return custom_response(200, "Your heart rates", heart_rates)
def get(self): """ Return all activities for the caller user """ current_user = User.find_by_username(get_jwt_identity()['username']) activities = Activity.query.with_parent(current_user).all() activities = list_to_array(activities) return custom_response(200, "Your activities", activities)
def get(self): """ Return all the steps for the caller user """ current_user = User.find_by_username(get_jwt_identity()['username']) steps = Step.query.with_parent(current_user).all() steps = list_to_array(steps) return custom_response(200, "Your steps", steps)
def get(self): """ Return all the meters for the caller user """ current_user = User.find_by_username(get_jwt_identity()['username']) meters = Meter.query.with_parent(current_user).all() meters = list_to_array(meters) return custom_response(200, "Your meters", meters)
def get(self): """ Return all the personal info for the caller user """ current_user = User.find_by_username(get_jwt_identity()['username']) personal_info = PersonalInfo.query.with_parent(current_user).order_by( PersonalInfo.timestamp.desc()).all() personal_info = list_to_array(personal_info) return custom_response(200, "Your personal info", personal_info)
def get(self): """ Return all the children for the caller user """ current_user = User.find_by_username(get_jwt_identity()['username']) children = current_user.family_members.all() children = list_to_array(children) return custom_response(200, "{}'s children".format(current_user.username), children)
def get(self): """ Return all the calories """ calories = Calorie.query.all() calories = list_to_array(calories) return custom_response( 200, "All calories", calories )
def get(self): """ Return all the calories for the caller user """ current_user = User.find_by_username(get_jwt_identity()['username']) calories = Calorie.query.with_parent(current_user).all() calories = list_to_array(calories) return custom_response( 200, "Your calories", calories )