toulouse-maelis: add natures subscribed to read-family response (#75549)
gitea/passerelle/pipeline/head This commit looks good
Details
gitea/passerelle/pipeline/head This commit looks good
Details
This commit is contained in:
parent
3a558b0ba4
commit
50c725d393
|
@ -322,6 +322,7 @@ def remove_id_on_child(conn, child):
|
||||||
del child['indicators'] # order may change
|
del child['indicators'] # order may change
|
||||||
child['subscribeSchoolList'] = [] # not managed by test yet
|
child['subscribeSchoolList'] = [] # not managed by test yet
|
||||||
child['subscribeActivityList'] = [] # not managed by test yet
|
child['subscribeActivityList'] = [] # not managed by test yet
|
||||||
|
del child['subscribe_natures'] # order may change
|
||||||
|
|
||||||
|
|
||||||
def remove_id_on_rlg(conn, rlg):
|
def remove_id_on_rlg(conn, rlg):
|
||||||
|
@ -332,6 +333,8 @@ def remove_id_on_rlg(conn, rlg):
|
||||||
rlg['indicatorList'].sort(key=lambda x: x['code'])
|
rlg['indicatorList'].sort(key=lambda x: x['code'])
|
||||||
rlg['quotientList'].sort(key=lambda x: (x['yearRev'], x['dateStart']))
|
rlg['quotientList'].sort(key=lambda x: (x['yearRev'], x['dateStart']))
|
||||||
del rlg['indicators'] # order may change
|
del rlg['indicators'] # order may change
|
||||||
|
rlg['subscribeActivityList'] = [] # not managed by test yet
|
||||||
|
del rlg['subscribe_natures'] # order may change
|
||||||
|
|
||||||
|
|
||||||
def remove_id_on_family(conn, family):
|
def remove_id_on_family(conn, family):
|
||||||
|
|
|
@ -343,6 +343,25 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
||||||
result[item['id']] = item
|
result[item['id']] = item
|
||||||
data['indicators'] = result
|
data['indicators'] = result
|
||||||
|
|
||||||
|
def add_nature_subsciptions(self, data):
|
||||||
|
subscribe_natures = {}
|
||||||
|
for item in data['subscribeActivityList'] or []:
|
||||||
|
activity_type = item.get('typeActivity')
|
||||||
|
activity_nature = activity_type.get('natureSpec') if activity_type else None
|
||||||
|
if not activity_nature:
|
||||||
|
continue
|
||||||
|
for unit in item['subscribesUnit']:
|
||||||
|
start_year = utils.get_reference_year_from_date(unit.get('dateStart'))
|
||||||
|
end_year = utils.get_reference_year_from_date(unit.get('dateEnd'))
|
||||||
|
if not start_year or not end_year:
|
||||||
|
continue
|
||||||
|
for year in range(start_year, end_year + 1):
|
||||||
|
school_year = '%s-%s' % (year, year + 1)
|
||||||
|
if not subscribe_natures.get(school_year):
|
||||||
|
subscribe_natures[school_year] = set()
|
||||||
|
subscribe_natures[school_year].add(activity_nature['code'])
|
||||||
|
data['subscribe_natures'] = {x: sorted(list(y)) for x, y in subscribe_natures.items()}
|
||||||
|
|
||||||
def add_text_value_to_rl_indicator(self, data):
|
def add_text_value_to_rl_indicator(self, data):
|
||||||
self.add_text_value('RLIndicator', data, ['code'])
|
self.add_text_value('RLIndicator', data, ['code'])
|
||||||
|
|
||||||
|
@ -363,6 +382,7 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
||||||
for indicator in data['indicatorList']:
|
for indicator in data['indicatorList']:
|
||||||
self.add_text_value_to_child_indicator(indicator)
|
self.add_text_value_to_child_indicator(indicator)
|
||||||
self.add_indicators_field('ChildIndicator', data)
|
self.add_indicators_field('ChildIndicator', data)
|
||||||
|
self.add_nature_subsciptions(data)
|
||||||
|
|
||||||
def add_text_value_to_person(self, data):
|
def add_text_value_to_person(self, data):
|
||||||
self.add_text_value('Civility', data, ['civility'])
|
self.add_text_value('Civility', data, ['civility'])
|
||||||
|
@ -382,6 +402,7 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
||||||
for quotient in data['quotientList']:
|
for quotient in data['quotientList']:
|
||||||
self.add_text_value('Quotient', quotient, ['cdquo'])
|
self.add_text_value('Quotient', quotient, ['cdquo'])
|
||||||
self.add_indicators_field('RLIndicator', data)
|
self.add_indicators_field('RLIndicator', data)
|
||||||
|
self.add_nature_subsciptions(data)
|
||||||
|
|
||||||
def add_text_value_to_family(self, data):
|
def add_text_value_to_family(self, data):
|
||||||
self.add_text_value('Category', data, ['category'])
|
self.add_text_value('Category', data, ['category'])
|
||||||
|
|
|
@ -238,7 +238,7 @@
|
||||||
<libelle>RESTAURATION SCOLAIRE 22/23</libelle>
|
<libelle>RESTAURATION SCOLAIRE 22/23</libelle>
|
||||||
<bUniStd>true</bUniStd>
|
<bUniStd>true</bUniStd>
|
||||||
<dateStart>2023-03-01T00:00:00+01:00</dateStart>
|
<dateStart>2023-03-01T00:00:00+01:00</dateStart>
|
||||||
<dateEnd>2023-07-07T00:00:00+02:00</dateEnd>
|
<dateEnd>2023-09-01T00:00:00+02:00</dateEnd>
|
||||||
</subscribesUnit>
|
</subscribesUnit>
|
||||||
<place>DUPONT PIERRE ELEMENTAIRE</place>
|
<place>DUPONT PIERRE ELEMENTAIRE</place>
|
||||||
<planningHebdomadaire>0010011</planningHebdomadaire>
|
<planningHebdomadaire>0010011</planningHebdomadaire>
|
||||||
|
|
|
@ -237,7 +237,7 @@
|
||||||
<libelle>RESTAURATION SCOLAIRE 22/23</libelle>
|
<libelle>RESTAURATION SCOLAIRE 22/23</libelle>
|
||||||
<bUniStd>true</bUniStd>
|
<bUniStd>true</bUniStd>
|
||||||
<dateStart>2023-03-01T00:00:00+01:00</dateStart>
|
<dateStart>2023-03-01T00:00:00+01:00</dateStart>
|
||||||
<dateEnd>2023-07-07T00:00:00+02:00</dateEnd>
|
<dateEnd>2023-09-01T00:00:00+02:00</dateEnd>
|
||||||
</subscribesUnit>
|
</subscribesUnit>
|
||||||
<place>DUPONT PIERRE ELEMENTAIRE</place>
|
<place>DUPONT PIERRE ELEMENTAIRE</place>
|
||||||
<planningHebdomadaire>0010011</planningHebdomadaire>
|
<planningHebdomadaire>0010011</planningHebdomadaire>
|
||||||
|
|
|
@ -238,7 +238,7 @@
|
||||||
<libelle>RESTAURATION SCOLAIRE 22/23</libelle>
|
<libelle>RESTAURATION SCOLAIRE 22/23</libelle>
|
||||||
<bUniStd>true</bUniStd>
|
<bUniStd>true</bUniStd>
|
||||||
<dateStart>2023-03-01T00:00:00+01:00</dateStart>
|
<dateStart>2023-03-01T00:00:00+01:00</dateStart>
|
||||||
<dateEnd>2023-07-07T00:00:00+02:00</dateEnd>
|
<dateEnd>2023-09-01T00:00:00+02:00</dateEnd>
|
||||||
</subscribesUnit>
|
</subscribesUnit>
|
||||||
<place>DUPONT PIERRE ELEMENTAIRE</place>
|
<place>DUPONT PIERRE ELEMENTAIRE</place>
|
||||||
<planningHebdomadaire>0010011</planningHebdomadaire>
|
<planningHebdomadaire>0010011</planningHebdomadaire>
|
||||||
|
|
|
@ -1321,6 +1321,7 @@ def test_read_family(family_service, xml, con, app):
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
'subscribeActivityList': [],
|
'subscribeActivityList': [],
|
||||||
|
'subscribe_natures': {},
|
||||||
}
|
}
|
||||||
assert sorted(resp.json['data']['RL1']['indicatorList'], key=lambda x: x['code']) == [
|
assert sorted(resp.json['data']['RL1']['indicatorList'], key=lambda x: x['code']) == [
|
||||||
{
|
{
|
||||||
|
@ -1380,6 +1381,7 @@ def test_read_family(family_service, xml, con, app):
|
||||||
del data['indicatorList']
|
del data['indicatorList']
|
||||||
del data['indicators']
|
del data['indicators']
|
||||||
del data['subscribeActivityList']
|
del data['subscribeActivityList']
|
||||||
|
del data['subscribe_natures']
|
||||||
assert data == {
|
assert data == {
|
||||||
'num': '613880',
|
'num': '613880',
|
||||||
'lastname': 'DOE',
|
'lastname': 'DOE',
|
||||||
|
@ -1519,13 +1521,20 @@ def test_read_family(family_service, xml, con, app):
|
||||||
'note': None,
|
'note': None,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
assert [x['libelle'] for x in resp.json['data']['childList'][0]['subscribeActivityList']] == [
|
assert [
|
||||||
'RESTAURATION SCOLAIRE 22/23',
|
(x['typeActivity']['natureSpec']['code'], x['libelle'])
|
||||||
'CLAE MIDI 22/23',
|
for x in resp.json['data']['childList'][0]['subscribeActivityList']
|
||||||
'CLAE MATIN 22/23',
|
] == [
|
||||||
'SEMST2 ADL MERC. ELEM Maourine 22/23',
|
('R', 'RESTAURATION SCOLAIRE 22/23'),
|
||||||
'ECOLE DES SPORTS 22/23 SEMESTRE 2 - MULTIACTIVITES',
|
('A', 'CLAE MIDI 22/23'),
|
||||||
|
('A', 'CLAE MATIN 22/23'),
|
||||||
|
('X', 'SEMST2 ADL MERC. ELEM Maourine 22/23'),
|
||||||
|
('8', 'ECOLE DES SPORTS 22/23 SEMESTRE 2 - MULTIACTIVITES'),
|
||||||
]
|
]
|
||||||
|
assert resp.json['data']['childList'][0]['subscribe_natures'] == {
|
||||||
|
'2022-2023': ['8', 'A', 'R', 'X'],
|
||||||
|
'2023-2024': ['R'],
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def test_read_family_not_linked_error(con, app):
|
def test_read_family_not_linked_error(con, app):
|
||||||
|
@ -1718,6 +1727,7 @@ def test_read_rl2(family_service, con, app):
|
||||||
'typeActivity': None,
|
'typeActivity': None,
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
'subscribe_natures': {},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue