def get(self): try: posts = Post.objects().to_json() return Response(posts, mimetype="application/json", status=200) except DoesNotExist: raise NotExistsError except Exception: raise InternalServerError
def get(self): try: user_id = get_jwt_identity() user = User.objects.get(id=user_id) ids = user.following ids.append(user) posts = Post.objects(author__in=ids) posts = [convert_post(ob) for ob in posts] posts.sort(key=operator.itemgetter('created_at'), reverse=True) return Response(JSONEncoder().encode(posts), mimetype="application/json", status=200) except DoesNotExist: raise DocumentMissing except Exception as e: raise InternalServerError
def get(self): posts = Post.objects().to_json() return Response(posts, mimetype="application/json", status=200)