def get_all_comments(): CheckPermissions.call(request, ['USER_WRITE']) comments = CommentsController.fetch_all() comments, pages = paginate(request, comments) comments = CommentsController.multi_fill_information(comments) return responses.success(comments, pages=pages)
def get_comments_by_post(post): BlogPostsController.get_one(post) comments = CommentsController.fetch_by_post(post) comments, pages = paginate(request, comments) return responses.success( CommentsController.multi_fill_information(comments, to_exclude=['ip', 'is_validated', 'email']), pages=pages )
def create_session(): required_data = { 'email': { 'type': 'string' }, 'password': { 'type': 'string' } } data = CheckBody.call(request, required_data=required_data) user, token = AuthController.create_session(data['email'], data['password']) return responses.success({ 'user': user, 'token': token })
def get_all_blog_posts(): posts = BlogPostsController.fetch_all() options = { 'category': BlogPostsController.filter_by_category, 'type': BlogPostsController.filter_by_type, 'author': BlogPostsController.filter_by_author, 'search': BlogPostsController.filter_by_search } for name in options: option = request.args.get(name, None) if option is not None: posts = options[name](posts, option) posts, pages = paginate(request, posts) posts = BlogPostsController.multi_fill_information(posts) return responses.success(posts, pages=pages)
def get_one_blog_post(url): return responses.success(BlogPostsController.get_one(url))
def get_random_blog_post(): return responses.success(BlogPostsController.get_random())
def get_last_blog_post(): return responses.success(BlogPostsController.get_last())
def get_information(): CheckAuth.call(request) return responses.success(UsersController.get_one_by_token(request.headers.get('Authorization')))
def get_user_permissions(username): CheckPermissions.call(request, ['USER_WRITE']) return responses.success(UsersController.get_user_permissions(username))
def get_one_user(username): return responses.success(UsersController.get_one(username))
def get_all_users(): CheckPermissions.call(request, ['USER_WRITE']) return responses.success(UsersController.get_all())
def get_all_posts(): posts = PostsController.fetch_all() posts, pages = paginate(request, posts) return responses.success(PostsController.multi_fill_information(posts), pages=pages)