diff --git a/gregui/api/views/invitation.py b/gregui/api/views/invitation.py index eaa9dd80095c2538e7a21df114a71622ab176930..5da4eef6d587c45363013c7f76d674d35b327580 100644 --- a/gregui/api/views/invitation.py +++ b/gregui/api/views/invitation.py @@ -323,7 +323,7 @@ class InvitedGuestView(GenericAPIView): # It is not certain that all fields required will come from Feide, like the national ID number, so # allow updates to empty fields to handle the case where the information is missing from Feide # and the user has to enter it manually - illegal_fields = self._illegal_fields( + illegal_fields = self._illegal_updates( data, self.fields_allowed_to_update_if_invite if feide_id is None @@ -340,13 +340,18 @@ class InvitedGuestView(GenericAPIView): ) @staticmethod - def _illegal_fields(request_data, changeable_fields, person) -> List[str]: + def _illegal_updates(request_data, changeable_fields, person) -> List[str]: person_data = request_data.get("person", {}) changed_fields = person_data.keys() - result = [] + illegal_field_updates = [] for changed_field in changed_fields: - attribute = getattr(person, changed_field) + try: + attribute = getattr(person, changed_field) + except AttributeError: + # The property does not exist on person + illegal_field_updates.append(changed_field) + continue if changed_field not in changeable_fields: # It is still allowed to update fields where there is no existing value even if @@ -357,9 +362,9 @@ class InvitedGuestView(GenericAPIView): else: if attribute != person_data[changed_field]: # There is an existing value - result.append(changed_field) + illegal_field_updates.append(changed_field) - return result + return illegal_field_updates @staticmethod def _get_identity_or_none(