toulouse-maelis: add endpoint to list exemptions reasons referential (#72746)
gitea-wip/passerelle/pipeline/pr-main Build started... Details

This commit is contained in:
Serghei Mihai 2023-01-02 11:15:30 +01:00
parent 1535e83579
commit b37dd96cfd
3 changed files with 44 additions and 1 deletions

View File

@ -150,7 +150,7 @@ class ToulouseMaelis(BaseResource, HTTPResource):
self.update_referential(referential_name, data, id_key, text_key)
def update_site_referentials(self):
for referential_name in ('YearSchool', 'Level'):
for referential_name in ('YearSchool', 'Level', 'DerogReason'):
id_key, text_key = 'code', 'libelle'
data = self.get_referential_data('Site', referential_name)
if referential_name == 'YearSchool':
@ -1683,6 +1683,15 @@ class ToulouseMaelis(BaseResource, HTTPResource):
return {'data': [item for item in data if item.get('age') == int(age)]}
return {'data': data}
@endpoint(
display_category='Inscriptions',
description="Liste des motifs de dérogation",
name='read-exemption-reasons-list',
perm='can_access',
)
def read_exemption_reasons_list(self, request):
return {'data': self.get_referential('DerogReason')}
class Link(models.Model):
resource = models.ForeignKey(ToulouseMaelis, on_delete=models.CASCADE)

View File

@ -0,0 +1,22 @@
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:readDerogReasonListResponse xmlns:ns2="site.ws.maelis.sigec.com">
<derogReasonBean>
<code>07DERO-1</code>
<libelle>DERO07 - ULIS</libelle>
</derogReasonBean>
<derogReasonBean>
<code>10DERO-2</code>
<libelle>DERO10 - ORGANISATION</libelle>
</derogReasonBean>
<derogReasonBean>
<code>11DERO-1</code>
<libelle>DERO11 - AUTRE</libelle>
</derogReasonBean>
<derogReasonBean>
<code>05PRIO-1</code>
<libelle>PRIO05 - MAINTIENT</libelle>
</derogReasonBean>
</ns2:readDerogReasonListResponse>
</soap:Body>
</soap:Envelope>

View File

@ -154,6 +154,7 @@ def django_db_setup(django_db_setup, django_db_blocker):
with site_service() as site_mock:
site_mock.add_soap_response('readYearSchoolList', get_xml_file('R_read_year_school_list.xml'))
site_mock.add_soap_response('readLevelList', get_xml_file('R_read_level_list.xml'))
site_mock.add_soap_response('readDerogReasonList', get_xml_file('R_read_derog_reason_list.xml'))
con.update_site_referentials()
# reset change in zeep private interface to bypass clear_cache fixture
@ -315,6 +316,7 @@ def test_cron(db):
'Civility',
'Complement',
'Country',
'DerogReason',
'DietCode',
'Document',
'Level',
@ -3686,3 +3688,13 @@ def test_read_school_levels_list(con, app):
assert level['code'] == 'CE2'
assert level['text'] == 'Cours élémentaire 2'
assert level['libelle'] == 'Cours élémentaire 2'
def test_read_exemption_reasons_list(con, app):
url = get_endpoint('read-exemption-reasons-list')
resp = app.get(url)
assert resp.json['err'] == 0
assert len(resp.json['data']) == 4
for item in resp.json['data']:
assert 'id' in item
assert 'text' in item