def review_save(request): mandate_id = request.POST.get("mandate_id") review_id = request.POST.get("review_id") rev = review.find_by_id(review_id) mandate = assistant_mandate.find_mandate_by_id(mandate_id) current_person = request.user.person form = ReviewForm(data=request.POST, instance=rev, prefix='rev') menu = generate_phd_supervisor_menu_tabs(mandate, reviewer_role.PHD_SUPERVISOR) previous_mandates = assistant_mandate.find_before_year_for_assistant(mandate.academic_year.year, mandate.assistant) if form.is_valid(): current_review = form.save(commit=False) if 'validate_and_submit' in request.POST: validate_review_and_update_mandate(current_review, mandate) return HttpResponseRedirect(reverse("phd_supervisor_assistants_list")) elif 'save' in request.POST: current_review.status = review_status.IN_PROGRESS current_review.save() return review_edit(request) else: return render(request, "review_form.html", {'review': rev, 'role': mandate.state, 'year': mandate.academic_year.year + 1, 'current_person': current_person, 'absences': mandate.absences, 'comment': mandate.comment, 'mandate_id': mandate.id, 'previous_mandates': previous_mandates, 'assistant': mandate.assistant, 'menu': menu, 'menu_type': 'phd_supervisor_menu', 'form': form})
def review_save(request): mandate_id = request.POST.get("mandate_id") review_id = request.POST.get("review_id") rev = review.find_by_id(review_id) mandate = assistant_mandate.find_mandate_by_id(mandate_id) current_reviewer = reviewer.find_by_person(request.user.person) form = ReviewForm(data=request.POST, instance=rev, prefix='rev') previous_mandates = assistant_mandate.find_before_year_for_assistant(mandate.academic_year.year, mandate.assistant) role = current_reviewer.role entity = entity_version.get_last_version(current_reviewer.entity) menu = generate_reviewer_menu_tabs(role, mandate, role) if form.is_valid(): current_review = form.save(commit=False) if 'validate_and_submit' in request.POST: validate_review_and_update_mandate(current_review, mandate) return HttpResponseRedirect(reverse("reviewer_mandates_list_todo")) elif 'save' in request.POST: current_review.status = review_status.IN_PROGRESS current_review.save() return review_edit(request) else: return render(request, "review_form.html", {'review': rev, 'role': mandate.state, 'year': mandate.academic_year.year + 1, 'absences': mandate.absences, 'comment': mandate.comment, 'mandate_id': mandate.id, 'previous_mandates': previous_mandates, 'assistant': mandate.assistant, 'entity': entity, 'menu': menu, 'menu_type': 'reviewer_menu', 'form': form})
def review_save(request): mandate_id = request.POST.get("mandate_id") review_id = request.POST.get("review_id") rev = review.find_by_id(review_id) mandate = assistant_mandate.find_mandate_by_id(mandate_id) current_reviewer = reviewer.can_edit_review( reviewer.find_by_person(person.find_by_user(request.user)).id, mandate_id) form = ReviewForm(data=request.POST, instance=rev, prefix='rev') previous_mandates = assistant_mandate.find_before_year_for_assistant( mandate.academic_year.year, mandate.assistant) role = current_reviewer.role entity = entity_version.get_last_version(current_reviewer.entity) menu = generate_reviewer_menu_tabs(role, mandate, role) if form.is_valid(): current_review = form.save(commit=False) if 'validate_and_submit' in request.POST: current_review.status = review_status.DONE current_review.save() if mandate.state == assistant_mandate_state.PHD_SUPERVISOR: if mandate_entity.find_by_mandate_and_type( mandate, entity_type.INSTITUTE): mandate.state = assistant_mandate_state.RESEARCH elif mandate_entity.find_by_mandate_and_type( mandate, entity_type.POLE): mandate.state = assistant_mandate_state.RESEARCH else: mandate.state = assistant_mandate_state.SUPERVISION elif mandate.state == assistant_mandate_state.RESEARCH: mandate.state = assistant_mandate_state.SUPERVISION elif mandate.state == assistant_mandate_state.SUPERVISION: mandate.state = assistant_mandate_state.VICE_RECTOR elif mandate.state == assistant_mandate_state.VICE_RECTOR: mandate.state = assistant_mandate_state.DONE mandate.save() if current_review.reviewer is not None: return HttpResponseRedirect(reverse("reviewer_mandates_list")) else: return HttpResponseRedirect( reverse("phd_supervisor_assistants_list")) elif 'save' in request.POST: current_review.status = review_status.IN_PROGRESS current_review.save() return review_edit(request) else: return render( request, "review_form.html", { 'review': rev, 'role': mandate.state, 'year': mandate.academic_year.year + 1, 'absences': mandate.absences, 'comment': mandate.comment, 'mandate_id': mandate.id, 'previous_mandates': previous_mandates, 'assistant': mandate.assistant, 'entity': entity, 'menu': menu, 'menu_type': 'reviewer_menu', 'form': form })
def review_save(request): mandate_id = request.POST.get("mandate_id") review_id = request.POST.get("review_id") rev = review.find_by_id(review_id) mandate = assistant_mandate.find_mandate_by_id(mandate_id) current_reviewer = reviewer.find_by_person(request.user.person) form = ReviewForm(data=request.POST, instance=rev, prefix='rev') previous_mandates = assistant_mandate.find_before_year_for_assistant(mandate.academic_year.year, mandate.assistant) role = current_reviewer.role entity = entity_version.get_last_version(current_reviewer.entity) menu = generate_reviewer_menu_tabs(role, mandate, role) if form.is_valid(): current_review = form.save(commit=False) if 'validate_and_submit' in request.POST: if current_review.advice not in assistant_mandate_renewal.ASSISTANT_MANDATE_RENEWAL_TYPES: errors = form._errors.setdefault("advice", ErrorList()) errors.append(_('advice_missing_in_form')) return render(request, "review_form.html", {'review': rev, 'role': mandate.state, 'year': mandate.academic_year.year + 1, 'absences': mandate.absences, 'comment': mandate.comment, 'reviewer_role': reviewer_role, 'can_validate': reviewer.can_validate(current_reviewer), 'mandate_id': mandate.id, 'previous_mandates': previous_mandates, 'assistant': mandate.assistant, 'entity': entity, 'menu': menu, 'menu_type': 'reviewer_menu', 'form': form}) current_review.reviewer = current_reviewer validate_review_and_update_mandate(current_review, mandate) return HttpResponseRedirect(reverse("reviewer_mandates_list_todo")) elif 'save' in request.POST: current_review.reviewer = current_reviewer current_review.status = review_status.IN_PROGRESS current_review.save() return review_edit(request) else: return render(request, "review_form.html", {'review': rev, 'role': mandate.state, 'year': mandate.academic_year.year + 1, 'absences': mandate.absences, 'comment': mandate.comment, 'reviewer_role': reviewer_role, 'mandate_id': mandate.id, 'previous_mandates': previous_mandates, 'assistant': mandate.assistant, 'entity': entity, 'menu': menu, 'menu_type': 'reviewer_menu', 'form': form})
def review_save(request): mandate_id = request.POST.get("mandate_id") review_id = request.POST.get("review_id") rev = review.find_by_id(review_id) mandate = assistant_mandate.find_mandate_by_id(mandate_id) current_person = request.user.person form = ReviewForm(data=request.POST, instance=rev, prefix='rev') menu = generate_phd_supervisor_menu_tabs(mandate, reviewer_role.PHD_SUPERVISOR) previous_mandates = assistant_mandate.find_before_year_for_assistant( mandate.academic_year.year, mandate.assistant) if form.is_valid(): current_review = form.save(commit=False) if 'validate_and_submit' in request.POST: current_review.status = review_status.DONE current_review.save() if mandate_entity.find_by_mandate_and_type(mandate, entity_type.INSTITUTE): mandate.state = assistant_mandate_state.RESEARCH elif mandate_entity.find_by_mandate_and_type( mandate, entity_type.POLE): mandate.state = assistant_mandate_state.RESEARCH else: mandate.state = assistant_mandate_state.SUPERVISION mandate.save() return HttpResponseRedirect( reverse("phd_supervisor_assistants_list")) elif 'save' in request.POST: current_review.status = review_status.IN_PROGRESS current_review.save() return review_edit(request) else: return render( request, "review_form.html", { 'review': rev, 'role': mandate.state, 'year': mandate.academic_year.year + 1, 'current_person': current_person, 'absences': mandate.absences, 'comment': mandate.comment, 'mandate_id': mandate.id, 'previous_mandates': previous_mandates, 'assistant': mandate.assistant, 'menu': menu, 'menu_type': 'phd_supervisor_menu', 'form': form })