0002-toulouse_maelis-add-sex-referential-67325.patch
passerelle/contrib/toulouse_maelis/models.py | ||
---|---|---|
74 | 74 |
# local referentials |
75 | 75 |
if referential_name == 'Complement': |
76 | 76 |
response = [ |
77 | 77 |
{'id': 'B', 'text': 'bis'}, |
78 | 78 |
{'id': 'T', 'text': 'ter'}, |
79 | 79 |
{'id': 'Q', 'text': 'quater'}, |
80 | 80 |
] |
81 | 81 |
return {'list': response, 'dict': {x['id']: x['text'] for x in response}} |
82 |
elif referential_name == 'Sex': |
|
83 |
response = [ |
|
84 |
{'id': 'M', 'text': 'Masculin'}, |
|
85 |
{'id': 'F', 'text': 'Féminin'}, |
|
86 |
] |
|
87 |
return {'list': response, 'dict': {x['id']: x['text'] for x in response}} |
|
82 | 88 | |
83 | 89 |
# remote referentials |
84 | 90 |
cache_key = 'maelis-%s-%s' % (self.pk, referential_name) |
85 | 91 |
data = cache.get(cache_key) |
86 | 92 |
if data is None: |
87 | 93 |
response = self.call('Family', 'read' + referential_name + 'List') |
88 | 94 |
data = { |
89 | 95 |
'list': [{'id': x.code, 'text': x.libelle} for x in response], |
... | ... | |
123 | 129 |
# add text from referentials |
124 | 130 |
add_text_value('Category', data, ['category']) |
125 | 131 |
add_text_value('Situation', data, ['situation']) |
126 | 132 |
for rlg in 'RL1', 'RL2': |
127 | 133 |
add_text_value('Civility', data, [rlg, 'civility']) |
128 | 134 |
add_text_value('Quality', data, [rlg, 'quality']) |
129 | 135 |
add_text_value('Complement', data, [rlg, 'adresse', 'numComp']) |
130 | 136 |
add_text_value('CSP', data, [rlg, 'profession', 'codeCSP']) |
137 |
for child in data['childList']: |
|
138 |
add_text_value('Sex', child, ['sexe']) |
|
131 | 139 |
return data |
132 | 140 | |
133 | 141 |
@endpoint( |
134 | 142 |
display_category=_('Family'), |
135 | 143 |
description='Liste des catégories', |
136 | 144 |
name='read-category-list', |
137 | 145 |
perm='can_access', |
138 | 146 |
) |
... | ... | |
180 | 188 |
display_category=_('Family'), |
181 | 189 |
description='liste des qualités du référenciel', |
182 | 190 |
name='read-quality-list', |
183 | 191 |
perm='can_access', |
184 | 192 |
) |
185 | 193 |
def read_quality_list(self, request): |
186 | 194 |
return {'data': self.get_referential('Quality')['list']} |
187 | 195 | |
196 |
@endpoint( |
|
197 |
display_category=_('Family'), |
|
198 |
description='Liste des sexes', |
|
199 |
name='read-sex-list', |
|
200 |
perm='can_access', |
|
201 |
) |
|
202 |
def read_sex_list(self, request): |
|
203 |
return {'data': self.get_referential('Sex')['list']} |
|
204 | ||
188 | 205 |
@endpoint( |
189 | 206 |
display_category=_('Family'), |
190 | 207 |
description='liste des situations', |
191 | 208 |
name='read-situation-list', |
192 | 209 |
perm='can_access', |
193 | 210 |
) |
194 | 211 |
def read_situation_list(self, request): |
195 | 212 |
return {'data': self.get_referential('Situation')['list']} |
tests/test_toulouse_maelis.py | ||
---|---|---|
314 | 314 |
{'id': 'O', 'text': 'ONCLE'}, |
315 | 315 |
{'id': 'OS', 'text': 'ORGANISME SOCIAL'}, |
316 | 316 |
{'id': 'PERE', 'text': 'PERE'}, |
317 | 317 |
{'id': 'T', 'text': 'TANTE'}, |
318 | 318 |
{'id': 'TUTEUR', 'text': 'TUTEUR'}, |
319 | 319 |
] |
320 | 320 | |
321 | 321 | |
322 |
def test_read_sex_list(con, app): |
|
323 |
url = get_endpoint('read-sex-list') |
|
324 | ||
325 |
resp = app.get(url) |
|
326 |
assert resp.json['err'] == 0 |
|
327 |
assert resp.json['data'] == [ |
|
328 |
{'id': 'M', 'text': 'Masculin'}, |
|
329 |
{'id': 'F', 'text': 'Féminin'}, |
|
330 |
] |
|
331 | ||
332 | ||
322 | 333 |
@mock.patch('passerelle.utils.Request.get') |
323 | 334 |
@mock.patch('passerelle.utils.Request.post') |
324 | 335 |
def test_read_situation_list(mocked_post, mocked_get, con, app): |
325 | 336 |
mocked_get.return_value = FAMILY_SERVICE_WSDL |
326 | 337 |
mocked_post.return_value = READ_SITUATIONS |
327 | 338 |
url = get_endpoint('read-situation-list') |
328 | 339 | |
329 | 340 |
resp = app.get(url) |
... | ... | |
375 | 386 |
'mail': 'petro.costache@yahoo.com', |
376 | 387 |
'isContactMail': True, |
377 | 388 |
'isContactSms': True, |
378 | 389 |
'isInvoicePdf': True, |
379 | 390 |
}, |
380 | 391 |
'profession': None, |
381 | 392 |
'CAFInfo': {'number': '51', 'organ': None}, |
382 | 393 |
} |
394 |
assert resp.json['data']['childList'][0] == { |
|
395 |
'num': '613880', |
|
396 |
'lastname': 'COSTANZE', |
|
397 |
'firstname': 'CASSANDRA', |
|
398 |
'sexe': 'F', |
|
399 |
'sexe_text': 'Féminin', |
|
400 |
'birth': {'dateBirth': '2021-06-22T00:00:00+02:00', 'place': None}, |
|
401 |
'dietcode': 'STD', |
|
402 |
'fsl': None, |
|
403 |
'bPhoto': False, |
|
404 |
'bLeaveAlone': False, |
|
405 |
'authorizedPersonList': [], |
|
406 |
'indicatorList': [], |
|
407 |
'medicalRecord': None, |
|
408 |
'subscribeSchoolList': [], |
|
409 |
'mother': None, |
|
410 |
'father': None, |
|
411 |
'rl': None, |
|
412 |
'subscribeActivityList': [], |
|
413 |
'paiInfoBean': None, |
|
414 |
} |
|
383 | 415 | |
384 | 416 | |
385 | 417 |
def test_read_family_not_linked_error(con, app): |
386 | 418 |
url = get_endpoint('read-family') |
387 | 419 | |
388 | 420 |
resp = app.get(url + '?NameID=') |
389 | 421 |
assert resp.json['err'] == 'not-linked' |
390 | 422 |
assert resp.json['err_desc'] == 'User not linked to family' |
391 |
- |