Match existing Teilnehmer with multiple parameters
This commit is contained in:
parent
9f15c3de69
commit
57cd5fe871
|
|
@ -269,7 +269,7 @@
|
|||
"selfEvaluationNo": "@:selfEvaluation: Muss ich nochmals anschauen.",
|
||||
"selfEvaluationYes": "@:selfEvaluation: Ich kann das.",
|
||||
"steps": "Schritt {{current}} von {{max}}",
|
||||
"title": "@:selfEvaluation.selfEvaluation {{title}}",
|
||||
"title": "Selbsteinschätzung {{title}}",
|
||||
"yes": "Ja, ich kann das"
|
||||
},
|
||||
"settings": {
|
||||
|
|
|
|||
|
|
@ -91,7 +91,9 @@ const getNextStepLink = (courseSession: CourseSession) => {
|
|||
<br />
|
||||
{{ $t("uk.contact.address") }}
|
||||
<br />
|
||||
<a href="mailto:uek-support@vbv-afa.ch">uk.contact.email</a>
|
||||
<a class="link" href="mailto:uek-support@vbv-afa.ch">
|
||||
uek-support@vbv-afa.ch
|
||||
</a>
|
||||
</p>
|
||||
</address>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -185,6 +185,7 @@ def create_or_update_user(
|
|||
last_name: str = "",
|
||||
sso_id: str = None,
|
||||
contract_number: str = "",
|
||||
date_of_birth: str = "",
|
||||
):
|
||||
logger.debug(
|
||||
"create_or_update_user",
|
||||
|
|
@ -200,9 +201,13 @@ def create_or_update_user(
|
|||
if user_qs.exists():
|
||||
user = user_qs.first()
|
||||
|
||||
# use the ID from DBPLAP2 (Lehrvertragsnummer, firstname, lastname, date of birth)
|
||||
if not user and contract_number:
|
||||
user_qs = User.objects.filter(
|
||||
additional_json_data__Lehrvertragsnummer=contract_number
|
||||
first_name=first_name,
|
||||
last_name=last_name,
|
||||
additional_json_data__Lehrvertragsnummer=contract_number,
|
||||
additional_json_data__Geburtsdatum=date_of_birth,
|
||||
)
|
||||
if user_qs.exists():
|
||||
user = user_qs.first()
|
||||
|
|
@ -502,6 +507,8 @@ def import_students_from_excel(filename: str):
|
|||
"Name",
|
||||
"Sprache",
|
||||
"Durchführungen",
|
||||
"Lehrvertragsnummer",
|
||||
"Geburtsdatum",
|
||||
],
|
||||
)
|
||||
create_or_update_student(data)
|
||||
|
|
@ -514,11 +521,14 @@ def create_or_update_student(data: Dict[str, Any]):
|
|||
label="import",
|
||||
)
|
||||
|
||||
date_of_birth = _get_date_of_birth(data)
|
||||
|
||||
user = create_or_update_user(
|
||||
email=data["Email"].lower(),
|
||||
first_name=data["Vorname"],
|
||||
last_name=data["Name"],
|
||||
contract_number=data.get("Lehrvertragsnummer", ""),
|
||||
date_of_birth=date_of_birth,
|
||||
)
|
||||
|
||||
user.language = data["Sprache"]
|
||||
|
|
@ -535,6 +545,16 @@ def create_or_update_student(data: Dict[str, Any]):
|
|||
csu.save()
|
||||
|
||||
|
||||
def _get_date_of_birth(data: Dict[str, Any]) -> str:
|
||||
date_of_birth = data.get("Geburtsdatum", None)
|
||||
if date_of_birth is None:
|
||||
return ""
|
||||
elif date_of_birth is date or date_of_birth is datetime:
|
||||
return date_of_birth.strftime("%d.%m.%Y")
|
||||
elif type(date_of_birth) is str:
|
||||
return date_of_birth
|
||||
|
||||
|
||||
def sync_students_from_t2l_excel(filename: str):
|
||||
workbook = load_workbook(filename=filename)
|
||||
sheet = workbook.active
|
||||
|
|
@ -546,10 +566,13 @@ def sync_students_from_t2l_excel(filename: str):
|
|||
|
||||
|
||||
def sync_students_from_t2l(data):
|
||||
# ignore errors
|
||||
date_of_birth = _get_date_of_birth(data)
|
||||
try:
|
||||
user = User.objects.get(
|
||||
additional_json_data__Lehrvertragsnummer=data["Lehrvertragsnummer"]
|
||||
first_name=data["Vorname"],
|
||||
last_name=data["Name"],
|
||||
additional_json_data__Lehrvertragsnummer=data["Lehrvertragsnummer"],
|
||||
additional_json_data__Geburtsdatum=date_of_birth,
|
||||
)
|
||||
except User.DoesNotExist:
|
||||
return
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ class CreateOrUpdateStudentTestCase(TestCase):
|
|||
"Durchführungen": "DE 2023 A",
|
||||
"Lehrvertragsnummer": "1234",
|
||||
"Tel. Privat": "079 593 83 43",
|
||||
"Geburtsdatum": "01.01.2000",
|
||||
}
|
||||
|
||||
def test_create_student(self):
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ class SyncT2lTestCase(TestCase):
|
|||
"Durchführungen": "DE 2023 A",
|
||||
"Lehrvertragsnummer": "1234",
|
||||
"Tel. Privat": "079 593 83 43",
|
||||
"Geburtsdatum": "01.01.2000",
|
||||
}
|
||||
create_or_update_student(self.user_dict)
|
||||
|
||||
|
|
@ -44,6 +45,7 @@ class SyncT2lTestCase(TestCase):
|
|||
"Durchführungen": "DE 2023 A",
|
||||
"Lehrvertragsnummer": "1234",
|
||||
"Tel. Privat": "079 593 83 65",
|
||||
"Geburtsdatum": "01.01.2000",
|
||||
}
|
||||
|
||||
sync_students_from_t2l(user_dict)
|
||||
|
|
@ -65,6 +67,7 @@ class SyncT2lTestCase(TestCase):
|
|||
"Lehrvertragsnummer": "1234",
|
||||
"Tel. Privat": "079 593 83 43",
|
||||
"Firma": "VBV",
|
||||
"Geburtsdatum": "01.01.2000",
|
||||
}
|
||||
|
||||
sync_students_from_t2l(user_dict)
|
||||
|
|
@ -84,6 +87,7 @@ class SyncT2lTestCase(TestCase):
|
|||
"Durchführungen": "DE 2023 B",
|
||||
"Lehrvertragsnummer": "1234",
|
||||
"Tel. Privat": "079 593 83 43",
|
||||
"Geburtsdatum": "01.01.2000",
|
||||
}
|
||||
|
||||
sync_students_from_t2l(user_dict)
|
||||
|
|
|
|||
Loading…
Reference in New Issue