Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions contrib/forms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,13 @@ def get_scholarship_choices(uuid, person):
return EMPTY_CHOICE + ((uuid, format_scholarship(scholarship)),)


def get_past_academic_years_choices(person, exclude_current=False, current_year=None, academic_years=None):
def get_past_academic_years_choices(
person,
exclude_current=False,
current_year=None,
academic_years=None,
format_label_function=None,
):
"""Return a list of choices of past academic years."""
if academic_years is None:
academic_years = AcademicYearService.get_academic_years(person)
Expand All @@ -203,8 +209,15 @@ def get_past_academic_years_choices(person, exclude_current=False, current_year=

lower_year = current_year - 100

if format_label_function is None:

def default_format_label_function(academic_year):
return f"{academic_year.year}-{academic_year.year + 1}"

format_label_function = default_format_label_function

return EMPTY_CHOICE + tuple(
(academic_year.year, f"{academic_year.year}-{academic_year.year + 1}")
(academic_year.year, format_label_function(academic_year))
for academic_year in academic_years
if current_year >= academic_year.year >= lower_year
)
Expand Down
37 changes: 30 additions & 7 deletions contrib/forms/education.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# The core business involves the administration of students, teachers,
# courses, programs and so on.
#
# Copyright (C) 2015-2024 Université catholique de Louvain (http://www.uclouvain.be)
# Copyright (C) 2015-2025 Université catholique de Louvain (http://www.uclouvain.be)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -23,33 +23,36 @@
# see http://www.gnu.org/licenses/.
#
# ##############################################################################
import datetime

from dal import forward
from django import forms
from django.utils.safestring import mark_safe
from django.utils.translation import gettext_lazy as _, pgettext_lazy
from django.utils.translation import gettext_lazy as _
from django.utils.translation import pgettext_lazy
from osis_document.contrib.widgets import HiddenFileWidget

from admission.constants import FIELD_REQUIRED_MESSAGE
from admission.contrib.enums import HAS_DIPLOMA_CHOICES
from admission.contrib.enums.secondary_studies import (
EDUCATIONAL_TYPES,
BelgianCommunitiesOfEducation,
DiplomaTypes,
EDUCATIONAL_TYPES,
Equivalence,
ForeignDiplomaTypes,
GotDiploma,
)
from admission.contrib.forms import EMPTY_CHOICE
from admission.contrib.forms import AdmissionFileUploadField as FileUploadField
from admission.contrib.forms import (
autocomplete,
get_country_initial_choices,
get_high_school_initial_choices,
get_language_initial_choices,
get_past_academic_years_choices,
EMPTY_CHOICE,
AdmissionFileUploadField as FileUploadField,
)
from admission.contrib.forms.specific_question import ConfigurableFormMixin
from admission.services.reference import CountriesService, AcademicYearService
from osis_document.contrib.widgets import HiddenFileWidget
from admission.services.reference import AcademicYearService, CountriesService


def disable_fields(condition, fields, fields_to_keep_enabled_names=None):
Expand Down Expand Up @@ -155,6 +158,12 @@ class BachelorAdmissionEducationForm(BaseAdmissionEducationForm):
max_files=1,
required=False,
)
first_cycle_admission_exam_year = forms.TypedChoiceField(
label=_('Year of obtaining this proof'),
widget=autocomplete.Select2(),
coerce=int,
required=False,
)

class Media:
js = ("js/dependsOn.min.js",)
Expand All @@ -166,6 +175,17 @@ def __init__(self, *args, **kwargs):
foreign_diploma = self.initial.get("foreign_diploma")
high_school_diploma_alternative = self.initial.get("high_school_diploma_alternative")

today = datetime.date.today()
if today.month >= 11:
current_year = today.year
else:
current_year = today.year - 1
self.fields['first_cycle_admission_exam_year'].choices = get_past_academic_years_choices(
kwargs['person'],
current_year=current_year,
format_label_function=lambda academic_year: str(academic_year.year + 1),
)

diploma = belgian_diploma or foreign_diploma
# Select the correct diploma type if one has been saved
if diploma:
Expand All @@ -177,6 +197,9 @@ def __init__(self, *args, **kwargs):
self.fields['first_cycle_admission_exam'].initial = high_school_diploma_alternative.get(
"first_cycle_admission_exam"
)
self.fields['first_cycle_admission_exam_year'].initial = high_school_diploma_alternative.get(
"first_cycle_admission_exam_year"
)
disable_fields(not self.can_update_diploma, self.fields, {self.configurable_form_field_name})

def clean(self):
Expand Down
15 changes: 11 additions & 4 deletions contrib/views/common/form_tabs/education.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# The core business involves the administration of students, teachers,
# courses, programs and so on.
#
# Copyright (C) 2015-2024 Université catholique de Louvain (http://www.uclouvain.be)
# Copyright (C) 2015-2025 Université catholique de Louvain (http://www.uclouvain.be)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -29,12 +29,12 @@

from admission.constants import LINGUISTIC_REGIMES_WITHOUT_TRANSLATION, PLUS_5_ISO_CODES
from admission.contrib.enums.secondary_studies import (
HAS_DIPLOMA_CHOICES,
BelgianCommunitiesOfEducation,
DiplomaTypes,
Equivalence,
ForeignDiplomaTypes,
GotDiploma,
HAS_DIPLOMA_CHOICES,
)
from admission.contrib.enums.specific_question import Onglets
from admission.contrib.enums.training_choice import TrainingType
Expand All @@ -45,7 +45,10 @@
BaseAdmissionEducationForm,
)
from admission.contrib.views.mixins import LoadDossierViewMixin
from admission.services.mixins import FormMixinWithSpecificQuestions, WebServiceFormMixin
from admission.services.mixins import (
FormMixinWithSpecificQuestions,
WebServiceFormMixin,
)
from admission.services.person import (
ContinuingEducationAdmissionPersonService,
GeneralEducationAdmissionPersonService,
Expand Down Expand Up @@ -238,12 +241,16 @@ def prepare_data(self, main_form_data):
}

first_cycle_admission_exam = data.pop("first_cycle_admission_exam", [])
first_cycle_admission_exam_year = data.pop("first_cycle_admission_exam_year", "")
if graduated_from_high_school == GotDiploma.NO.name:
return {
'specific_question_answers': data.get('specific_question_answers'),
'graduated_from_high_school': graduated_from_high_school,
'graduated_from_high_school_year': data.get('graduated_from_high_school_year'),
'high_school_diploma_alternative': {'first_cycle_admission_exam': first_cycle_admission_exam},
'high_school_diploma_alternative': {
'first_cycle_admission_exam': first_cycle_admission_exam,
'first_cycle_admission_exam_year': first_cycle_admission_exam_year,
},
}

# The candidate has a diploma or will have one this year
Expand Down
38 changes: 22 additions & 16 deletions locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,10 @@ msgstr ""
#, python-format
msgid ""
"<p> On the basis of the information you have provided on your previous "
"experience, you do not appear to meet the <a href=\"%(url)s\" target=\"_blank"
"\">eligibility requirements for the course</a> <em>%(course_title)s</em>. </"
"p> <p>Please check your previous course data or choose another course.</p>"
"experience, you do not appear to meet the <a href=\"%(url)s\" "
"target=\"_blank\">eligibility requirements for the course</a> "
"<em>%(course_title)s</em>. </p> <p>Please check your previous course data or "
"choose another course.</p>"
msgstr ""

#, python-format
Expand Down Expand Up @@ -169,8 +170,8 @@ msgid ""
msgstr ""

msgid ""
"A technical or IT problem? <a href=\"http://uclouvain.be/8282\" target="
"\"_blank\">Contact the Service Desk</a>"
"A technical or IT problem? <a href=\"http://uclouvain.be/8282\" "
"target=\"_blank\">Contact the Service Desk</a>"
msgstr ""

msgid "A transcript for all years"
Expand Down Expand Up @@ -306,9 +307,10 @@ msgid ""
"Answer according to the European Framework of Reference for Languages (CEFR) "
"classification. Detailed explanations of this framework can be found at <a "
"href=\"https://www.coe.int/en/web/common-european-framework-reference-"
"languages/table-1-cefr-3.3-common-reference-levels-global-scale\" target="
"\"_blank\"> https://www.coe.int/en/web/common-european-framework-reference-"
"languages/table-1-cefr-3.3-common-reference-levels-global-scale </a>"
"languages/table-1-cefr-3.3-common-reference-levels-global-scale\" "
"target=\"_blank\"> https://www.coe.int/en/web/common-european-framework-"
"reference-languages/table-1-cefr-3.3-common-reference-levels-global-scale </"
"a>"
msgstr ""

msgid ""
Expand Down Expand Up @@ -2792,8 +2794,8 @@ msgstr ""

#, python-format
msgid ""
"Would you like to switch courses this academic year at UCLouvain? (<a href="
"\"%(url)s\" target=\"_blank\">Informations</a>)"
"Would you like to switch courses this academic year at UCLouvain? (<a "
"href=\"%(url)s\" target=\"_blank\">Informations</a>)"
msgstr ""

msgid ""
Expand All @@ -2812,6 +2814,9 @@ msgstr ""
msgid "Year of birth"
msgstr ""

msgid "Year of obtaining this proof"
msgstr ""

msgid "Year without enrolling in the course."
msgstr ""

Expand Down Expand Up @@ -2894,8 +2899,9 @@ msgid ""
msgstr ""

msgid ""
"You can find more information on the French Community webpage <a href="
"\"https://equisup.cfwb.be/\" target=\"_blank\">https://equisup.cfwb.be/</a>"
"You can find more information on the French Community webpage <a "
"href=\"https://equisup.cfwb.be/\" target=\"_blank\">https://equisup.cfwb.be/"
"</a>"
msgstr ""

msgid "You can specify the locality or postcode in your search."
Expand Down Expand Up @@ -2980,8 +2986,8 @@ msgstr ""

#, python-brace-format
msgid ""
"Your completed and signed reorientation form (<a href=\"{url}\" target="
"\"_blank\">{url}</a>)"
"Your completed and signed reorientation form (<a href=\"{url}\" "
"target=\"_blank\">{url}</a>)"
msgstr ""

msgid "Your data have been saved"
Expand All @@ -2996,8 +3002,8 @@ msgid ""
msgstr ""

msgid ""
"Your joint supervision information can be completed later. Please input \"No"
"\" if you don't have information yet."
"Your joint supervision information can be completed later. Please input "
"\"No\" if you don't have information yet."
msgstr ""

#, python-brace-format
Expand Down
Loading