Skip to content
Snippets Groups Projects
Commit e69843e3 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Add guardians on registration if known, advances #9.

parent 2cc8a01b
No related branches found
No related tags found
No related merge requests found
......@@ -93,8 +93,25 @@ def register_event(request, cn):
given_name=register_form.cleaned_data['guardian_first_name'],
sn=register_form.cleaned_data['guardian_last_name']
):
# Guardian with name exists - mark for manual check
check_guardian_note = True
# Guardian with name exists - check other attributes
guardian = TeckidsParent.objects.get(
given_name=register_form.cleaned_data['guardian_first_name'],
sn=register_form.cleaned_data['guardian_last_name']
)
if (guardian.mail == register_form.cleaned_data['guardian_mail'] or
guardian.mobile == register_form.cleaned_data['guardian_mobile']
):
# Either mail or mobile matches - update both and link
guardian.mail = register_form.cleaned_data['guardian_mail'] or
guardian.mobile = register_form.cleaned_data['guardian_mobile']):
guardian.save()
if guardian.dn not in current_person.guardians:
current_person.guardians.append(guardian.dn)
current_person.save()
else:
# Automatic guardian management failed
check_guardian_note = True
else:
# Guardian does not exist - create
guardian = TeckidsParent.objects.create(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment