def get(self): parser = reqparse.RequestParser() parser.add_argument('event_id', type=int, required=True) args = parser.parse_args() event_id = args['event_id'] review_forms = review_repository.get_all_review_forms_for_event( event_id) current_form = [r for r in review_forms if r.active] if not current_form: return NO_ACTIVE_REVIEW_FORM current_form = current_form[0] return { 'current_stage': current_form.stage, 'total_stages': len(review_forms) }
def post(self, event_id): parser = reqparse.RequestParser() parser.add_argument('stage', type=int, required=True) args = parser.parse_args() stage = args['stage'] review_forms = review_repository.get_all_review_forms_for_event( event_id) selected_form = [r for r in review_forms if r.stage == stage] if not selected_form: return REVIEW_FORM_FOR_STAGE_NOT_FOUND selected_form = selected_form[0] for form in review_forms: form.deactivate() selected_form.activate() db.session.commit() return {}, 201