Esempio n. 1
0
def applications(request, application_id=None):
    application_list = mdl.application.find_by_user(request.user)
    if application_id:
        application = mdl.application.find_by_id(application_id)
    else:
        # application = mdl.application.init_application(request.user)
        application = None
    applicant = mdl.applicant.find_by_user(request.user)
    person_legal_address = mdl.person_address.find_by_person_type(applicant, 'LEGAL')
    countries = mdl_reference.country.find_all()
    a_domain = None
    a_parent_domain = None
    if application and application.offer_year:
        a_domain = mdl_base.offer_year_domain.find_by_offer_year(application.offer_year)
        a_parent_domain = a_domain.domain.parent
    data = {
        "applications": application_list,
        "grade_choices": enum_institutional_grade_type.INSTITUTIONAL_GRADE_CHOICES,
        "domains": mdl_reference.domain.find_current_domains(),
        'tab_active': navigation.DEMAND_TAB,
        "application": application,
        "local_language_exam_needed": common.is_local_language_exam_needed(request.user),
        "applicant": applicant,
        "person_legal_address": person_legal_address,
        "countries": countries,
        "domain": a_domain,
        "parent_domain": a_parent_domain
    }
    data.update(demande_validation.get_validation_status(application, applicant))
    return render(request, "admission_home.html", data)
Esempio n. 2
0
def update(request, application_id=None):
    application = mdl.application.find_by_id(application_id)
    past_attachments = list_attachments(application)
    UploadDocumentFileFormSet = formset_factory(UploadDocumentFileForm,
                                                extra=0)
    document_formset = UploadDocumentFileFormSet()
    applicant = mdl.applicant.find_by_user(request.user)
    remove_attachment_form = RemoveAttachmentForm()
    list_choices = [x[1] for x in document_type.DOCUMENT_TYPE_CHOICES]
    data = {
        "tab_active": navigation.ATTACHMENTS_TAB,
        "application": application,
        "applications": mdl.application.find_by_user(request.user),
        "document_formset": document_formset,
        "attachments": past_attachments,
        "removeAttachmentForm": remove_attachment_form,
        "list_choices": list_choices
    }
    data.update(
        demande_validation.get_validation_status(application, applicant))
    letter_motivation_doc_present = False
    curriculum_doc_present = False

    if application.application_type == application_type.ADMISSION:
        for p in past_attachments:
            if p.description == 'letter_motivation':
                letter_motivation_doc_present = True
            if p.description == 'curriculum':
                curriculum_doc_present = True
    data.update({
        'letter_motivation_doc_present': letter_motivation_doc_present,
        'curriculum_doc_present': curriculum_doc_present
    })
    return render(request, "admission_home.html", data)
Esempio n. 3
0
def update(request, application_id=None):
    application = mdl.application.find_by_id(application_id)
    past_attachments = list_attachments(application)
    UploadDocumentFileFormSet = formset_factory(UploadDocumentFileForm, extra=0)
    document_formset = UploadDocumentFileFormSet()
    applicant = mdl.applicant.find_by_user(request.user)
    remove_attachment_form = RemoveAttachmentForm()
    list_choices = [x[1] for x in document_type.DOCUMENT_TYPE_CHOICES]
    data = {
        "tab_active": navigation.ATTACHMENTS_TAB,
        "application": application,
        "applications": mdl.application.find_by_user(request.user),
        "document_formset": document_formset,
        "attachments": past_attachments,
        "removeAttachmentForm": remove_attachment_form,
        "list_choices": list_choices
    }
    data.update(demande_validation.get_validation_status(application, applicant))
    letter_motivation_doc_present = False
    curriculum_doc_present = False

    if application.application_type ==  application_type.ADMISSION:
        for p in past_attachments:
            if p.description == 'letter_motivation':
                letter_motivation_doc_present=True
            if p.description == 'curriculum':
                curriculum_doc_present=True
    data.update({'letter_motivation_doc_present': letter_motivation_doc_present,
                 'curriculum_doc_present': curriculum_doc_present})
    return render(request, "admission_home.html", data)
Esempio n. 4
0
def accounting(request, application_id=None):
    if application_id:
        application = mdl.application.find_by_id(application_id)
    else:
        application = mdl.application.init_application(request.user)
    academic_yr = mdl_base.academic_year.current_academic_year()
    previous_academic_year = mdl_base.academic_year.find_by_year(academic_yr.year - 1)
    sport_affiliation_amount = 0
    culture_affiliation_amount = 0
    solidary_affiliation_amount = 0
    applicant = mdl.applicant.find_by_user(request.user)

    data = {
        "academic_year": academic_yr,
        "previous_academic_year": previous_academic_year,
        "sport_affiliation_amount": sport_affiliation_amount,
        "culture_affiliation_amount": culture_affiliation_amount,
        "solidary_affiliation_amount": solidary_affiliation_amount,
        "application": application,
        "debts_check": debts_check(application),
        "reduction_possible": reduction_possible(application),
        "third_cycle": third_cycle(application),
        "tab_active": navigation.ACCOUNTING_TAB,
        "applications": mdl.application.find_by_user(request.user),
    }
    data.update(demande_validation.get_validation_status(application, applicant))
    return render(request, "admission_home.html", data)
def get_prerequis_data(request, saved, application_id):
    message_info = ""
    if saved:
        message_info = _('msg_info_saved')

    if application_id:
        application = mdl.application.find_by_id(application_id)
    else:
        application = mdl.application.find_first_by_user(request.user)
    applicant = mdl.applicant.find_by_user(request.user)
    other_language_regime = mdl_reference.language.find_unrecognized_languages()
    recognized_languages = mdl_reference.language.find_recognized_languages()
    exam_types = mdl.admission_exam_type.find_all_by_adhoc(False)
    secondary_education = mdl.secondary_education.find_by_person(applicant)
    education_type_transition = mdl_reference.education_type.find_education_type_by_adhoc('TRANSITION', False)
    education_type_qualification = mdl_reference.education_type.find_education_type_by_adhoc('QUALIFICATION', False)
    local_language_exam_link = mdl.properties.find_by_key('PROFESSIONAL_EXAM_LINK')
    professional_exam_link = mdl.properties.find_by_key('LOCAL_LANGUAGE_EXAM_LINK')
    countries = mdl_reference.country.find_excluding("BE")
    current_academic_year = mdl_base.academic_year.current_academic_year()
    academic_years = []
    if current_academic_year:
        upper_bound = current_academic_year.year
        low_bound = upper_bound - NB_YEARS_AVAILABLE_FOR_DIPLOMA_ACQUISITION
        year_cpt = low_bound
        while year_cpt <= upper_bound:
            academic_years.append(year_cpt)
            year_cpt = year_cpt + 1
    current_year = None
    if current_academic_year:
        current_year = current_academic_year.year
    data = {"application":                  application,
            "academic_years":               academic_years,
            "secondary_education":          secondary_education,
            "countries":                    countries,
            "recognized_languages":         recognized_languages,
            "languages":                    other_language_regime,
            "exam_types":                   exam_types,
            'local_language_exam_link':     local_language_exam_link,
            "professional_exam_link":       professional_exam_link,
            "education_type_transition":    education_type_transition,
            "education_type_qualification": education_type_qualification,
            "current_academic_year":        current_year,
            "local_language_exam_needed":   common.is_local_language_exam_needed(request.user),
            'tab_active':                   navigation.PREREQUISITES_TAB,
            'applications':                 mdl.application.find_by_user(request.user),
            'message_info':                 message_info}
    # merge dictionaries
    data.update(get_secondary_education_exams(secondary_education))
    data.update(get_secondary_education_files(application))
    data.update(demande_validation.get_validation_status(application, applicant))
    return data
Esempio n. 6
0
def submission(request, application_id=None):
    if application_id:
        application = mdl.application.find_by_id(application_id)
    else:
        application = mdl.application.init_application(request.user)
    data = {
        'application': application,
        'display_admission_exam': extra_information(application),
        'tab_active': navigation.SUBMISSION_TAB,
        'applications': mdl.application.find_by_user(request.user)
    }
    applicant = mdl.applicant.find_by_user(request.user)
    data.update(demande_validation.get_validation_status(application, applicant))
    return render(request, "admission_home.html", data)
Esempio n. 7
0
def change_application_offer(request, application_id=None):
    application = mdl.application.find_by_id(application_id)
    application.application_type = mdl.application.define_application_type(application.coverage_access_degree,
                                                                           request.user)
    application.save()
    application_list = mdl.application.find_by_user(request.user)
    applicant = mdl.applicant.find_by_user(request.user)
    data = {
        'applications': application_list,
        "grade_choices": enum_institutional_grade_type.INSTITUTIONAL_GRADE_CHOICES,
        "domains": mdl_reference.domain.find_current_domains(),
        'tab_active': navigation.DEMAND_TAB,
        "first": True,
        "application": application,
    }
    data.update(demande_validation.get_validation_status(application, applicant))
    return render(request, "admission_home.html", data)
Esempio n. 8
0
def update(request, application_id=None):
    """
    Sociological survey of an applicant.
    :param request
    :param application_id
    """
    applicant = mdl.applicant.find_by_user(request.user)
    if application_id:
        application = mdl.application.find_by_id(application_id)
    else:
        application = mdl.application.init_application(request.user)
    next_tab = navigation.SOCIOLOGICAL_SURVEY_TAB
    sociological_survey = sociological_survey_mdl.find_by_applicant(applicant)
    if request.method == "POST":
        sociological_form = SociologicalSurveyForm(request.POST)
        if sociological_form.is_valid():
            sociological_form.save(applicant=applicant)
            sociological_survey = sociological_survey_mdl.find_by_applicant(
                applicant)
            following_tab = navigation.get_following_tab(
                request, 'sociological', application)
            if following_tab:
                return following_tab
            else:
                sociological_form = SociologicalSurveyForm(
                    instance=sociological_survey)
    elif sociological_survey:
        sociological_form = SociologicalSurveyForm(
            instance=sociological_survey)
    else:
        sociological_form = SociologicalSurveyForm()

    data = {
        'tab_active': next_tab,
        'application': application,
        'applications': mdl.application.find_by_user(request.user),
        'sociological_form': sociological_form,
        'professions': mdl.profession.find_by_adoc(False),
        'sociological_survey': sociological_survey
    }
    data.update(
        demande_validation.get_validation_status(application, applicant))
    return render(request, "admission_home.html", data)
Esempio n. 9
0
def accounting_update(request, application_id=None):
    next_tab = navigation.ACCOUNTING_TAB
    academic_yr = mdl_base.academic_year.current_academic_year()
    previous_academic_year = mdl_base.academic_year.find_by_year(academic_yr.year - 1)
    sport_affiliation_amount = 0
    culture_affiliation_amount = 0
    solidary_affiliation_amount = 0
    accounting_form = None
    if request.method == 'POST':
        accounting_form = AccountingForm(data=request.POST)

    if application_id:
        application = mdl.application.find_by_id(application_id)
    else:
        application = mdl.application.init_application(request.user)

    try:
        if application.offer_year and application.applicant:
            application.save()
    except:
        pass
    following_tab = navigation.get_following_tab(request, 'accounting', application)
    if following_tab:
        return following_tab
    data = {
        "academic_year": academic_yr,
        "previous_academic_year": previous_academic_year,
        "sport_affiliation_amount": sport_affiliation_amount,
        "culture_affiliation_amount": culture_affiliation_amount,
        "solidary_affiliation_amount": solidary_affiliation_amount,
        "application": application,
        "form": accounting_form,
        "debts_check": debts_check(application),
        "reduction_possible": reduction_possible(application),
        "third_cycle": third_cycle(application),
        "tab_active": next_tab,
        "applications": mdl.application.find_by_user(request.user),
    }
    applicant = mdl.applicant.find_by_user(request.user)
    data.update(demande_validation.get_validation_status(application, applicant))
    return render(request, "admission_home.html", data)
Esempio n. 10
0
def update(request, application_id=None):
    """
    Sociological survey of an applicant.
    :param request
    :param application_id
    """
    applicant = mdl.applicant.find_by_user(request.user)
    if application_id:
        application = mdl.application.find_by_id(application_id)
    else:
        application = mdl.application.init_application(request.user)
    next_tab = navigation.SOCIOLOGICAL_SURVEY_TAB
    sociological_survey = sociological_survey_mdl.find_by_applicant(applicant)
    if request.method == "POST":
        sociological_form = SociologicalSurveyForm(request.POST)
        if sociological_form.is_valid():
            sociological_form.save(applicant=applicant)
            sociological_survey = sociological_survey_mdl.find_by_applicant(applicant)
            following_tab = navigation.get_following_tab(request, 'sociological', application)
            if following_tab:
                return following_tab
            else:
                sociological_form = SociologicalSurveyForm(instance=sociological_survey)
    elif sociological_survey:
        sociological_form = SociologicalSurveyForm(instance=sociological_survey)
    else:
        sociological_form = SociologicalSurveyForm()

    data = {
        'tab_active': next_tab,
        'application': application,
        'applications': mdl.application.find_by_user(request.user),
        'sociological_form': sociological_form,
        'professions': mdl.profession.find_by_adoc(False),
        'sociological_survey': sociological_survey
    }
    data.update(demande_validation.get_validation_status(application, applicant))
    return render(request, "admission_home.html", data)
Esempio n. 11
0
def save_application_offer(request):
    next_tab = None
    application = None

    if request.method == 'POST':
        next_tab = request.POST.get('next_tab')

        offer_year_id = request.POST.get('offer_year_id', None)
        application_id = request.POST.get('application_id', None)

        if application_id:
            application = get_object_or_404(mdl.application.Application, pk=application_id)
            secondary_education = mdl.secondary_education.find_by_person(application.applicant)
        else:
            application = mdl.application.init_application(request.user)
            applicant = mdl.applicant.find_by_user(request.user)
            application.applicant = applicant
            secondary_education = mdl.secondary_education.SecondaryEducation()
            secondary_education.applicant = application.applicant

        if secondary_education and secondary_education.academic_year is None:
            secondary_education.academic_year = mdl_base.academic_year.current_academic_year()

        if offer_year_id:
            offer_year = mdl_base.offer_year.find_by_id(offer_year_id)
            application.offer_year = offer_year

        if request.POST.get('national_coverage_degree'):
            if request.POST.get('national_coverage_degree') == "true":
                application.coverage_access_degree = coverage_access_degree_choices.NATIONAL
            else:
                application.coverage_access_degree = coverage_access_degree_choices.NON_NATIONAL

        if request.POST.get('valuation_possible'):
            if request.POST.get('valuation_possible') == "true":
                application.valuation_possible = True
            else:
                application.valuation_possible = False
        if request.POST.get('rdb_offer_samestudies'):
            if request.POST.get('rdb_offer_samestudies') == "true":
                application.started_similar_studies = True
            else:
                application.started_similar_studies = False
        if request.POST.get('rdb_offer_valuecredits'):
            if request.POST.get('rdb_offer_valuecredits') == "true":
                application.credits_to_value = True
            else:
                application.credits_to_value = False
        if request.POST.get('rdb_offer_sameprogram'):
            if request.POST.get('rdb_offer_sameprogram') == "true":
                application.applied_to_sameprogram = True
            else:
                application.resident = False
        if request.POST.get('rdb_offer_resident'):
            if request.POST.get('rdb_offer_resident') == "true":
                application.resident = True
            else:
                application.resident = False
        if request.POST.get('txt_offer_lottery'):
            application.raffle_number = request.POST.get('txt_offer_lottery')
        application.application_type = mdl.application.define_application_type(application.coverage_access_degree,
                                                                               request.user)
        if offer_year_id:
            application.save()
        delete_application_assimilation_criteria(application)

        if application.id:
            create_application_assimilation_criteria(application)
            delete_existing_answers(application)
            create_answers(application, request)
    applicant = mdl.applicant.find_by_user(request.user)

    if next_tab:
        return navigation.get_redirection(next_tab, application.id)

    data = {
        'tab_active': next_tab,
        'application': application,
        'picture': get_picture_id(request.user),
        'id_document': get_id_document(request.user),
        'applicant': applicant
    }
    data.update(demande_validation.get_validation_status(application, applicant))
    return render(request, "admission_home.html", data)
Esempio n. 12
0
def update(request, application_id=None):
    if application_id:
        application = mdl.application.find_by_id(application_id)
    else:
        application = mdl.application.init_application(request.user)
    curricula = []
    message = None
    applicant = mdl.applicant.find_by_user(request.user)
    secondary_education = mdl.secondary_education.find_by_person(applicant)
    current_academic_year = None
    if mdl_base.academic_year.current_academic_year():
        current_academic_year = mdl_base.academic_year.current_academic_year().year
    admission = is_admission(applicant, secondary_education)
    year_secondary = None
    year = None
    if current_academic_year:
        year = current_academic_year - CURRICULUM_YEARS_REQUIRED
    if secondary_education is None:
        pass
    else:
        if secondary_education and secondary_education.diploma is True and secondary_education.academic_year:
            year_secondary = secondary_education.academic_year

    if admission:
        if secondary_education and secondary_education.diploma is True and secondary_education.academic_year:
            year = secondary_education.academic_year + 1

    if year_secondary and year and year < year_secondary:
        year = year_secondary + 1
    if year and current_academic_year:
        while year < current_academic_year:
            # find existing cv
            curriculum = mdl.curriculum.find_by_person_year(applicant, year)
            if curriculum is None:
                # add cv empty cv's for the year if it's needed
                curriculum = mdl.curriculum.Curriculum()
                curriculum.person = applicant
                curriculum.academic_year = year
            curricula.append(curriculum)
            year = year + 1
    local_universities_french = mdl_reference.education_institution \
        .find_by_institution_type_national_community(education_institution_type.UNIVERSITY,
                                                     national_cmunity_type.FRENCH,
                                                     False)

    local_universities_dutch = mdl_reference.education_institution \
        .find_by_institution_type_national_community(education_institution_type.UNIVERSITY,
                                                     national_cmunity_type.DUTCH,
                                                     False)
    if message:
        return common.home(request)
    else:
        universities_cities, universities = populate_dropdown_list(curricula)

        data = {
            "curricula": curricula,
            "local_universities_french": local_universities_french,
            "local_universities_dutch": local_universities_dutch,
            "domains": mdl_reference.domain.find_current_domains(),
            "subdomains": mdl_reference.domain.find_parent_domains(),
            "grade_types": mdl_reference.grade_type.find_all(),
            "universities_countries": mdl_reference.education_institution.find_countries(),
            "universities_cities": universities_cities,
            "universities": universities,
            "languages": mdl_reference.language.find_languages(),
            "current_academic_year": mdl_base.academic_year.current_academic_year(),
            "tab_active": navigation.CURRICULUM_TAB,
            "application": application,
            'applications': mdl.application.find_by_user(request.user)
        }
        data.update(demande_validation.get_validation_status(application, applicant))
        return render(request, "admission_home.html", data)
Esempio n. 13
0
def profile(request, application_id=None, message_success=None):
    message_info = None
    application = None
    assimilation_case = False

    if application_id:
        application = mdl.application.find_by_id(application_id)
    if request.method == 'POST':
        applicant_form = ApplicantForm(data=request.POST)
        applicant = mdl.applicant.find_by_user(request.user)
        person_legal_address = mdl.person_address.find_by_person_type(
            applicant, 'LEGAL')

        if person_legal_address is None:
            person_legal_address = mdl.person_address.PersonAddress()
            person_legal_address.person = applicant
            person_legal_address.type = 'LEGAL'

        if request.POST['last_name']:
            applicant.user.last_name = request.POST['last_name']
        else:
            applicant.user.last_name = None
        if request.POST['first_name']:
            applicant.user.first_name = request.POST['first_name']
        else:
            applicant.user.first_name = None
        if request.POST['middle_name']:
            applicant.middle_name = request.POST['middle_name']
        else:
            applicant.middle_name = None
        if request.POST['birth_date']:
            try:
                applicant.birth_date = datetime.strptime(
                    request.POST['birth_date'], '%d/%m/%Y')
            except ValueError:
                applicant.birth_date = None
                applicant_form.errors[
                    'birth_date'] = "La date encodée('%s') semble incorrecte " % request.POST[
                        'birth_date']
        else:
            applicant.birth_date = None
        if request.POST['birth_place']:
            applicant.birth_place = request.POST['birth_place']
        else:
            applicant.birth_place = None
        if request.POST.get('birth_country'):
            birth_country_id = request.POST['birth_country']
            if birth_country_id and int(birth_country_id) >= 0:
                birth_country = mdl_ref.country.find_by_id(birth_country_id)
            else:
                birth_country = None
            applicant.birth_country = birth_country
        else:
            applicant.birth_country = None
        if request.POST.get('gender'):
            applicant.gender = request.POST['gender']
        else:
            applicant.gender = None
        if request.POST['civil_status']:
            applicant.civil_status = request.POST['civil_status']
        else:
            applicant.civil_status = None
        if request.POST['number_children']:
            applicant.number_children = request.POST['number_children']
        else:
            applicant.number_children = None
        if request.POST['spouse_name']:
            applicant.spouse_name = request.POST['spouse_name']
        else:
            applicant.spouse_name = None
        if request.POST.get(
                'nationality') and not request.POST.get('nationality') == "-1":
            country_id = request.POST['nationality']
            if country_id and int(country_id) >= 0:
                country = mdl_ref.country.find_by_id(country_id)
            else:
                country = None
            if country:
                if not country.european_union:
                    assimilation_case = True
            applicant.nationality = country
        else:
            applicant.nationality = None
        if request.POST['national_id']:
            applicant.national_id = request.POST['national_id']
        else:
            applicant.national_id = None
        if request.POST['id_card_number']:
            applicant.id_card_number = request.POST['id_card_number']
        else:
            applicant.id_card_number = None
        if request.POST['passport_number']:
            applicant.passport_number = request.POST['passport_number']
        else:
            applicant.passport_number = None
        if request.POST['legal_adr_street']:
            person_legal_address.street = request.POST['legal_adr_street']
        else:
            person_legal_address.street = ''
        if request.POST['legal_adr_number']:
            person_legal_address.number = request.POST['legal_adr_number']
        else:
            person_legal_address.number = ''
        if request.POST['legal_adr_complement']:
            person_legal_address.complement = request.POST[
                'legal_adr_complement']
        else:
            person_legal_address.complement = None
        if request.POST['legal_adr_postal_code']:
            person_legal_address.postal_code = request.POST[
                'legal_adr_postal_code']
        else:
            person_legal_address.postal_code = ''
        if request.POST['legal_adr_city']:
            person_legal_address.city = request.POST['legal_adr_city']
        else:
            person_legal_address.city = ''

        if request.POST.get('legal_adr_country') and not request.POST.get(
                'legal_adr_country') == "-1":
            country_id = request.POST['legal_adr_country']
            country = None
            if country_id and int(country_id) >= 0:
                country = mdl_ref.country.find_by_id(country_id)
            person_legal_address.country = country
        else:
            applicant_form.errors['legal_adr_country'] = _('mandatory_field')

        if request.POST.get('same_contact_legal_addr') == "false":
            person_contact_address = mdl.person_address.find_by_person_type(
                applicant, 'CONTACT')
            if person_contact_address is None:
                person_contact_address = mdl.person_address.PersonAddress()
                person_contact_address.person = applicant
                person_contact_address.type = 'CONTACT'

            if request.POST['contact_adr_street']:
                person_contact_address.street = request.POST[
                    'contact_adr_street']
            else:
                person_contact_address.street = None
            if request.POST['contact_adr_number']:
                person_contact_address.number = request.POST[
                    'contact_adr_number']
            else:
                person_contact_address.number = None
            if request.POST['contact_adr_complement']:
                person_contact_address.complement = request.POST[
                    'contact_adr_complement']
            else:
                person_contact_address.complement = None
            if request.POST['contact_adr_postal_code']:
                person_contact_address.postal_code = request.POST[
                    'contact_adr_postal_code']
            else:
                person_contact_address.postal_code = None
            if request.POST['contact_adr_city']:
                person_contact_address.city = request.POST['contact_adr_city']
            else:
                person_contact_address.city = None
            if request.POST['contact_adr_country']:
                country_id = request.POST['contact_adr_country']
                country = None
                if country_id and int(country_id) >= 0:
                    country = mdl_ref.country.find_by_id(country_id)
                if country:
                    person_contact_address.country = country
            else:
                person_contact_address.country = None
            same_addresses = False
            person_contact_address.save()
        else:
            same_addresses = True
            person_contact_address = mdl.person_address.find_by_person_type(
                applicant, 'CONTACT')
            if person_contact_address:
                person_contact_address.delete()
                person_contact_address = None

        if request.POST['phone_mobile']:
            applicant.phone_mobile = request.POST['phone_mobile']
        if request.POST['phone']:
            applicant.phone = request.POST['phone']
        else:
            applicant.phone = None

        if request.POST['previous_enrollment'] == "true":
            if request.POST['registration_id']:
                applicant.registration_id = request.POST['registration_id']
            else:
                applicant.registration_id = None
            if request.POST['last_academic_year']:
                applicant.last_academic_year = request.POST[
                    'last_academic_year']
            else:
                applicant.last_academic_year = None
            previous_enrollment = True
        else:
            applicant.registration_id = None
            applicant.last_academic_year = None
            previous_enrollment = False
        if assimilation_case:
            # verify if it exists one record per criteria
            default_criteria_list = assimilation_criteria_enum.ASSIMILATION_CRITERIA_CHOICES
            for criteria in default_criteria_list:
                crit = criteria[0]
                existing_crit = mdl.applicant_assimilation_criteria.find_first(
                    applicant, crit)
                if existing_crit is None:
                    applicant_assimilation_criteria = \
                                    mdl.applicant_assimilation_criteria.ApplicantAssimilationCriteria()
                    applicant_assimilation_criteria.criteria = crit
                    applicant_assimilation_criteria.applicant = applicant
                    applicant_assimilation_criteria.additional_criteria = None
                    applicant_assimilation_criteria.selected = None
                    applicant_assimilation_criteria.save()
                if application:
                    application_assimilation_criteria = mdl.application_assimilation_criteria.find_first(
                        application, crit)
                    if application_assimilation_criteria is None:
                        application_assimilation_criteria = \
                            mdl.application_assimilation_criteria.ApplicationAssimilationCriteria()
                        application_assimilation_criteria.criteria = crit
                        application_assimilation_criteria.application = application
                        application_assimilation_criteria.additional_criteria = None
                        application_assimilation_criteria.selected = None
                        application_assimilation_criteria.save()

            for key in request.POST:
                if key[0:len(RADIO_NAME_ASSIMILATION_CRITERIA
                             )] == RADIO_NAME_ASSIMILATION_CRITERIA:
                    criteria_id = key[len(RADIO_NAME_ASSIMILATION_CRITERIA):]
                    criteria_ref = assimilation_criteria_enum.find(criteria_id)
                    criteria = criteria_ref[0]
                    applicant_assimilation_criteria = mdl.applicant_assimilation_criteria.find_first(
                        applicant, criteria)
                    if applicant_assimilation_criteria is None:
                        applicant_assimilation_criteria = mdl.applicant_assimilation_criteria\
                            .ApplicantAssimilationCriteria()
                        applicant_assimilation_criteria.criteria = criteria
                        applicant_assimilation_criteria.applicant = applicant
                    if request.POST[key] == "true":
                        if criteria:
                            assimilation_basic_documents = assimilation_criteria_view.\
                                find_list_assimilation_basic_documents()
                            list_document_type_needed = assimilation_criteria_view.\
                                get_list_documents_descriptions(criteria)
                            list_document_type_needed.append(
                                document_type.ID_CARD)

                            if criteria == assimilation_criteria_enum.CRITERIA_5:
                                if request.POST.get(
                                        "criteria_5"
                                ) == assimilation_criteria_enum.CRITERIA_1:
                                    list_document_type_needed.extend([
                                        document_type.RESIDENT_LONG_DURATION,
                                        document_type.ID_FOREIGN_UNLIMITED
                                    ])
                                if request.POST.get(
                                        "criteria_5"
                                ) == assimilation_criteria_enum.CRITERIA_2:
                                    list_document_type_needed.extend([
                                        document_type.ATTACHMENT_26,
                                        document_type.REFUGEE_CARD,
                                        document_type.FAMILY_COMPOSITION,
                                        document_type.BIRTH_CERTIFICATE,
                                        document_type.REFUGEE_CARD,
                                        document_type.RESIDENT_CERTIFICATE,
                                        document_type.
                                        FOREIGN_INSCRIPTION_CERTIFICATE,
                                        document_type.
                                        SUBSIDIARY_PROTECTION_DECISION,
                                        document_type.RESIDENCE_PERMIT,
                                        document_type.STATELESS_CERTIFICATE
                                    ])
                                if request.POST.get(
                                        "criteria_5"
                                ) == assimilation_criteria_enum.CRITERIA_3:
                                    list_document_type_needed.extend([
                                        document_type.FAMILY_COMPOSITION,
                                        document_type.PAYCHECK_1,
                                        document_type.PAYCHECK_2,
                                        document_type.PAYCHECK_3,
                                        document_type.PAYCHECK_4,
                                        document_type.PAYCHECK_5,
                                        document_type.PAYCHECK_6,
                                        document_type.RESIDENT_CERTIFICATE,
                                        document_type.ID_CARD
                                    ])
                                if request.POST.get(
                                        "criteria_5"
                                ) == assimilation_criteria_enum.CRITERIA_4:
                                    list_document_type_needed.extend(
                                        [document_type.CPAS])

                            for basic_doc_description in assimilation_basic_documents:
                                if basic_doc_description not in list_document_type_needed:
                                    app_doc_files = mdl.applicant_document_file.\
                                        find_by_applicant_and_description(applicant, basic_doc_description)
                                    for app_doc_file in app_doc_files:
                                        # delete unnecessary documents
                                        app_doc_file.document_file.delete()

                            applicant_assimilation_criteria.additional_criteria = \
                                define_additional_criteria(request.POST.get("criteria_5"))
                            applicant_assimilation_criteria.selected = True
                            applicant_assimilation_criteria.save()

                            # Update/create application_assimilation_criteria
                            if application:
                                application_assimilation_criteria = mdl.application_assimilation_criteria.\
                                    find_first(application, criteria)
                                application_assimilation_criteria.criteria = criteria
                                if applicant_assimilation_criteria.additional_criteria:
                                    application_assimilation_criteria.additional_criteria = \
                                        applicant_assimilation_criteria.additional_criteria
                                application_assimilation_criteria.selected = True
                                application_assimilation_criteria.save()

                    if request.POST[key] == "false":
                        applicant_assimilation_criteria.selected = False
                        applicant_assimilation_criteria.save()
                        # Update/create application_assimilation_criteria
                        if application:
                            application_assimilation_criteria = mdl.application_assimilation_criteria.\
                                find_first(application, criteria)
                            application_assimilation_criteria.criteria = criteria
                            if applicant_assimilation_criteria.additional_criteria:
                                application_assimilation_criteria.additional_criteria = \
                                    applicant_assimilation_criteria.additional_criteria
                            application_assimilation_criteria.selected = False
                            application_assimilation_criteria.save()

        else:
            # cleanup the database if needed
            delete_previous_criteria(applicant, application)
        message_success = None

        if person_contact_address:
            person_contact_address.save()
        person_legal_address.save()
        applicant.user.save()
        if application:
            application.application_type = mdl.application.define_application_type(
                application.coverage_access_degree, request.user)
            application.save()
        request.user = applicant.user  # Otherwise it was not refreshed while going back to home page
        applicant.save()
        message_info = _('msg_info_saved')

        following_tab = navigation.get_following_tab(request, 'profile',
                                                     application)
        if following_tab:
            return following_tab
    else:
        applicant = mdl.applicant.find_by_user(request.user)
        applicant_form = ApplicantForm()
        if applicant:
            person_contact_address = mdl.person_address.find_by_person_type(
                applicant, 'CONTACT')
            same_addresses = True
            if person_contact_address:
                same_addresses = False

            previous_enrollment = False
            if applicant.registration_id or applicant.last_academic_year:
                previous_enrollment = True
        else:
            return HttpResponseRedirect('/admission/logout')

    countries = mdl_ref.country.find_all()
    props = mdl.properties.find_by_key('INSTITUTION')
    if props:
        institution_name = props.value
    else:
        institution_name = None

    assimilation_criteria = assimilation_criteria_enum.ASSIMILATION_CRITERIA_CHOICES
    applicant_assimilation_criteria = mdl.applicant_assimilation_criteria.find_by_applicant(
        applicant.id)

    # validated are not ready yet, to be achieved in another issue - Leila
    person_legal_address = mdl.person_address.find_by_person_type(
        applicant, 'LEGAL')
    person_contact_address = mdl.person_address.find_by_person_type(
        applicant, 'CONTACT')

    document_formset = UploadDocumentFileForm()
    data = {
        'applicant':
        applicant,
        'applicant_form':
        applicant_form,
        'countries':
        countries,
        'assimilation_criteria':
        assimilation_criteria,
        'applicant_assimilation_criteria':
        applicant_assimilation_criteria,
        'person_legal_address':
        person_legal_address,
        'person_contact_address':
        person_contact_address,
        'same_addresses':
        same_addresses,
        'previous_enrollment':
        previous_enrollment,
        'institution':
        institution_name,
        'message_success':
        message_success,
        'tab_active':
        navigation.PROFILE_TAB,
        'application':
        application,
        'applications':
        mdl.application.find_by_user(request.user),
        'picture':
        get_picture_id(request.user),
        'id_document':
        get_id_document(request.user),
        'assimilation_basic_documents':
        assimilation_criteria_view.find_assimilation_basic_documents(),
        'assimilation_documents_existing':
        get_assimilation_documents_existing(request.user),
        'document_formset':
        document_formset,
        'message_info':
        message_info
    }
    data.update(
        demande_validation.get_validation_status(application, applicant))
    return render(request, "admission_home.html", data)
Esempio n. 14
0
def update(request, application_id=None):
    if application_id:
        application = mdl.application.find_by_id(application_id)
    else:
        application = mdl.application.init_application(request.user)
    curricula = []
    message = None
    applicant = mdl.applicant.find_by_user(request.user)
    secondary_education = mdl.secondary_education.find_by_person(applicant)
    current_academic_year = None
    if mdl_base.academic_year.current_academic_year():
        current_academic_year = mdl_base.academic_year.current_academic_year(
        ).year
    admission = is_admission(applicant, secondary_education)
    year_secondary = None
    year = None
    if current_academic_year:
        year = current_academic_year - CURRICULUM_YEARS_REQUIRED
    if secondary_education is None:
        pass
    else:
        if secondary_education and secondary_education.diploma is True and secondary_education.academic_year:
            year_secondary = secondary_education.academic_year

    if admission:
        if secondary_education and secondary_education.diploma is True and secondary_education.academic_year:
            year = secondary_education.academic_year + 1

    if year_secondary and year and year < year_secondary:
        year = year_secondary + 1
    if year and current_academic_year:
        while year < current_academic_year:
            # find existing cv
            curriculum = mdl.curriculum.find_by_person_year(applicant, year)
            if curriculum is None:
                # add cv empty cv's for the year if it's needed
                curriculum = mdl.curriculum.Curriculum()
                curriculum.person = applicant
                curriculum.academic_year = year
            curricula.append(curriculum)
            year = year + 1
    local_universities_french = mdl_reference.education_institution \
        .find_by_institution_type_national_community(education_institution_type.UNIVERSITY,
                                                     national_cmunity_type.FRENCH,
                                                     False)

    local_universities_dutch = mdl_reference.education_institution \
        .find_by_institution_type_national_community(education_institution_type.UNIVERSITY,
                                                     national_cmunity_type.DUTCH,
                                                     False)
    if message:
        return common.home(request)
    else:
        universities_cities, universities = populate_dropdown_list(curricula)

        data = {
            "curricula":
            curricula,
            "local_universities_french":
            local_universities_french,
            "local_universities_dutch":
            local_universities_dutch,
            "domains":
            mdl_reference.domain.find_current_domains(),
            "subdomains":
            mdl_reference.domain.find_parent_domains(),
            "grade_types":
            mdl_reference.grade_type.find_all(),
            "universities_countries":
            mdl_reference.education_institution.find_countries(),
            "universities_cities":
            universities_cities,
            "universities":
            universities,
            "languages":
            mdl_reference.language.find_languages(),
            "current_academic_year":
            mdl_base.academic_year.current_academic_year(),
            "tab_active":
            navigation.CURRICULUM_TAB,
            "application":
            application,
            'applications':
            mdl.application.find_by_user(request.user)
        }
        data.update(
            demande_validation.get_validation_status(application, applicant))
        return render(request, "admission_home.html", data)
Esempio n. 15
0
def profile(request, application_id=None, message_success=None):
    message_info = None
    application = None
    assimilation_case = False

    if application_id:
        application = mdl.application.find_by_id(application_id)
    if request.method == 'POST':
        applicant_form = ApplicantForm(data=request.POST)
        applicant = mdl.applicant.find_by_user(request.user)
        person_legal_address = mdl.person_address.find_by_person_type(applicant, 'LEGAL')

        if person_legal_address is None:
            person_legal_address = mdl.person_address.PersonAddress()
            person_legal_address.person = applicant
            person_legal_address.type = 'LEGAL'

        if request.POST['last_name']:
            applicant.user.last_name = request.POST['last_name']
        else:
            applicant.user.last_name = None
        if request.POST['first_name']:
            applicant.user.first_name = request.POST['first_name']
        else:
            applicant.user.first_name = None
        if request.POST['middle_name']:
            applicant.middle_name = request.POST['middle_name']
        else:
            applicant.middle_name = None
        if request.POST['birth_date']:
            try:
                applicant.birth_date = datetime.strptime(request.POST['birth_date'], '%d/%m/%Y')
            except ValueError:
                applicant.birth_date = None
                applicant_form.errors['birth_date'] = "La date encodée('%s') semble incorrecte " % request.POST[
                    'birth_date']
        else:
            applicant.birth_date = None
        if request.POST['birth_place']:
            applicant.birth_place = request.POST['birth_place']
        else:
            applicant.birth_place = None
        if request.POST.get('birth_country'):
            birth_country_id = request.POST['birth_country']
            if birth_country_id and int(birth_country_id) >= 0:
                birth_country = mdl_ref.country.find_by_id(birth_country_id)
            else:
                birth_country = None
            applicant.birth_country = birth_country
        else:
            applicant.birth_country = None
        if request.POST.get('gender'):
            applicant.gender = request.POST['gender']
        else:
            applicant.gender = None
        if request.POST['civil_status']:
            applicant.civil_status = request.POST['civil_status']
        else:
            applicant.civil_status = None
        if request.POST['number_children']:
            applicant.number_children = request.POST['number_children']
        else:
            applicant.number_children = None
        if request.POST['spouse_name']:
            applicant.spouse_name = request.POST['spouse_name']
        else:
            applicant.spouse_name = None
        if request.POST.get('nationality') and not request.POST.get('nationality') == "-1":
            country_id = request.POST['nationality']
            if country_id and int(country_id) >= 0:
                country = mdl_ref.country.find_by_id(country_id)
            else:
                country = None
            if country:
                if not country.european_union:
                    assimilation_case = True
            applicant.nationality = country
        else:
            applicant.nationality = None
        if request.POST['national_id']:
            applicant.national_id = request.POST['national_id']
        else:
            applicant.national_id = None
        if request.POST['id_card_number']:
            applicant.id_card_number = request.POST['id_card_number']
        else:
            applicant.id_card_number = None
        if request.POST['passport_number']:
            applicant.passport_number = request.POST['passport_number']
        else:
            applicant.passport_number = None
        if request.POST['legal_adr_street']:
            person_legal_address.street = request.POST['legal_adr_street']
        else:
            person_legal_address.street = ''
        if request.POST['legal_adr_number']:
            person_legal_address.number = request.POST['legal_adr_number']
        else:
            person_legal_address.number = ''
        if request.POST['legal_adr_complement']:
            person_legal_address.complement = request.POST['legal_adr_complement']
        else:
            person_legal_address.complement = None
        if request.POST['legal_adr_postal_code']:
            person_legal_address.postal_code = request.POST['legal_adr_postal_code']
        else:
            person_legal_address.postal_code = ''
        if request.POST['legal_adr_city']:
            person_legal_address.city = request.POST['legal_adr_city']
        else:
            person_legal_address.city = ''

        if request.POST.get('legal_adr_country') and not request.POST.get('legal_adr_country') == "-1":
            country_id = request.POST['legal_adr_country']
            country = None
            if country_id and int(country_id) >= 0:
                country = mdl_ref.country.find_by_id(country_id)
            person_legal_address.country = country
        else:
            applicant_form.errors['legal_adr_country'] = _('mandatory_field')

        if request.POST.get('same_contact_legal_addr') == "false":
            person_contact_address = mdl.person_address.find_by_person_type(applicant, 'CONTACT')
            if person_contact_address is None:
                person_contact_address = mdl.person_address.PersonAddress()
                person_contact_address.person = applicant
                person_contact_address.type = 'CONTACT'

            if request.POST['contact_adr_street']:
                person_contact_address.street = request.POST['contact_adr_street']
            else:
                person_contact_address.street = None
            if request.POST['contact_adr_number']:
                person_contact_address.number = request.POST['contact_adr_number']
            else:
                person_contact_address.number = None
            if request.POST['contact_adr_complement']:
                person_contact_address.complement = request.POST['contact_adr_complement']
            else:
                person_contact_address.complement = None
            if request.POST['contact_adr_postal_code']:
                person_contact_address.postal_code = request.POST['contact_adr_postal_code']
            else:
                person_contact_address.postal_code = None
            if request.POST['contact_adr_city']:
                person_contact_address.city = request.POST['contact_adr_city']
            else:
                person_contact_address.city = None
            if request.POST['contact_adr_country']:
                country_id = request.POST['contact_adr_country']
                country = None
                if country_id and int(country_id) >= 0:
                    country = mdl_ref.country.find_by_id(country_id)
                if country:
                    person_contact_address.country = country
            else:
                person_contact_address.country = None
            same_addresses = False
            person_contact_address.save()
        else:
            same_addresses = True
            person_contact_address = mdl.person_address.find_by_person_type(applicant, 'CONTACT')
            if person_contact_address:
                person_contact_address.delete()
                person_contact_address = None

        if request.POST['phone_mobile']:
            applicant.phone_mobile = request.POST['phone_mobile']
        if request.POST['phone']:
            applicant.phone = request.POST['phone']
        else:
            applicant.phone = None

        if request.POST['previous_enrollment'] == "true":
            if request.POST['registration_id']:
                applicant.registration_id = request.POST['registration_id']
            else:
                applicant.registration_id = None
            if request.POST['last_academic_year']:
                applicant.last_academic_year = request.POST['last_academic_year']
            else:
                applicant.last_academic_year = None
            previous_enrollment = True
        else:
            applicant.registration_id = None
            applicant.last_academic_year = None
            previous_enrollment = False
        if assimilation_case:
            # verify if it exists one record per criteria
            default_criteria_list = assimilation_criteria_enum.ASSIMILATION_CRITERIA_CHOICES
            for criteria in default_criteria_list:
                crit = criteria[0]
                existing_crit = mdl.applicant_assimilation_criteria.find_first(applicant, crit)
                if existing_crit is None:
                    applicant_assimilation_criteria = \
                                    mdl.applicant_assimilation_criteria.ApplicantAssimilationCriteria()
                    applicant_assimilation_criteria.criteria = crit
                    applicant_assimilation_criteria.applicant = applicant
                    applicant_assimilation_criteria.additional_criteria = None
                    applicant_assimilation_criteria.selected = None
                    applicant_assimilation_criteria.save()
                if application:
                    application_assimilation_criteria = mdl.application_assimilation_criteria.find_first(application,
                                                                                                         crit)
                    if application_assimilation_criteria is None:
                        application_assimilation_criteria = \
                            mdl.application_assimilation_criteria.ApplicationAssimilationCriteria()
                        application_assimilation_criteria.criteria = crit
                        application_assimilation_criteria.application = application
                        application_assimilation_criteria.additional_criteria = None
                        application_assimilation_criteria.selected = None
                        application_assimilation_criteria.save()

            for key in request.POST:
                if key[0:len(RADIO_NAME_ASSIMILATION_CRITERIA)] == RADIO_NAME_ASSIMILATION_CRITERIA:
                    criteria_id = key[len(RADIO_NAME_ASSIMILATION_CRITERIA):]
                    criteria_ref = assimilation_criteria_enum.find(criteria_id)
                    criteria = criteria_ref[0]
                    applicant_assimilation_criteria = mdl.applicant_assimilation_criteria.find_first(applicant,
                                                                                                     criteria)
                    if applicant_assimilation_criteria is None:
                        applicant_assimilation_criteria = mdl.applicant_assimilation_criteria\
                            .ApplicantAssimilationCriteria()
                        applicant_assimilation_criteria.criteria = criteria
                        applicant_assimilation_criteria.applicant = applicant
                    if request.POST[key] == "true":
                        if criteria:
                            assimilation_basic_documents = assimilation_criteria_view.\
                                find_list_assimilation_basic_documents()
                            list_document_type_needed = assimilation_criteria_view.\
                                get_list_documents_descriptions(criteria)
                            list_document_type_needed.append(document_type.ID_CARD)

                            if criteria == assimilation_criteria_enum.CRITERIA_5:
                                if request.POST.get("criteria_5") == assimilation_criteria_enum.CRITERIA_1:
                                    list_document_type_needed.extend([document_type.RESIDENT_LONG_DURATION,
                                                                      document_type.ID_FOREIGN_UNLIMITED])
                                if request.POST.get("criteria_5") == assimilation_criteria_enum.CRITERIA_2:
                                    list_document_type_needed.extend([
                                        document_type.ATTACHMENT_26,
                                        document_type.REFUGEE_CARD,
                                        document_type.FAMILY_COMPOSITION,
                                        document_type.BIRTH_CERTIFICATE,
                                        document_type.REFUGEE_CARD,
                                        document_type.RESIDENT_CERTIFICATE,
                                        document_type.FOREIGN_INSCRIPTION_CERTIFICATE,
                                        document_type.SUBSIDIARY_PROTECTION_DECISION,
                                        document_type.RESIDENCE_PERMIT,
                                        document_type.STATELESS_CERTIFICATE])
                                if request.POST.get("criteria_5") == assimilation_criteria_enum.CRITERIA_3:
                                    list_document_type_needed.extend([document_type.FAMILY_COMPOSITION,
                                                                      document_type.PAYCHECK_1,
                                                                      document_type.PAYCHECK_2,
                                                                      document_type.PAYCHECK_3,
                                                                      document_type.PAYCHECK_4,
                                                                      document_type.PAYCHECK_5,
                                                                      document_type.PAYCHECK_6,
                                                                      document_type.RESIDENT_CERTIFICATE,
                                                                      document_type.ID_CARD])
                                if request.POST.get("criteria_5") == assimilation_criteria_enum.CRITERIA_4:
                                    list_document_type_needed.extend([document_type.CPAS])

                            for basic_doc_description in assimilation_basic_documents:
                                if basic_doc_description not in list_document_type_needed:
                                    app_doc_files = mdl.applicant_document_file.\
                                        find_by_applicant_and_description(applicant, basic_doc_description)
                                    for app_doc_file in app_doc_files:
                                        # delete unnecessary documents
                                        app_doc_file.document_file.delete()

                            applicant_assimilation_criteria.additional_criteria = \
                                define_additional_criteria(request.POST.get("criteria_5"))
                            applicant_assimilation_criteria.selected = True
                            applicant_assimilation_criteria.save()

                            # Update/create application_assimilation_criteria
                            if application:
                                application_assimilation_criteria = mdl.application_assimilation_criteria.\
                                    find_first(application, criteria)
                                application_assimilation_criteria.criteria = criteria
                                if applicant_assimilation_criteria.additional_criteria:
                                    application_assimilation_criteria.additional_criteria = \
                                        applicant_assimilation_criteria.additional_criteria
                                application_assimilation_criteria.selected = True
                                application_assimilation_criteria.save()

                    if request.POST[key] == "false":
                        applicant_assimilation_criteria.selected = False
                        applicant_assimilation_criteria.save()
                        # Update/create application_assimilation_criteria
                        if application:
                            application_assimilation_criteria = mdl.application_assimilation_criteria.\
                                find_first(application, criteria)
                            application_assimilation_criteria.criteria = criteria
                            if applicant_assimilation_criteria.additional_criteria:
                                application_assimilation_criteria.additional_criteria = \
                                    applicant_assimilation_criteria.additional_criteria
                            application_assimilation_criteria.selected = False
                            application_assimilation_criteria.save()

        else:
            # cleanup the database if needed
            delete_previous_criteria(applicant, application)
        message_success = None

        if person_contact_address:
            person_contact_address.save()
        person_legal_address.save()
        applicant.user.save()
        if application:
            application.application_type = mdl.application.define_application_type(application.coverage_access_degree,
                                                                                   request.user)
            application.save()
        request.user = applicant.user  # Otherwise it was not refreshed while going back to home page
        applicant.save()
        message_info = _('msg_info_saved')

        following_tab = navigation.get_following_tab(request, 'profile', application)
        if following_tab:
            return following_tab
    else:
        applicant = mdl.applicant.find_by_user(request.user)
        applicant_form = ApplicantForm()
        if applicant:
            person_contact_address = mdl.person_address.find_by_person_type(applicant, 'CONTACT')
            same_addresses = True
            if person_contact_address:
                same_addresses = False

            previous_enrollment = False
            if applicant.registration_id or applicant.last_academic_year:
                previous_enrollment = True
        else:
            return HttpResponseRedirect('/admission/logout')

    countries = mdl_ref.country.find_all()
    props = mdl.properties.find_by_key('INSTITUTION')
    if props:
        institution_name = props.value
    else:
        institution_name = None

    assimilation_criteria = assimilation_criteria_enum.ASSIMILATION_CRITERIA_CHOICES
    applicant_assimilation_criteria = mdl.applicant_assimilation_criteria.find_by_applicant(applicant.id)

    # validated are not ready yet, to be achieved in another issue - Leila
    person_legal_address = mdl.person_address.find_by_person_type(applicant, 'LEGAL')
    person_contact_address = mdl.person_address.find_by_person_type(applicant, 'CONTACT')

    document_formset = UploadDocumentFileForm()
    data = {
        'applicant': applicant,
        'applicant_form': applicant_form,
        'countries': countries,
        'assimilation_criteria': assimilation_criteria,
        'applicant_assimilation_criteria': applicant_assimilation_criteria,
        'person_legal_address': person_legal_address,
        'person_contact_address': person_contact_address,
        'same_addresses': same_addresses,
        'previous_enrollment': previous_enrollment,
        'institution': institution_name,
        'message_success': message_success,
        'tab_active': navigation.PROFILE_TAB,
        'application': application,
        'applications': mdl.application.find_by_user(request.user),
        'picture': get_picture_id(request.user),
        'id_document': get_id_document(request.user),
        'assimilation_basic_documents': assimilation_criteria_view.find_assimilation_basic_documents(),
        'assimilation_documents_existing': get_assimilation_documents_existing(request.user),
        'document_formset': document_formset,
        'message_info': message_info}
    data.update(demande_validation.get_validation_status(application, applicant))
    return render(request, "admission_home.html", data)