def get(self, id): resp = PostService.get_movie_by_post(id) if resp[1] != 200: abort(403, resp) else: return resp
def get(self, id): resp = PostService.fetch_reaction_info(id) if resp[1] != 200: abort(403, resp) else: return resp
def post(self, id): resp = PostService.downvote_post(id) if resp[1] != 200: abort(403, resp) else: return resp
def get(self, id): resp = PostService.fetch_all_comments(id) if resp[1] != 200: abort(403, resp) else: return resp
def post(self): """ Create New Post. Takes post title and post body as payload. Login is required. """ new_post_data = request.json print(new_post_data) resp = PostService.create_new_post(new_post_data) return resp
def delete(self, id): """ Delete post with given ID. User needs to be authenticated. """ resp = PostService.delete_post({'post_id': id}) if resp[1] != 200: abort(403, resp) else: return resp
def get(self, id): """ Fetches the post given by the id. """ post_id = int(id) resp = PostService.get_post_by_id(post_id) if resp[1] != 200: abort(403, resp) else: return resp
def post(self, id): """ Update post with given ID. User needs to be authenticated properly. """ post_data = request.json resp = PostService.update_post(post_data, id) if resp[1] != 200: abort(403, resp) else: return resp
def get(self): ''' Get all Posts. If a query is given, fetch all posts that match query. ''' q = request.args.get("q") page = request.args.get("page") or 1 resp = PostService.get_post_by_query(q, page) if resp[1] != 200: abort(403, resp) else: return resp