def user_posts(): uid = g.user.uid user_id = request.args.get('uid') user_id = user_id if user_id is not None else uid posts_list = Posts.user_posts(user_id) list = PostsCollection(posts_list) return json.dumps(list.data)
def received_comments(): user_id = g.user.uid posts_list = Posts.user_posts(user_id) posts_ids = [post.id for post in posts_list] list = Comments.query.filter(Comments.post_id.in_(posts_ids), Comments.user_id != user_id).all() return list