toulouse-maelis: add a school year parameter on read_subscribe_activity_list (#75552)
gitea/passerelle/pipeline/head This commit looks good
Details
gitea/passerelle/pipeline/head This commit looks good
Details
This commit is contained in:
parent
43fced3f4a
commit
4f34f25ba1
|
@ -1227,10 +1227,14 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
|||
'description': "Codes des types des activités (tous par défaut), séparés par des virgules",
|
||||
'example_value': 'ACCSOIR,RESTSCOL',
|
||||
},
|
||||
'school_year': {
|
||||
'description': 'Année scolaire (ex: 2022-2023)',
|
||||
'example_value': '2022-2023',
|
||||
},
|
||||
},
|
||||
)
|
||||
def read_subscribe_activity_list(
|
||||
self, request, person_id, NameID=None, family_id=None, nature=None, type_ids=None
|
||||
self, request, person_id, NameID=None, family_id=None, nature=None, type_ids=None, school_year=None
|
||||
):
|
||||
family_id = family_id or self.get_link(NameID).family_id
|
||||
result = self.get_rl_or_child_raw(family_id, person_id)
|
||||
|
@ -1254,6 +1258,17 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
|||
if nature_filter_codes:
|
||||
if not activity_nature or activity_nature['code'] not in nature_filter_codes:
|
||||
continue
|
||||
if school_year:
|
||||
school_years = set()
|
||||
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('dateStart'))
|
||||
if not start_year or not end_year:
|
||||
continue
|
||||
for year in range(start_year, end_year + 1):
|
||||
school_years.add('%s-%s' % (year, year + 1))
|
||||
if school_year not in school_years:
|
||||
continue
|
||||
item['id'] = item['idActivity']
|
||||
item['text'] = item['libelle']
|
||||
data.append(item)
|
||||
|
|
|
@ -1633,6 +1633,21 @@ def test_read_subscribe_activity_list(family_service, con, app):
|
|||
for x in resp.json['data']
|
||||
] == [('A10049327689', 'CLAE MATIN 22/23', 'A', 'ACCMAT')]
|
||||
|
||||
resp = app.get(url + '?NameID=local&person_id=613880&school_year=2022-2023')
|
||||
assert [
|
||||
(x['id'], x['text'], x['typeActivity']['natureSpec']['code'], x['typeActivity']['code'])
|
||||
for x in resp.json['data']
|
||||
] == [
|
||||
('A10049327682', 'RESTAURATION SCOLAIRE 22/23', 'R', 'RESTSCOL'),
|
||||
('A10049327686', 'CLAE MIDI 22/23', 'A', 'ACCPERI'),
|
||||
('A10049327689', 'CLAE MATIN 22/23', 'A', 'ACCMAT'),
|
||||
('A10049354913', 'SEMST2 ADL MERC. ELEM Maourine 22/23', 'X', 'EXTMERC'),
|
||||
('A10053179798', 'ECOLE DES SPORTS 22/23 SEMESTRE 2 - MULTIACTIVITES', '8', '25'),
|
||||
]
|
||||
|
||||
resp = app.get(url + '?NameID=local&person_id=613880&school_year=2021-2022')
|
||||
assert len(resp.json['data']) == 0
|
||||
|
||||
|
||||
def test_read_subscribe_activity_list_not_linked_error(con, app):
|
||||
url = get_endpoint('read-subscribe-activity-list')
|
||||
|
|
Loading…
Reference in New Issue