Example #1
0
def download_student_attestation(request, global_id, academic_year,
                                 attestation_type):
    attestation_pdf = student_attestation.fetch_student_attestation(
        global_id, academic_year, attestation_type, request.user)
    if attestation_pdf:
        return _make_pdf_attestation(attestation_pdf, attestation_type)
    else:
        person = person_mdl.find_by_global_id(global_id)
        student = student_mdl.find_by_person(person)
        messages.add_message(request, messages.ERROR,
                             _('error_fetching_attestation'))
        return visualize_student_attestations(request, student.registration_id)
Example #2
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)
    def test_when_attestation_config_items_are_none(self):
        response = fetch_student_attestation(GLOBAL_ID, ACADEMIC_YEAR,
                                             ATTESTATION_TYPE, 'USER_TEST')

        self.assertEqual(response, None)
    def test_when_attestation_config_not_present(self):
        del settings.ATTESTATION_CONFIG
        response = fetch_student_attestation(GLOBAL_ID, ACADEMIC_YEAR,
                                             ATTESTATION_TYPE, 'USER_TEST')

        self.assertEqual(response, None)