class ConsumerRequestCommentsResource(Resource):

    def __init__(self):
        self._consumer_actor = None

    @marshal_with(fields.CONSUMER_REQUEST_COMMENT_RESOURCE_FIELDS)
    def get(self,request_id):
        request_parser = ex_reqparse.ExRequestParser()
        request_parser.add_argument(arguments.ACCESS_TOKEN_HEADER)
        request_args = request_parser.parse_args()
        access_token = re.sub('^Bearer ', '', request_args['Authorization'])
        self._consumer_actor = ConsumerActor(access_token)

        return self._consumer_actor.get_consumer_request_comments(request_id)


    @marshal_with(fields.CONSUMER_REQUEST_COMMENT_RESOURCE_FIELDS)
    def post(self,request_id):
        request_parser = ex_reqparse.ExRequestParser()
        request_parser.add_argument(arguments.ACCESS_TOKEN_HEADER)
        request_args = request_parser.parse_args()
        access_token = re.sub('^Bearer ', '', request_args['Authorization'])
        self._consumer_actor = ConsumerActor(access_token)

        post_parser = ex_reqparse.ExRequestParser()
        post_parser.add_argument('content', required=True)

        post_args = post_parser.parse_args()
        content = post_args['content']


        return self._consumer_actor.new_consumer_request_comment(request_id,content),201
class ConsumerRequestsResource(Resource):

    def __init__(self):
        self._consumer_actor = None

    @marshal_with(fields.CONSUMER_REQUEST_RESOURCE_FIELDS)
    def get(self):
        request_parser = ex_reqparse.ExRequestParser()
        request_parser.add_argument(arguments.ACCESS_TOKEN_HEADER)

        request_args = request_parser.parse_args()
        access_token = re.sub('^Bearer ', '', request_args['Authorization'])

        self._consumer_actor = ConsumerActor(access_token)
        requests = self._consumer_actor.get_consumer_requests()
        return requests, 200

    @marshal_with(fields.CONSUMER_REQUEST_RESOURCE_FIELDS)
    def post(self):
        request_parser = ex_reqparse.ExRequestParser()
        request_parser.add_argument(arguments.ACCESS_TOKEN_HEADER)
        request_args = request_parser.parse_args()
        access_token = re.sub('^Bearer ', '', request_args['Authorization'])
        self._consumer_actor = ConsumerActor(access_token)

        post_parser = ex_reqparse.ExRequestParser()
        post_parser.add_argument('post_id', type=int,required=True)

        post_args = post_parser.parse_args()
        post_id = post_args['post_id']

        return self._consumer_actor.make_post_request(post_id), 201
    def get(self,request_id):
        request_parser = ex_reqparse.ExRequestParser()
        request_parser.add_argument(arguments.ACCESS_TOKEN_HEADER)
        request_args = request_parser.parse_args()
        access_token = re.sub('^Bearer ', '', request_args['Authorization'])
        self._consumer_actor = ConsumerActor(access_token)

        return self._consumer_actor.get_consumer_request_comments(request_id)
    def post(self):
        request_parser = ex_reqparse.ExRequestParser()
        request_parser.add_argument(arguments.ACCESS_TOKEN_HEADER)
        request_args = request_parser.parse_args()
        access_token = re.sub('^Bearer ', '', request_args['Authorization'])
        self._consumer_actor = ConsumerActor(access_token)

        post_parser = ex_reqparse.ExRequestParser()
        post_parser.add_argument('post_id', type=int,required=True)

        post_args = post_parser.parse_args()
        post_id = post_args['post_id']

        return self._consumer_actor.make_post_request(post_id), 201
    def post(self,request_id):
        request_parser = ex_reqparse.ExRequestParser()
        request_parser.add_argument(arguments.ACCESS_TOKEN_HEADER)
        request_args = request_parser.parse_args()
        access_token = re.sub('^Bearer ', '', request_args['Authorization'])
        self._consumer_actor = ConsumerActor(access_token)

        post_parser = ex_reqparse.ExRequestParser()
        post_parser.add_argument('content', required=True)

        post_args = post_parser.parse_args()
        content = post_args['content']


        return self._consumer_actor.new_consumer_request_comment(request_id,content),201
Beispiel #6
0
class PostsResource(Resource):
    def __init__(self):
        self._consumer_actor = None
        self._contributor_actor = None

    @marshal_with(fields.THE_POST_RESOURCE_FIELDS)
    def get(self):
        request_parser = ex_reqparse.ExRequestParser()
        request_parser.add_argument(arguments.ACCESS_TOKEN_HEADER)

        request_args = request_parser.parse_args()
        access_token = re.sub('^Bearer ', '', request_args['Authorization'])

        self._consumer_actor = ConsumerActor(access_token)
        posts = self._consumer_actor.get_all_posts()
        return posts, 200