def pst_form_view(request):
    mandate_id = request.POST.get("mandate_id")
    mandate = assistant_mandate.find_mandate_by_id(mandate_id)
    current_reviewer = reviewer.find_by_person(request.user.person)
    current_role = current_reviewer.role
    entity = entity_version.get_last_version(current_reviewer.entity)
    entities = get_entities_for_mandate(mandate)
    learning_units = tutoring_learning_unit_year.find_by_mandate(mandate)
    phd_files = assistant_document_file.find_by_assistant_mandate_and_description(mandate,
                                                                                  document_type.PHD_DOCUMENT)
    research_files = assistant_document_file.find_by_assistant_mandate_and_description(mandate,
                                                                                       document_type.RESEARCH_DOCUMENT)
    tutoring_files = assistant_document_file.find_by_assistant_mandate_and_description(mandate,
                                                                                       document_type.TUTORING_DOCUMENT)
    assistant = mandate.assistant
    menu = generate_reviewer_menu_tabs(current_role, mandate, None)
    return render(request, 'pst_form_view.html', {'menu': menu,
                                                  'menu_type': 'reviewer_menu',
                                                  'mandate_id': mandate.id,
                                                  'assistant': assistant, 'mandate': mandate,
                                                  'learning_units': learning_units,
                                                  'entity': entity,
                                                  'entities': entities,
                                                  'phd_files': phd_files,
                                                  'assistant_mandate_renewal': assistant_mandate_renewal,
                                                  'research_files': research_files,
                                                  'tutoring_files': tutoring_files,
                                                  'current_reviewer': current_reviewer,
                                                  'role': current_role,
                                                  'year': mandate.academic_year.year + 1})
Example #2
0
def can_edit_review(reviewer_id, mandate_id):
    if assistant_mandate.find_mandate_by_id(
            mandate_id).state not in find_by_id(reviewer_id).role:
        return None

    if not mandate_entity.find_by_mandate_and_entity(
            assistant_mandate.find_mandate_by_id(mandate_id),
            find_by_id(reviewer_id).entity):
        if not mandate_entity.find_by_mandate_and_part_of_entity(
                assistant_mandate.find_mandate_by_id(mandate_id),
                find_by_id(reviewer_id).entity):
            return None
        else:
            return find_by_id(reviewer_id)
    else:
        return find_by_id(reviewer_id)
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_view(request):
    mandate_id = request.POST.get("mandate_id")
    role = request.POST.get("role")
    mandate = assistant_mandate.find_mandate_by_id(mandate_id)
    current_reviewer = reviewer.find_by_person(request.user.person)
    entity = entity_version.get_last_version(current_reviewer.entity)
    current_role = current_reviewer.role
    if role == reviewer_role.PHD_SUPERVISOR:
        try:
            current_review = review.find_done_by_supervisor_for_mandate(mandate)
        except ObjectDoesNotExist:
            current_review = None
    else:
        current_review = review.find_review_for_mandate_by_role(mandate, role)
    assistant = mandate.assistant
    menu = generate_reviewer_menu_tabs(current_role, mandate, role)
    return render(request, 'review_view.html', {'review': current_review,
                                                'role': current_role,
                                                'menu': menu,
                                                'menu_type': 'reviewer_menu',
                                                'mandate_id': mandate.id,
                                                'mandate_state': mandate.state,
                                                'current_reviewer': current_reviewer,
                                                'entity': entity,
                                                'assistant': assistant,
                                                'year': mandate.academic_year.year + 1
                                                })
Example #5
0
def review_view(request):
    mandate_id = request.POST.get("mandate_id")
    role = request.POST.get("role")
    mandate = assistant_mandate.find_mandate_by_id(mandate_id)
    current_reviewer = reviewer.Reviewer.objects.filter(
        person=request.user.person,
        entity__mandateentity__assistant_mandate=mandate
    ).first()
    entity = entity_version.get_last_version(current_reviewer.entity)

    current_role = current_reviewer.role
    if role == reviewer_role.PHD_SUPERVISOR:
        try:
            current_review = review.find_done_by_supervisor_for_mandate(mandate)
        except ObjectDoesNotExist:
            current_review = None
    else:
        current_review = review.find_review_for_mandate_by_role(mandate, role)
    assistant = mandate.assistant
    menu = generate_reviewer_menu_tabs(current_role, mandate, role)
    return render(request, 'review_view.html', {'review': current_review,
                                                'role': current_role,
                                                'menu': menu,
                                                'menu_type': 'reviewer_menu',
                                                'mandate_id': mandate.id,
                                                'mandate_state': mandate.state,
                                                'current_reviewer': current_reviewer,
                                                'entity': entity,
                                                'assistant': assistant,
                                                'year': mandate.academic_year.year + 1
                                                })
Example #6
0
def pst_form_view(request):
    mandate_id = request.POST.get("mandate_id")
    mandate = assistant_mandate.find_mandate_by_id(mandate_id)
    current_role = reviewer_role.PHD_SUPERVISOR
    current_person = request.user.person
    learning_units = tutoring_learning_unit_year.find_by_mandate(mandate)
    assistant = mandate.assistant
    entities = get_entities_for_mandate(mandate)
    phd_files = assistant_document_file.find_by_assistant_mandate_and_description(
        mandate, document_type.PHD_DOCUMENT)
    research_files = assistant_document_file.find_by_assistant_mandate_and_description(
        mandate, document_type.RESEARCH_DOCUMENT)
    tutoring_files = assistant_document_file.find_by_assistant_mandate_and_description(
        mandate, document_type.TUTORING_DOCUMENT)
    menu = generate_phd_supervisor_menu_tabs(mandate, None)
    return render(
        request, 'pst_form_view.html', {
            'menu': menu,
            'mandate_id': mandate.id,
            'assistant': assistant,
            'mandate': mandate,
            'learning_units': learning_units,
            'current_person': current_person,
            'phd_files': phd_files,
            'entities': entities,
            'research_files': research_files,
            'tutoring_files': tutoring_files,
            'role': current_role,
            'assistant_mandate_renewal': assistant_mandate_renewal,
            'menu_type': 'phd_supervisor_menu',
            'year': mandate.academic_year.year + 1
        })
Example #7
0
def pst_form_view(request):
    mandate_id = request.POST.get("mandate_id")
    mandate = assistant_mandate.find_mandate_by_id(mandate_id)
    current_reviewer = reviewer.Reviewer.objects.filter(
        person=request.user.person,
        entity__mandateentity__assistant_mandate=mandate
    ).first()
    current_role = current_reviewer.role
    entity = entity_version.get_last_version(current_reviewer.entity)
    entities = get_entities_for_mandate(mandate)
    learning_units = tutoring_learning_unit_year.find_by_mandate(mandate)
    phd_files = assistant_document_file.find_by_assistant_mandate_and_description(mandate,
                                                                                  document_type.PHD_DOCUMENT)
    research_files = assistant_document_file.find_by_assistant_mandate_and_description(mandate,
                                                                                       document_type.RESEARCH_DOCUMENT)
    tutoring_files = assistant_document_file.find_by_assistant_mandate_and_description(mandate,
                                                                                       document_type.TUTORING_DOCUMENT)
    assistant = mandate.assistant
    menu = generate_reviewer_menu_tabs(current_role, mandate, None)
    return render(request, 'pst_form_view.html', {'menu': menu,
                                                  'menu_type': 'reviewer_menu',
                                                  'mandate_id': mandate.id,
                                                  'assistant': assistant, 'mandate': mandate,
                                                  'learning_units': learning_units,
                                                  'entity': entity,
                                                  'entities': entities,
                                                  'phd_files': phd_files,
                                                  'assistant_mandate_renewal': assistant_mandate_renewal,
                                                  'research_files': research_files,
                                                  'tutoring_files': tutoring_files,
                                                  'current_reviewer': current_reviewer,
                                                  'role': current_role,
                                                  'year': mandate.academic_year.year + 1})
Example #8
0
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_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})
Example #10
0
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.Reviewer.objects.filter(
        person=request.user.person,
        entity__mandateentity__assistant_mandate=mandate
    ).first()
    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 form.has_remark_been_modified():
            history.add_review_history_entry(form.instance, request.user.person)
        if 'validate_and_submit' in request.POST:
            valid_advice_choices = (k for k, v in review_advice_choices.REVIEW_ADVICE_CHOICES)
            if current_review.advice not in valid_advice_choices:
                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})
Example #11
0
def reviews_view(request, mandate_id):
    reviews = find_by_mandate(mandate_id)
    mandate = assistant_mandate.find_mandate_by_id(mandate_id)
    return render(
        request, 'manager_reviews_view.html', {
            'mandate_id': mandate_id,
            'year': mandate.academic_year.year + 1,
            'reviews': reviews
        })
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 reviews_view(request, mandate_id):
    reviews = find_by_mandate(mandate_id)
    mandate = assistant_mandate.find_mandate_by_id(mandate_id)
    can_go_backward = mandate_can_go_backward(mandate)

    return render(
        request, 'manager_reviews_view.html', {
            'mandate_id': mandate_id,
            'year': mandate.academic_year.year + 1,
            'reviews': reviews,
            'can_go_backward': can_go_backward
        })
def reviews_view(request, mandate_id):
    reviews = find_by_mandate(mandate_id)
    mandate = assistant_mandate.find_mandate_by_id(mandate_id)
    can_go_backward = mandate_can_go_backward(mandate)

    return render(
        request, 'manager_reviews_view.html',
        {
            'mandate_id': mandate_id,
            'year': mandate.academic_year.year + 1,
            'reviews': reviews,
            'can_go_backward': can_go_backward
        }
    )
Example #15
0
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
            })
def review_edit(request):
    mandate_id = request.POST.get("mandate_id")
    mandate = assistant_mandate.find_mandate_by_id(mandate_id)
    current_reviewer = reviewer.find_by_person(request.user.person)
    entity = entity_version.get_last_version(current_reviewer.entity)
    delegate_role = current_reviewer.role + "_ASSISTANT"
    existing_review = review.find_review_for_mandate_by_role(
        mandate, delegate_role)
    if existing_review is None:
        existing_review, created = review.Review.objects.get_or_create(
            mandate=mandate,
            reviewer=current_reviewer,
            status=review_status.IN_PROGRESS)
    previous_mandates = assistant_mandate.find_before_year_for_assistant(
        mandate.academic_year.year, mandate.assistant)
    role = current_reviewer.role
    menu = generate_reviewer_menu_tabs(role, mandate, role)
    assistant = mandate.assistant
    form = ReviewForm(initial={
        'mandate': mandate,
        'reviewer': existing_review.reviewer,
        'status': existing_review.status,
        'advice': existing_review.advice,
        'changed': timezone.now,
        'confidential': existing_review.confidential,
        'remark': existing_review.remark
    },
                      prefix="rev",
                      instance=existing_review)
    return render(
        request, 'review_form.html', {
            'review': existing_review,
            'role': role,
            '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': assistant,
            'can_validate': reviewer.can_validate(current_reviewer),
            'current_reviewer': current_reviewer,
            'entity': entity,
            'menu': menu,
            'menu_type': 'reviewer_menu',
            'form': form
        })
def find_assistant_mandate_step_backward_state(request):
    mandate_id = request.POST.get('mandate_id')
    mandate = assistant_mandate.find_mandate_by_id(mandate_id)
    if mandate.state == assistant_mandate_state.TRTS:
        make_assistant_mandate_step_backward(
            mandate=mandate,
            rev_role=None,
            state_to=assistant_mandate_state.TO_DO)
    elif mandate.state == assistant_mandate_state.PHD_SUPERVISOR:
        make_assistant_mandate_step_backward(
            mandate=mandate,
            rev_role=None,
            state_to=assistant_mandate_state.TRTS)
    elif mandate.state == assistant_mandate_state.RESEARCH:
        if mandate.assistant.supervisor:
            make_assistant_mandate_step_backward(
                mandate, reviewer_role.PHD_SUPERVISOR,
                assistant_mandate_state.PHD_SUPERVISOR)
        else:
            make_assistant_mandate_step_backward(
                mandate=mandate,
                rev_role=None,
                state_to=assistant_mandate_state.TRTS)
    elif mandate.state == assistant_mandate_state.SUPERVISION:
        if mandate.assistant_type == assistant_type.ASSISTANT:
            make_assistant_mandate_step_backward(
                mandate=mandate,
                rev_role=reviewer_role.RESEARCH,
                state_to=assistant_mandate_state.RESEARCH)
        else:
            make_assistant_mandate_step_backward(
                mandate=mandate,
                rev_role=None,
                state_to=assistant_mandate_state.TRTS)
    elif mandate.state == assistant_mandate_state.VICE_RECTOR:
        make_assistant_mandate_step_backward(
            mandate, reviewer_role.SUPERVISION,
            assistant_mandate_state.SUPERVISION)
    else:
        make_assistant_mandate_step_backward(
            mandate, reviewer_role.VICE_RECTOR,
            assistant_mandate_state.VICE_RECTOR)
    return HttpResponseRedirect(
        reverse('manager_reviews_view', kwargs={'mandate_id': mandate_id}))
Example #18
0
def mandate_change_state(request):
    mandate = assistant_mandate.find_mandate_by_id(request.POST.get("mandate_id"))
    if mandate:
        if 'bt_mandate_accept' in request.POST:
            mandate.state = assistant_mandate_state.TRTS
        elif 'bt_mandate_decline' in request.POST:
            mandate.state = assistant_mandate_state.DECLINED
            faculty = mandate_entity.find_by_mandate_and_type(mandate, entity_type.FACULTY)
            if faculty:
                faculty_dean = reviewer.find_by_entity_and_role(
                    faculty.first().entity, reviewer_role.SUPERVISION).first()
                pers = person.find_by_user(request.user)
                assistant = academic_assistant.find_by_person(pers)
                html_template_ref = 'assistant_dean_assistant_decline_html'
                txt_template_ref = 'assistant_dean_assistant_decline_txt'
                send_message(person=faculty_dean.person, html_template_ref=html_template_ref,
                             txt_template_ref=txt_template_ref, assistant=assistant)
        mandate.save()
    return HttpResponseRedirect(reverse('assistant_mandates'))
Example #19
0
def review_edit(request):
    mandate_id = request.POST.get("mandate_id")
    mandate = assistant_mandate.find_mandate_by_id(mandate_id)
    try:
        review.find_done_by_supervisor_for_mandate(mandate)
        return HttpResponseRedirect(reverse("assistants_home"))
    except:
        existing_review, created = review.Review.objects.get_or_create(
            mandate=mandate, reviewer=None, status=review_status.IN_PROGRESS)
    previous_mandates = assistant_mandate.find_before_year_for_assistant(
        mandate.academic_year.year, mandate.assistant)
    menu = generate_phd_supervisor_menu_tabs(mandate,
                                             reviewer_role.PHD_SUPERVISOR)
    assistant = mandate.assistant
    current_person = request.user.person
    form = ReviewForm(initial={
        'mandate': mandate,
        'reviewer': existing_review.reviewer,
        'status': existing_review.status,
        'advice': existing_review.advice,
        'changed': timezone.now,
        'confidential': existing_review.confidential,
        'remark': existing_review.remark
    },
                      prefix="rev",
                      instance=existing_review)
    return render(
        request, 'review_form.html', {
            'review': existing_review,
            'role': reviewer_role.PHD_SUPERVISOR,
            'year': mandate.academic_year.year + 1,
            'absences': mandate.absences,
            'comment': mandate.comment,
            'mandate_id': mandate.id,
            'previous_mandates': previous_mandates,
            'current_person': current_person,
            'can_validate': True,
            'assistant': assistant,
            'menu': menu,
            'menu_type': 'phd_supervisor_menu',
            'form': form
        })
def review_view(request):
    mandate_id = request.POST.get("mandate_id")
    mandate = assistant_mandate.find_mandate_by_id(mandate_id)
    current_role = reviewer_role.PHD_SUPERVISOR
    try:
        current_review = review.find_done_by_supervisor_for_mandate(mandate)
    except ObjectDoesNotExist:
        current_review = None
    assistant = mandate.assistant
    current_person = request.user.person
    menu = generate_phd_supervisor_menu_tabs(mandate, current_role)
    return render(request, 'review_view.html', {'review': current_review,
                                                'role': current_role,
                                                'menu': menu,
                                                'menu_type': 'phd_supervisor_menu',
                                                'mandate_id': mandate.id,
                                                'mandate_state': mandate.state,
                                                'current_person': current_person,
                                                'assistant': assistant,
                                                'year': mandate.academic_year.year + 1
                                                })
def review_edit(request):
    mandate_id = request.POST.get("mandate_id")
    mandate = assistant_mandate.find_mandate_by_id(mandate_id)
    current_reviewer = reviewer.find_by_person(request.user.person)
    entity = entity_version.get_last_version(current_reviewer.entity)
    delegate_role = current_reviewer.role + "_ASSISTANT"
    existing_review = review.find_review_for_mandate_by_role(mandate, delegate_role)
    if existing_review is None:
        existing_review, created = review.Review.objects.get_or_create(
            mandate=mandate,
            reviewer=current_reviewer,
            status=review_status.IN_PROGRESS
        )
    previous_mandates = assistant_mandate.find_before_year_for_assistant(mandate.academic_year.year, mandate.assistant)
    role = current_reviewer.role
    menu = generate_reviewer_menu_tabs(role, mandate, role)
    assistant = mandate.assistant
    form = ReviewForm(initial={'mandate': mandate,
                               'reviewer': existing_review.reviewer,
                               'status': existing_review.status,
                               'advice': existing_review.advice,
                               'changed': timezone.now,
                               'confidential': existing_review.confidential,
                               'remark': existing_review.remark
                               }, prefix="rev", instance=existing_review)
    return render(request, 'review_form.html', {'review': existing_review,
                                                'role': role,
                                                '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': assistant,
                                                'can_validate': reviewer.can_validate(current_reviewer),
                                                'current_reviewer': current_reviewer,
                                                'entity': entity,
                                                'menu': menu,
                                                'menu_type': 'reviewer_menu',
                                                'form': form})
def mandate_change_state(request):
    mandate_id = request.POST.get("mandate_id")
    mandate = assistant_mandate.find_mandate_by_id(mandate_id)
    if 'bt_mandate_accept' in request.POST:
        mandate.state = assistant_mandate_state.TRTS
    elif 'bt_mandate_decline' in request.POST:
        mandate.state = assistant_mandate_state.DECLINED
        faculty = mandate_entity.find_by_mandate_and_type(
            mandate, entity_type.FACULTY)
        if faculty:
            faculty_dean = reviewer.find_by_entity_and_role(
                faculty.first().structure, reviewer_role.SUPERVISION).first()
            assistant = academic_assistant.find_by_person(
                person.find_by_user(request.user))
            html_template_ref = 'assistant_dean_assistant_decline_html'
            txt_template_ref = 'assistant_dean_assistant_decline_txt'
            send_message(person=faculty_dean.person,
                         html_template_ref=html_template_ref,
                         txt_template_ref=txt_template_ref,
                         assistant=assistant)
    mandate.save()
    return HttpResponseRedirect(reverse('assistant_mandates'))
Example #23
0
def assistant_form_view(request, mandate_id):
    mandate = assistant_mandate.find_mandate_by_id(mandate_id)
    learning_units = tutoring_learning_unit_year.find_by_mandate(mandate)
    phd_files = assistant_document_file.find_by_assistant_mandate_and_description(
        mandate, document_type.PHD_DOCUMENT)
    research_files = assistant_document_file.find_by_assistant_mandate_and_description(
        mandate, document_type.RESEARCH_DOCUMENT)
    tutoring_files = assistant_document_file.find_by_assistant_mandate_and_description(
        mandate, document_type.TUTORING_DOCUMENT)
    return render(
        request, 'manager_assistant_form_view.html', {
            'mandate_id': mandate_id,
            'assistant': mandate.assistant,
            'mandate': mandate,
            'learning_units': learning_units,
            'phd_files': phd_files,
            'assistant_mandate_renewal': assistant_mandate_renewal,
            'research_files': research_files,
            'tutoring_files': tutoring_files,
            'year': mandate.academic_year.year + 1,
            'assistant_type': assistant_type
        })
Example #24
0
def review_view(request):
    mandate_id = request.POST.get("mandate_id")
    mandate = assistant_mandate.find_mandate_by_id(mandate_id)
    current_role = reviewer_role.PHD_SUPERVISOR
    try:
        current_review = review.find_done_by_supervisor_for_mandate(mandate)
    except ObjectDoesNotExist:
        current_review = None
    assistant = mandate.assistant
    current_person = request.user.person
    menu = generate_phd_supervisor_menu_tabs(mandate, current_role)
    return render(
        request, 'review_view.html', {
            'review': current_review,
            'role': current_role,
            'menu': menu,
            'menu_type': 'phd_supervisor_menu',
            'mandate_id': mandate.id,
            'mandate_state': mandate.state,
            'current_person': current_person,
            'assistant': assistant,
            'year': mandate.academic_year.year + 1
        })
def review_edit(request):
    mandate_id = request.POST.get("mandate_id")
    mandate = assistant_mandate.find_mandate_by_id(mandate_id)
    try:
        review.find_done_by_supervisor_for_mandate(mandate)
        return HttpResponseRedirect(reverse("assistants_home"))
    except:
        existing_review, created = review.Review.objects.get_or_create(
            mandate=mandate,
            reviewer=None,
            status=review_status.IN_PROGRESS
        )
    previous_mandates = assistant_mandate.find_before_year_for_assistant(mandate.academic_year.year, mandate.assistant)
    menu = generate_phd_supervisor_menu_tabs(mandate, reviewer_role.PHD_SUPERVISOR)
    assistant = mandate.assistant
    current_person = request.user.person
    form = ReviewForm(initial={'mandate': mandate,
                               'reviewer': existing_review.reviewer,
                               'status': existing_review.status,
                               'advice': existing_review.advice,
                               'changed': timezone.now,
                               'confidential': existing_review.confidential,
                               'remark': existing_review.remark
                               }, prefix="rev", instance=existing_review)
    return render(request, 'review_form.html', {'review': existing_review,
                                                'role': reviewer_role.PHD_SUPERVISOR,
                                                'year': mandate.academic_year.year + 1,
                                                'absences': mandate.absences,
                                                'comment': mandate.comment,
                                                'mandate_id': mandate.id,
                                                'previous_mandates': previous_mandates,
                                                'current_person': current_person,
                                                'can_validate': True,
                                                'assistant': assistant,
                                                'menu': menu,
                                                'menu_type': 'phd_supervisor_menu',
                                                'form': form})
 def test_find_mandate_by_id(self):
     self.assertEqual(self.mandate, assistant_mandate.find_mandate_by_id(self.mandate.id))
     self.mandate.delete()
     self.assertEqual(None, assistant_mandate.find_mandate_by_id(self.mandate.id))
def export_mandate(request):
    mandate_id = request.POST.get("mandate_id")
    mandate = assistant_mandate.find_mandate_by_id(mandate_id)
    return build_doc(request, mandates=[mandate])
Example #28
0
def export_mandate(request):
    mandate_id = request.POST.get("mandate_id")
    mandate = assistant_mandate.find_mandate_by_id(mandate_id)
    return build_doc(request, mandates=[mandate])
def reviews_view(request, mandate_id):
    mandate = assistant_mandate.find_mandate_by_id(mandate_id)
    reviews = review.find_by_mandate(mandate.id)
    return render(request, 'mandate_reviews_view.html', {'reviews': reviews})
Example #30
0
def reviews_view(request, mandate_id):
    mandate = assistant_mandate.find_mandate_by_id(mandate_id)
    reviews = review.find_by_mandate(mandate.id)
    return render(request, 'mandate_reviews_view.html', {'reviews': reviews})
Example #31
0
 def test_find_mandate_by_id(self):
     self.assertEqual(self.mandate, assistant_mandate.find_mandate_by_id(self.mandate.id))