diff --git a/passerelle/contrib/toulouse_maelis/models.py b/passerelle/contrib/toulouse_maelis/models.py index e9a5cb43..a13b3cb4 100644 --- a/passerelle/contrib/toulouse_maelis/models.py +++ b/passerelle/contrib/toulouse_maelis/models.py @@ -794,13 +794,17 @@ class ToulouseMaelis(BaseResource, HTTPResource): def update_child(self, request, NameID, child_id, post_data): family_id = self.get_link(NameID).family_id family = self.get_family_raw(family_id) - if child_id not in [x['num'] for x in family['childList']]: - raise APIError('No child %s to update on family' % child_id, err_code='no-child') self.assert_child_payload_in_referential(post_data) self.replace_null_values(post_data) child = post_data child['num'] = child_id + for known_child in family['childList']: + if str(known_child['num']) == child_id: + child['authorizedPersonList'] = known_child['authorizedPersonList'] + break + else: + raise APIError('No child %s to update on family' % child_id, err_code='no-child') payload = { 'dossierNumber': family_id, 'category': family['category'], diff --git a/tests/data/toulouse_maelis/Q_update_child.xml b/tests/data/toulouse_maelis/Q_update_child.xml index cdb6dd4d..14ba3a7b 100644 --- a/tests/data/toulouse_maelis/Q_update_child.xml +++ b/tests/data/toulouse_maelis/Q_update_child.xml @@ -25,6 +25,25 @@ true false + + + 614719 + BENT + AMEL + 1985-06-21T00:00:00+02:00 + MME + F + + 0123456789 + 0623456789 + abent@example.org + + + + T + TANTE + +