示例#1
0
    def put(self):
        args = self.post_req_parser.parse_args()
        validation_result = self.validate_scores(args['scores'])
        if validation_result is not None:
            return validation_result

        response_id = args['response_id']
        review_form_id = args['review_form_id']
        reviewer_user_id = g.current_user['id']
        scores = args['scores']
        is_submitted = args['is_submitted']

        response_reviewer = review_repository.get_response_reviewer(
            response_id, reviewer_user_id)
        if response_reviewer is None:
            return FORBIDDEN

        review_response = review_repository.get_review_response(
            review_form_id, response_id, reviewer_user_id)
        if review_response is None:
            return REVIEW_RESPONSE_NOT_FOUND

        review_repository.delete_review(review_response)
        review_response.review_scores = self.get_review_scores(scores)
        if is_submitted:
            review_response.submit()
        db.session.commit()

        return review_response, 200
示例#2
0
    def post(self):
        args = self.post_req_parser.parse_args()
        validation_result = self.validate_scores(args['scores'])
        if validation_result is not None:
            return validation_result

        response_id = args['response_id']
        review_form_id = args['review_form_id']
        reviewer_user_id = g.current_user['id']
        scores = args['scores']
        language = args['language']
        is_submitted = args['is_submitted']

        response_reviewer = review_repository.get_response_reviewer(
            response_id, reviewer_user_id)
        if response_reviewer is None:
            return FORBIDDEN

        review_response = ReviewResponse(review_form_id, reviewer_user_id,
                                         response_id, language)
        review_response.review_scores = self.get_review_scores(scores)
        if is_submitted:
            review_response.submit()
        review_repository.add_model(review_response)

        return review_response, 201
示例#3
0
文件: api.py 项目: mxaba/Baobab
    def put(self):
        args = self.post_req_parser.parse_args()
        validation_result = self.validate_scores(args['scores'])
        if validation_result is not None:
            return validation_result

        response_id = args['response_id']
        review_form_id = args['review_form_id']
        reviewer_user_id = g.current_user['id']
        scores = args['scores']

        response_reviewer = review_repository.get_response_reviewer(
            response_id, reviewer_user_id)
        if response_reviewer is None:
            return FORBIDDEN

        review_response = review_repository.get_review_response(
            review_form_id, response_id, reviewer_user_id)
        if review_response is None:
            return REVIEW_RESPONSE_NOT_FOUND

        db.session.query(ReviewScore).filter(
            ReviewScore.review_response_id == review_response.id).delete()
        review_response.review_scores = self.get_review_scores(scores)
        db.session.commit()

        return {}, 200
示例#4
0
def _validate_user_admin_or_reviewer(user_id, event_id, response_id):
    user = user_repository.get_by_id(user_id)
    # Check if the user is an event admin
    permitted = user.is_event_admin(event_id)
    # If they're not an event admin, check if they're a reviewer for the relevant response
    if not permitted and user.is_reviewer(event_id):
        response_reviewer = review_repository.get_response_reviewer(response_id, user.id)
        if response_reviewer is not None:
            permitted = True
    
    return permitted