Exemplo n.º 1
0
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)
Exemplo n.º 2
0
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
    )
Exemplo n.º 3
0
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
    })
Exemplo n.º 4
0
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)
Exemplo n.º 5
0
def get_one_blog_post(url):
    return responses.success(BlogPostsController.get_one(url))
Exemplo n.º 6
0
def get_random_blog_post():
    return responses.success(BlogPostsController.get_random())
Exemplo n.º 7
0
def get_last_blog_post():
    return responses.success(BlogPostsController.get_last())
Exemplo n.º 8
0
def get_information():
    CheckAuth.call(request)
    return responses.success(UsersController.get_one_by_token(request.headers.get('Authorization')))
Exemplo n.º 9
0
def get_user_permissions(username):
    CheckPermissions.call(request, ['USER_WRITE'])
    return responses.success(UsersController.get_user_permissions(username))
Exemplo n.º 10
0
def get_one_user(username):
    return responses.success(UsersController.get_one(username))
Exemplo n.º 11
0
def get_all_users():
    CheckPermissions.call(request, ['USER_WRITE'])
    return responses.success(UsersController.get_all())
Exemplo n.º 12
0
def get_all_posts():
    posts = PostsController.fetch_all()
    posts, pages = paginate(request, posts)
    return responses.success(PostsController.multi_fill_information(posts),
                             pages=pages)