Skip to content
Snippets Groups Projects
Commit 420564e7 authored by Tore.Brede's avatar Tore.Brede
Browse files

GREG-113: Handle date of birth. Some cleanup

parent e2907822
No related branches found
No related tags found
1 merge request!166GREG-113 guest date of birth
...@@ -72,8 +72,8 @@ class InvitationView(CreateAPIView, DestroyAPIView): ...@@ -72,8 +72,8 @@ class InvitationView(CreateAPIView, DestroyAPIView):
person = serializer.save() person = serializer.save()
for invitationlink in InvitationLink.objects.filter( for invitationlink in InvitationLink.objects.filter(
invitation__role__person_id=person.id, invitation__role__person_id=person.id,
invitation__role__sponsor_id=sponsor_user.sponsor_id, invitation__role__sponsor_id=sponsor_user.sponsor_id,
): ):
send_invite_mail(invitationlink) send_invite_mail(invitationlink)
...@@ -183,23 +183,16 @@ class InvitedGuestView(GenericAPIView): ...@@ -183,23 +183,16 @@ class InvitedGuestView(GenericAPIView):
else SessionType.FEIDE.value else SessionType.FEIDE.value
) )
fnr = self._get_identity_or_none(
person, Identity.IdentityType.NORWEGIAN_NATIONAL_ID_NUMBER
)
passport = self._get_identity_or_none(
person, Identity.IdentityType.PASSPORT_NUMBER
)
feide_id = self._get_identity_or_none(person, Identity.IdentityType.FEIDE_ID)
data = { data = {
"person": { "person": {
"first_name": person.first_name, "first_name": person.first_name,
"last_name": person.last_name, "last_name": person.last_name,
"email": person.private_email and person.private_email.value, "email": person.private_email and person.private_email.value,
"mobile_phone": person.private_mobile and person.private_mobile.value, "mobile_phone": person.private_mobile and person.private_mobile.value,
"fnr": fnr, "date_of_birth": person.date_of_birth,
"passport": passport, "fnr": person.fnr and person.fnr.value,
"feide_id": feide_id, "passport": person.passport and person.passport.value,
"feide_id": person.feide_id and person.feide_id.value,
}, },
"sponsor": { "sponsor": {
"first_name": sponsor.first_name, "first_name": sponsor.first_name,
...@@ -243,10 +236,10 @@ class InvitedGuestView(GenericAPIView): ...@@ -243,10 +236,10 @@ class InvitedGuestView(GenericAPIView):
# If there is a Feide ID registered with the guest, assume that the name is also coming from there # If there is a Feide ID registered with the guest, assume that the name is also coming from there
feide_id = self._get_identity_or_none(person, Identity.IdentityType.FEIDE_ID) feide_id = self._get_identity_or_none(person, Identity.IdentityType.FEIDE_ID)
if not self._only_allowed_fields_in_request( if not self._only_allowed_fields_in_request(
data, data,
self.fields_allowed_to_update_if_invite self.fields_allowed_to_update_if_invite
if feide_id is None if feide_id is None
else self.fields_allowed_to_update_if_feide, else self.fields_allowed_to_update_if_feide,
): ):
return Response(status=status.HTTP_400_BAD_REQUEST) return Response(status=status.HTTP_400_BAD_REQUEST)
...@@ -296,7 +289,7 @@ class InvitedGuestView(GenericAPIView): ...@@ -296,7 +289,7 @@ class InvitedGuestView(GenericAPIView):
@staticmethod @staticmethod
def _get_identity_or_none( def _get_identity_or_none(
person: Person, identity_type: Identity.IdentityType person: Person, identity_type: Identity.IdentityType
) -> Optional[str]: ) -> Optional[str]:
try: try:
return person.identities.get(type=identity_type).value return person.identities.get(type=identity_type).value
......
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