def getuserprofile(current_user): global user_steps count = Community.get_community_count(current_user.id) post_count = Post.get_post_count(current_user.id) steps = Steps.get_steps(current_user.id, 1) for item in steps: user_steps = item.steps_no data = { 'user_id': current_user.id, 'username': current_user.username, 'community': count, 'posts': post_count, 'steps_today': user_steps } return jsonify(data), 200
def getuser(): global user_steps values = request.get_json() required = ['user_id'] if not all(k in values for k in required): return 'Missing values', 400 user = User.get_by_id(values.get('user_id')) count = Community.get_community_count(values.get('user_id')) post_count = Post.get_post_count(values.get('user_id')) steps = Steps.get_steps(values.get('user_id'), 1) for item in steps: user_steps = item.steps_no if user: data = { 'user_id': user.id, 'username': user.username, 'community': count, 'posts': post_count, 'steps_today': user_steps } else: return response('failed', 'User Does not exist', 401) return jsonify(data), 200
def getuserprofileid(current_user, userid): global user_steps isFollowing = False community = Community.get_community(current_user.id) for person in community: if person.community_id == userid: isFollowing = True count = Community.get_community_count(userid) post_count = Post.get_post_count(userid) steps = Steps.get_steps(userid, 1) user = User.get_by_id(userid) for item in steps: user_steps = item.steps_no data = { 'user_id': userid, 'username': User.getusername(userid), 'community': count, 'posts': post_count, 'isFollowing': isFollowing, 'full_name': user.first_name + " " + user.last_name, 'steps_today': user_steps } return jsonify(data), 200