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
def get(self): parser = reqparse.RequestParser() parser.add_argument('response_id', type=int, required=True) parser.add_argument('event_id', type=int, required=True) parser.add_argument('language', type=str, required=True) args = parser.parse_args() response_id = args['response_id'] event_id = args['event_id'] review_form = review_repository.get_review_form(event_id) if review_form is None: return REVIEW_FORM_NOT_FOUND response = review_repository.get_response_by_reviewer( response_id, g.current_user['id']) if response is None: return RESPONSE_NOT_FOUND review_response = review_repository.get_review_response( review_form.id, response_id, g.current_user['id']) return ReviewResponseUser(review_form, response, 0, args['language'], review_response=review_response)
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
def _serialize_reviewer(response_reviewer, review_form_id): if review_form_id is None: completed = False else: review_response = review_repository.get_review_response(review_form_id, response_reviewer.response_id, response_reviewer.reviewer_user_id) completed = review_response is not None return { 'reviewer_user_id': response_reviewer.user.id, 'user_title': response_reviewer.user.user_title, 'firstname': response_reviewer.user.firstname, 'lastname': response_reviewer.user.lastname, 'completed': completed }
def get(self): args = self.req_parser.parse_args() event_id = args['event_id'] review_form = review_repository.get_review_form(event_id) if review_form is None: return EVENT_NOT_FOUND reviews_remaining_count = review_repository.get_remaining_reviews_count( g.current_user['id'], review_form.application_form_id) skip = self.sanitise_skip(args['skip'], reviews_remaining_count) response = review_repository.get_response_to_review( skip, g.current_user['id'], review_form.application_form_id) references = [] if response is not None: reference_requests = reference_repository.get_all_by_response_id( response.id) for r in reference_requests: reference = reference_repository.get_reference_by_reference_request_id( r.id) if reference is not None: references.append( ReviewResponseReference(r.title, r.firstname, r.lastname, r.relation, reference.uploaded_document)) review_response = None if response is None else review_repository.get_review_response( review_form.id, response.id, g.current_user['id']) references = None if len(references) == 0 else references return ReviewResponseUser(review_form, response, reviews_remaining_count, args['language'], reference_responses=references, review_response=review_response)
def get(self): args = self.req_parser.parse_args() event_id = args['event_id'] review_form = review_repository.get_review_form(event_id) if review_form is None: return EVENT_NOT_FOUND reviews_remaining_count = review_repository.get_remaining_reviews_count( g.current_user['id'], review_form.application_form_id) skip = self.sanitise_skip(args['skip'], reviews_remaining_count) response = review_repository.get_response_to_review( skip, g.current_user['id'], review_form.application_form_id) review_response = None if response is None else review_repository.get_review_response( review_form.id, response.id, g.current_user['id']) return ReviewResponseUser(review_form, response, reviews_remaining_count, args['language'], review_response)
def delete(self, event_id): parser = reqparse.RequestParser() parser.add_argument('response_id', type=int, required=True) parser.add_argument('reviewer_user_id', type=int, required=True) args = parser.parse_args() response_id = args['response_id'] reviewer_user_id = args['reviewer_user_id'] review_form = review_repository.get_review_form(event_id) if not review_form: return REVIEW_FORM_NOT_FOUND # If the reviewer has already completed the review, action can't be completed review_response = review_repository.get_review_response( review_form.id, response_id, reviewer_user_id) if review_response: return REVIEW_ALREADY_COMPLETED review_repository.delete_response_reviewer(response_id, reviewer_user_id) return {}, 200