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 get(self, event_id): parser = reqparse.RequestParser() parser.add_argument('language', type=str, required=True) args = parser.parse_args() responses = response_repository.get_all_for_event(event_id) review_form = review_repository.get_review_form(event_id) return [ ReviewResponseSummaryListAPI._serialise_response( response, review_form, args['language']) for response in responses ], 200
def get(self, event_id): req_parser = reqparse.RequestParser() req_parser.add_argument('stage', type=int, required=False) args = req_parser.parse_args() stage = args['stage'] review_form = review_repository.get_review_form(event_id, stage=stage) if not review_form: return REVIEW_FORM_FOR_STAGE_NOT_FOUND review_form.event_id = event_id return review_form
def get(self, event_id): req_parser = reqparse.RequestParser() req_parser.add_argument('response_id', type=int, required=True) req_parser.add_argument('language', type=str, required=True) args = req_parser.parse_args() response_id = args['response_id'] language = args['language'] response = response_repository.get_by_id(response_id) review_form = review_repository.get_review_form(event_id) review_form_id = None if review_form is None else review_form.id review_config = review_configuration_repository.get_configuration_for_event(event_id) num_reviewers = review_config.num_reviews_required + review_config.num_optional_reviews if review_config is not None else 1 return ResponseDetailAPI._serialize_response(response, language, review_form_id, num_reviewers)
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) return ReviewResponseUser(review_form, response, reviews_remaining_count)
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 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
def post(self, event_id): dt_format = lambda x: datetime.strptime(x, '%Y-%m-%dT%H:%M:%S') req_parser = reqparse.RequestParser() req_parser.add_argument('application_form_id', type=int, required=True) req_parser.add_argument('stage', type=int, required=True) req_parser.add_argument('is_open', type=bool, required=True) req_parser.add_argument('deadline', type=dt_format, required=True) req_parser.add_argument('active', type=bool, required=True) req_parser.add_argument('sections', type=dict, required=True, action='append') args = req_parser.parse_args() application_form_id = args['application_form_id'] stage = args['stage'] is_open = args['is_open'] deadline = args['deadline'] active = args['active'] sections_data = args['sections'] review_form = review_repository.get_review_form(event_id, stage) if review_form is not None: return REVIEW_FORM_EXISTS other_review_forms = review_repository.get_review_forms(event_id) review_form = ReviewForm( application_form_id, deadline, stage, # Only make this stage active if there is no other active stage. active=not any(o.active for o in other_review_forms)) review_repository.add_model(review_form) for section_data in sections_data: section = ReviewSection(review_form.id, section_data['order']) review_repository.add_model(section) languages = section_data['name'].keys() for language in languages: section_translation = ReviewSectionTranslation( review_section_id=section.id, language=language, headline=section_data['name'][language], description=section_data['description'][language]) review_repository.add_model(section_translation) for question_data in section_data['questions']: question = ReviewQuestion( review_section_id=section.id, question_id=question_data['question_id'] or None, type=question_data['type'], is_required=question_data['is_required'], order=question_data['order'], weight=question_data['weight']) review_repository.add_model(question) languages = question_data['headline'].keys() for language in languages: question_translation = ReviewQuestionTranslation( review_question_id=question.id, language=language, description=question_data["description"][language], headline=question_data["headline"][language], placeholder=question_data["placeholder"][language], options=question_data["options"][language], validation_regex=question_data["validation_regex"] [language], validation_text=question_data["validation_text"] [language]) review_repository.add_model(question_translation) new_review_form = review_repository.get_review_form_by_id( review_form.id) new_review_form.event_id = event_id return new_review_form, 201