Ejemplo n.º 1
0
def exam_enrollment_form(request, offer_year_id):
    try:
        stud = student.find_by_user(request.user)
    except MultipleObjectsReturned:
        return dash_main_view.show_multiple_registration_id_error(request)
    off_year = offer_year.find_by_id(offer_year_id)
    if request.method == 'POST':
        return _process_exam_enrollment_form_submission(off_year, request, stud)
    else:
        return _get_exam_enrollment_form(off_year, request, stud)
Ejemplo n.º 2
0
def result_by_year_and_program(request, anac, program_acronym):
    """
    Display the student result for a particular year and program.
    """
    stud = find_by_user(request.user)
    query_result = mdl.student_performance.select_where_registration_id_is(
        stud.registration_id)
    document = filter_by_anac_and_program_acronym(query_result, anac,
                                                  program_acronym)
    return layout.render(request, "performance_result.html",
                         {"results": document})
Ejemplo n.º 3
0
def home(request):
    """
    Display the academic programs of the student.
    """
    stud = find_by_user(request.user)
    list_student_programs = fetch_student_programs_list(stud)

    return layout.render(request, "performance_home.html", {
        "student": stud,
        "programs": list_student_programs
    })
Ejemplo n.º 4
0
def view_student_resume(request, cohort_id):
    cohort = mdl_internship_cohort.Cohort.objects.get(pk=cohort_id)
    student = mdl_student.find_by_user(request.user)
    internships = mdl_internship.Internship.objects.filter(
        cohort=cohort).order_by('speciality', 'name')

    student_information = mdl_student_information.find_by_user_in_cohort(
        request.user, cohort=cohort)
    periods = mdl_period.Period.objects.filter(cohort=cohort)
    period_ids = periods.values_list("pk", flat=True)
    student_affectations = mdl_student_affectation.InternshipStudentAffectationStat.objects.filter(
        student=student, period_id__in=period_ids).order_by("period__name")
    specialities = mdl_internship_speciality.find_by_cohort(cohort)
    student_choices = mdl_internship_choice.search(student=student,
                                                   specialities=specialities)
    cohort = mdl_internship_cohort.Cohort.objects.get(pk=cohort_id)
    publication_allowed = cohort.publication_start_date <= datetime.date.today(
    )
    offers = {}
    for affectation in student_affectations:
        score = InternshipAPIService.get_affectation(
            person=request.user.person,
            affectation_uuid=str(affectation.uuid)).score
        if score and score.validated:
            score.comments = _replace_comments_keys_with_translations(
                score.comments)
            setattr(affectation, 'score', score)
        offer = mdl_internship_offer.find_offer(
            cohort=cohort,
            speciality=affectation.speciality,
            organization=affectation.organization).first()
        offer.master = _get_internship_masters_repr(request.user.person,
                                                    affectation)
        try:
            offers[affectation.organization].update(
                {affectation.speciality: offer})
        except KeyError:
            offers.update(
                {affectation.organization: {
                    affectation.speciality: offer
                }})
    return layout.render(
        request, "student_resume.html", {
            "student": student,
            "student_information": student_information,
            "student_affectations": student_affectations,
            "student_choices": student_choices,
            "internships": internships,
            "publication_allowed": publication_allowed,
            "cohort": cohort,
            "offers": offers,
            "current_date": date.today(),
            "apds": APDS,
        })
Ejemplo n.º 5
0
def home(request):
    try:
        student = student_mdl.find_by_user(request.user)
    except MultipleObjectsReturned:
        logger.exception('User {} returned multiple students.'.format(request.user.username))
        return dash_main_view.show_multiple_registration_id_error(request)
    if student:
        json_message = _make_registration_json_message(student.registration_id)
        attestation_statuses_json_dict = student_attestation_status.fetch_json_attestation_statuses(json_message)
    else:
        attestation_statuses_json_dict = None
    data = _make_attestation_data(attestation_statuses_json_dict, student)
    return layout.render(request, "attestation_home_student.html", data)
Ejemplo n.º 6
0
def display_result_for_specific_student_performance(request, pk):
    """
    Display the student result for a particular year and program.
    """
    try:
        stud = student.find_by_user(request.user)
    except MultipleObjectsReturned:
        return dash_main_view.show_multiple_registration_id_error(request)
    stud_perf = mdl_performance.student_performance.find_actual_by_pk(pk)
    if not check_right_access(stud_perf, stud):
        raise PermissionDenied

    perf_data = __get_performance_data(stud_perf)
    return layout.render(request, "performance_result_student.html", perf_data)
Ejemplo n.º 7
0
def display_results_by_acronym_and_year(request, acronym, academic_year):
    """
    Display the reslt for a students , filter by acronym
    """
    try:
        stud = student.find_by_user(request.user)
    except MultipleObjectsReturned:
        return dash_main_view.show_multiple_registration_id_error(request)
    cleaned_acronym = _clean_acronym(acronym)
    stud_perf = mdl_performance.student_performance.find_actual_by_student_and_offer_year(
        stud.registration_id, academic_year, cleaned_acronym)
    if not check_right_access(stud_perf, stud):
        raise PermissionDenied
    perf_data = __get_performance_data(stud_perf)

    return layout.render(request, "performance_result_student.html", perf_data)
Ejemplo n.º 8
0
def download_attestation(request, academic_year, attestation_type):
    try:
        student = student_mdl.find_by_user(request.user)
    except MultipleObjectsReturned:
        logger.exception('User {} returned multiple students.'.format(request.user.username))
        return dash_main_view.show_multiple_registration_id_error(request)

    attestation_pdf = student_attestation.fetch_student_attestation(student.person.global_id,
                                                                    academic_year,
                                                                    attestation_type,
                                                                    request.user)

    if attestation_pdf:
        return _make_pdf_attestation(attestation_pdf, attestation_type)
    else:
        messages.add_message(request, messages.ERROR, _('error_fetching_attestation'))
        return home(request)
Ejemplo n.º 9
0
def view_performance_home(request):
    """
    Display the academic programs of the student.
    """
    try:
        stud = student.find_by_user(request.user)
    except MultipleObjectsReturned:
        return dash_main_view.show_multiple_registration_id_error(request)
    list_student_programs = None
    if stud:
        list_student_programs = get_student_programs_list(stud)
    data = {
        "student":
        stud,
        "programs":
        list_student_programs,
        "registration_states_to_show":
        offer_registration_state.STATES_TO_SHOW_ON_PAGE
    }
    return layout.render(request, "performance_home_student.html", data)
Ejemplo n.º 10
0
def display_result_for_specific_student_performance(request, pk):
    """
    Display the student result for a particular year and program.
    """
    stud = student.find_by_user(request.user)
    stud_perf = mdl_performance.student_performance.find_actual_by_pk(pk)
    if not check_right_access(stud_perf, stud):
        raise PermissionDenied
    document = json.dumps(stud_perf.data) if stud_perf else None
    creation_date = stud_perf.creation_date if stud_perf else None
    update_date = stud_perf.update_date if stud_perf else None
    fetch_timed_out = stud_perf.fetch_timed_out if stud_perf else None

    return layout.render(
        request, "performance_result.html", {
            "results": document,
            "creation_date": creation_date,
            "update_date": update_date,
            "fetch_timed_out": fetch_timed_out
        })