Project

General

Profile

0001-toulouse-maelis-send-authorized-person-list-on-updat.patch

Nicolas Roche, 24 November 2022 11:51 AM

Download (3.31 KB)

View differences:

Subject: [PATCH] toulouse-maelis: send authorized person list on update-child
 (#71645)

 passerelle/contrib/toulouse_maelis/models.py  |  8 ++++++--
 tests/data/toulouse_maelis/Q_update_child.xml | 19 +++++++++++++++++++
 2 files changed, 25 insertions(+), 2 deletions(-)
passerelle/contrib/toulouse_maelis/models.py
789 789
            'NameID': {'description': 'Publik NameID'},
790 790
            'child_id': {'description': "Numéro de l'enfant"},
791 791
        },
792 792
        post={'request_body': {'schema': {'application/json': schemas.UPDATE_CHILD_SCHEMA}}},
793 793
    )
794 794
    def update_child(self, request, NameID, child_id, post_data):
795 795
        family_id = self.get_link(NameID).family_id
796 796
        family = self.get_family_raw(family_id)
797
        if child_id not in [x['num'] for x in family['childList']]:
798
            raise APIError('No child %s to update on family' % child_id, err_code='no-child')
799 797
        self.assert_child_payload_in_referential(post_data)
800 798
        self.replace_null_values(post_data)
801 799

  
802 800
        child = post_data
803 801
        child['num'] = child_id
802
        for known_child in family['childList']:
803
            if str(known_child['num']) == child_id:
804
                child['authorizedPersonList'] = known_child['authorizedPersonList']
805
                break
806
        else:
807
            raise APIError('No child %s to update on family' % child_id, err_code='no-child')
804 808
        payload = {
805 809
            'dossierNumber': family_id,
806 810
            'category': family['category'],
807 811
            'situation': family['situation'],
808 812
            'flagCom': family['flagCom'],
809 813
            'nbChild': family['nbChild'],
810 814
            'nbTotalChild': family['nbTotalChild'],
811 815
            'nbAES': family['nbAES'],
tests/data/toulouse_maelis/Q_update_child.xml
20 20
        <lastname>DOE</lastname>
21 21
        <sexe>F</sexe>
22 22
        <birth>
23 23
          <dateBirth>1943-01-19</dateBirth>
24 24
          <place>Port Arthur</place>
25 25
        </birth>
26 26
        <bPhoto>true</bPhoto>
27 27
        <bLeaveAlone>false</bLeaveAlone>
28
        <authorizedPersonList>
29
          <personInfo>
30
            <num>614719</num>
31
            <lastname>BENT</lastname>
32
            <firstname>AMEL</firstname>
33
            <dateBirth>1985-06-21T00:00:00+02:00</dateBirth>
34
            <civility>MME</civility>
35
            <sexe>F</sexe>
36
            <contact>
37
              <phone>0123456789</phone>
38
              <mobile>0623456789</mobile>
39
              <mail>abent@example.org</mail>
40
            </contact>
41
          </personInfo>
42
          <personQuality>
43
            <code>T</code>
44
            <libelle>TANTE</libelle>
45
          </personQuality>
46
        </authorizedPersonList>
28 47
      </childList>
29 48
    </ns0:updateFamily>
30 49
  </soap-env:Body>
31 50
</soap-env:Envelope>
32
-