toulouse-maelis: copy note in indicators dict (#72622) #13
|
@ -13,7 +13,8 @@
|
|||
"text": "Autre",
|
||||
"label": "Autre",
|
||||
"typeDesc": "NOTE",
|
||||
"isActive": true
|
||||
"isActive": true,
|
||||
"note": "rebellious"
|
||||
},
|
||||
{
|
||||
"id": "AVL",
|
||||
|
@ -37,7 +38,8 @@
|
|||
"text": "Etablissement sp\u00e9cialis\u00e9",
|
||||
"label": "Etablissement sp\u00e9cialis\u00e9",
|
||||
"typeDesc": "NOTE",
|
||||
"isActive": false
|
||||
"isActive": false,
|
||||
"note": null
|
||||
},
|
||||
{
|
||||
"id": "LENTILLE",
|
||||
|
|
|
@ -21,7 +21,8 @@
|
|||
"text": "Etablissement sp\u00e9cialis\u00e9",
|
||||
"label": "Etablissement sp\u00e9cialis\u00e9",
|
||||
"typeDesc": "NOTE",
|
||||
"isActive": true
|
||||
"isActive": true,
|
||||
"note": "SNPP"
|
||||
},
|
||||
{
|
||||
"id": "MDPH",
|
||||
|
|
|
@ -237,11 +237,14 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
|||
data[last_key + '_text'] = self.get_referential_value(referential_name, data[last_key])
|
||||
|
||||
def add_indicators_field(self, referential_name, data):
|
||||
active_indicators = [x['code'] for x in data['indicatorList']]
|
||||
active_indicators = {x['code']: x for x in data['indicatorList']}
|
||||
indicators = self.get_referential(referential_name)
|
||||
result = {}
|
||||
for item in indicators:
|
||||
item['isActive'] = item['id'] in active_indicators
|
||||
active_indicator = active_indicators.get(item['id']) or {}
|
||||
item['isActive'] = bool(active_indicator)
|
||||
if item['typeDesc'] == 'NOTE':
|
||||
item['note'] = active_indicator.get('note')
|
||||
del item['choiceList'] # no list based indicator on parsifal project
|
||||
result[item['id']] = item
|
||||
data['indicators'] = result
|
||||
|
|
|
@ -907,6 +907,7 @@ def test_read_family(family_service, xml, con, app):
|
|||
'id': 'ETABSPEC',
|
||||
'isActive': True,
|
||||
'label': 'Etablissement spécialisé',
|
||||
'note': 'SNPP',
|
||||
'text': 'Etablissement spécialisé',
|
||||
'typeDesc': 'NOTE',
|
||||
},
|
||||
|
@ -1038,6 +1039,26 @@ def test_read_family(family_service, xml, con, app):
|
|||
indicators = resp.json['data']['childList'][0]['indicators']
|
||||
assert len(indicators) == 8
|
||||
assert len([x for x in indicators.values() if x['isActive']]) == 2
|
||||
assert [x for x in indicators.values() if x['typeDesc'] == 'NOTE'] == [
|
||||
{
|
||||
'id': 'AUTRE',
|
||||
'code': 'AUTRE',
|
||||
'text': 'Autre',
|
||||
'label': 'Autre',
|
||||
'typeDesc': 'NOTE',
|
||||
'isActive': True,
|
||||
'note': 'rebellious',
|
||||
},
|
||||
{
|
||||
'id': 'ETABSPEC',
|
||||
'code': 'ETABSPEC',
|
||||
'text': 'Etablissement spécialisé',
|
||||
'label': 'Etablissement spécialisé',
|
||||
'typeDesc': 'NOTE',
|
||||
'isActive': False,
|
||||
'note': None,
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
def test_read_family_not_linked_error(con, app):
|
||||
|
@ -1154,6 +1175,7 @@ def test_read_rl2(family_service, con, app):
|
|||
'id': 'ETABSPEC',
|
||||
'isActive': False,
|
||||
'label': 'Etablissement spécialisé',
|
||||
'note': None,
|
||||
'text': 'Etablissement spécialisé',
|
||||
'typeDesc': 'NOTE',
|
||||
},
|
||||
|
@ -3193,7 +3215,7 @@ def test_update_child_indicator(family_service, con, app):
|
|||
'indicatorList/3/code': 'AVS',
|
||||
'indicatorList/3/isActive': '0',
|
||||
'indicatorList/4/code': 'ETABSPEC',
|
||||
'indicatorList/4/note': 'xxx',
|
||||
'indicatorList/4/note': None,
|
||||
'indicatorList/4/isActive': 'Oui',
|
||||
'indicatorList/5/code': 'LENTILLE',
|
||||
'indicatorList/5/isActive': 'Non',
|
||||
|
|
Loading…
Reference in New Issue