Exemplo n.º 1
0
class NewCoursePost(Resource):
    @login_required(api)
    @api.expect(get_new_post_model(api))
    @api.marshal_with(get_post_model(api),
                      code=201,
                      description='Post published successfully.')
    def post(self, user, course_id, **kwargs):
        return publish_post_to_course(user, course_id, request)
class GetPost(Resource):
    @login_required(api)
    @api.marshal_with(get_post_model(api), code=200, description='Post successfully retrieved')
    @api.response(401, 'Post is private')
    @api.response(404, 'Cant find post')
    @api.response(200, 'Post successfully retrieved')
    def get(self, user, post_id):
        """Get specific post"""
        return get_post_by_id(user, post_id)
Exemplo n.º 3
0
class CoursePostsByID(Resource):
    @login_required(api)
    @api.marshal_list_with(get_post_model(api),
                           code=200,
                           description='Post successfully retrieved')
    def get(self, course_id, per_page, page, **kwargs):
        return get_course_posts(course_id,
                                per_page=int(per_page),
                                page=int(page),
                                request=request)
Exemplo n.º 4
0
class NewGroupPost(Resource):
    @login_required(api)
    @require_group_membership(api)
    @api.expect(get_new_post_model(api))
    @api.marshal_with(get_post_model(api),
                      code=201,
                      description='Post published successfully.')
    def post(self, user, group, **kwargs):
        """Publish a post to the group's board"""
        return publish_post_to_group(user, group, request)
class Posts(Resource):
    @login_required(api)
    @api.expect(get_new_post_model(api))
    @api.marshal_with(get_post_model(api), code=201, description='Post published successfully.')
    @api.response(201, 'Post published successfully.')
    @api.response(300, 'invalid board_id supplied')
    @api.response(401, 'Cant post to private group')
    @api.response(404, 'Cant find board')
    def post(self, user):
        """Publish new post"""
        return save_new_post(user, request)
Exemplo n.º 6
0
class GroupPostsByPage(Resource):
    @login_required(api)
    @require_group_membership(api)
    @api.marshal_with(get_post_model(api),
                      code=200,
                      description='Post successfully retrieved')
    def get(self, group, per_page, page, **kwargs):
        """Get group published posts"""
        return get_group_posts(group,
                               per_page=int(per_page),
                               page=int(page),
                               request=request)
class SearchPost(Resource):
    @login_required(api)
    @api.marshal_list_with(get_post_model(api))
    def get(self, user, searched_post_title):
        """Search post by title"""
        return search_post(user, searched_post_title)
class UserFeed(Resource):
    @login_required(api)
    @api.marshal_list_with(get_post_model(api))
    def get(self, user, per_page, page, **kwargs):
        """Fetch user posts feed"""
        return get_user_feed(user=user, per_page=int(per_page), page=int(page), request=request)
class UserPosts(Resource):
    @login_required(api)
    @api.marshal_list_with(get_post_model(api))
    def get(self, user, fetched_user_id, per_page, page, **kwargs):
        """Fetch user published posts"""
        return get_user_posts(user, fetched_user_id, per_page=int(per_page), page=int(page), request=request)