class ContributorPostDealReqCommentsResource(Resource):

    def __init__(self):
        self._contributor_actor = None

    @marshal_with(fields.CONTRIBUTOR_POST_REQUEST_COMMENT_RESOURCE_FIELDS)
    def get(self,post_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._contributor_actor = ContributorActor(access_token)

        return self._contributor_actor.get_post_deal_req_comments(post_id)


    @marshal_with(fields.CONTRIBUTOR_POST_REQUEST_COMMENT_RESOURCE_FIELDS)
    def post(self,post_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._contributor_actor = ContributorActor(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._contributor_actor.new_post_deal_req_comment(post_id,content),201
    def get(self,post_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._contributor_actor = ContributorActor(access_token)

        return self._contributor_actor.get_post_deal_req_comments(post_id)
コード例 #3
0
class ContributorPostsResource(Resource):

    def __init__(self):
        self._contributor_actor = None

    @marshal_with(fields.CONTRIBUTOR_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._contributor_actor = ContributorActor(access_token)
        posts = self._contributor_actor.get_contributor_posts()
        return posts, 200

    @marshal_with(fields.CONTRIBUTOR_POST_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._contributor_actor = ContributorActor(access_token)

        post_parser =  reqparse.RequestParser()

        post_parser.add_argument('name', required=True)
        post_parser.add_argument('category', required=True)
        post_parser.add_argument('price', type=int,required=True)
        post_parser.add_argument('description', required=True)

        post_args = post_parser.parse_args()
        name = post_args['name']
        category = post_args['category']
        price = post_args['price']
        description = post_args['description']

        return self._contributor_actor.create_new_post(name,category,price,description), 201
    def post(self,post_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._contributor_actor = ContributorActor(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._contributor_actor.new_post_deal_req_comment(post_id,content),201
コード例 #5
0
class ContributorPostRequestResource(Resource):

    def __init__(self):
        self._consumer_actor = None
        self._contributor_actor = None

    @marshal_with(fields.CONTRIBUTOR_POST_REQUEST_RESOURCE_FIELDS)
    def put(self,post_id,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._contributor_actor = ContributorActor(access_token)

        post_parser = ex_reqparse.ExRequestParser()
        post_parser.add_argument('agree', type=bool,required=True)

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

        if agree:
            return self._contributor_actor.agree_post_request(post_id,request_id), 200
        else:
            return self._contributor_actor.refuse_post_request(post_id,request_id), 200
コード例 #6
0
    def put(self,post_id,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._contributor_actor = ContributorActor(access_token)

        post_parser = ex_reqparse.ExRequestParser()
        post_parser.add_argument('agree', type=bool,required=True)

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

        if agree:
            return self._contributor_actor.agree_post_request(post_id,request_id), 200
        else:
            return self._contributor_actor.refuse_post_request(post_id,request_id), 200
コード例 #7
0
class AccountResource(Resource):

    def __init__(self):

        self._someone_actor = SomeoneActor()
        self._contributor_actor = None

    @marshal_with(fields.ACCOUNT_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._contributor_actor = ContributorActor(access_token)

        account = self._contributor_actor.get_account()
        return account, 200

    @marshal_with(fields.ACCOUNT_RESOURCE_FIELDS)
    def post(self):

        new_account_parser = reqparse.RequestParser()
        new_account_parser.add_argument('username',required=True)
        new_account_parser.add_argument('password',required=True)
        new_account_parser.add_argument('nickname',required=True)
        new_account_parser.add_argument('email',required=True)
        new_account_parser.add_argument('phone',required=True)
        new_account_parser.add_argument('name',required=True)
        new_account_parser.add_argument('eid',required=True)
        new_account_parser.add_argument('secret',required=True)


        args = new_account_parser.parse_args()
        username    = args['username']
        password    = args['password']
        nickname    = args['nickname']
        email       = args['email']
        phone   = args['phone']
        name    = args['name']
        eid     = args['eid']
        secret  = args['secret']

        account = self._someone_actor.create_account(username, password,nickname,email,phone,name,eid,secret)
        return account, 201
コード例 #8
0
    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._contributor_actor = ContributorActor(access_token)

        post_parser =  reqparse.RequestParser()

        post_parser.add_argument('name', required=True)
        post_parser.add_argument('category', required=True)
        post_parser.add_argument('price', type=int,required=True)
        post_parser.add_argument('description', required=True)

        post_args = post_parser.parse_args()
        name = post_args['name']
        category = post_args['category']
        price = post_args['price']
        description = post_args['description']

        return self._contributor_actor.create_new_post(name,category,price,description), 201