rsa13: filter referent by their status (#53815)
This commit is contained in:
parent
962fc6edb1
commit
25c12e40bf
|
@ -370,10 +370,15 @@ class RSA13Resource(BaseResource, HTTPResource):
|
||||||
)
|
)
|
||||||
def platform_referent(self, request, platform_id, email, ip=None, statut=None, post_data=None):
|
def platform_referent(self, request, platform_id, email, ip=None, statut=None, post_data=None):
|
||||||
if request.method == 'GET':
|
if request.method == 'GET':
|
||||||
params = {}
|
response = self.get('platform/%s/referent/' % platform_id, email=email, ip=ip)
|
||||||
if statut:
|
if statut:
|
||||||
params['statut'] = statut
|
data = []
|
||||||
return self.get('platform/%s/referent/' % platform_id, email=email, ip=ip, params=params)
|
for referent in response.get('data', []):
|
||||||
|
if referent.get('statut') != statut:
|
||||||
|
continue
|
||||||
|
data.append(referent)
|
||||||
|
response['data'] = data
|
||||||
|
return response
|
||||||
else:
|
else:
|
||||||
return self.post('platform/%s/referent/' % platform_id, email=email, ip=ip, json=post_data)
|
return self.post('platform/%s/referent/' % platform_id, email=email, ip=ip, json=post_data)
|
||||||
|
|
||||||
|
|
|
@ -179,7 +179,7 @@ PLATFORM_REFERENT = [
|
||||||
"tel": '090909090909',
|
"tel": '090909090909',
|
||||||
"email": "jane.doe@example.com",
|
"email": "jane.doe@example.com",
|
||||||
"role": "Accompagnateur",
|
"role": "Accompagnateur",
|
||||||
"statut": "Actif",
|
"statut": "Clos",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -193,12 +193,12 @@ def test_platform_referent(app, rsa13, url):
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@mock_response(['/api/platform/11/referent/', 'statut=Actif', {'err': 0, 'data': PLATFORM_REFERENT}])
|
@mock_response(['/api/platform/11/referent/', {'err': 0, 'data': PLATFORM_REFERENT}])
|
||||||
def test_platform_referent_with_status(app, rsa13, url):
|
def test_platform_referent_with_status(app, rsa13, url):
|
||||||
response = app.get(url + 'platform/11/referent/?statut=Actif')
|
response = app.get(url + 'platform/11/referent/?statut=Actif')
|
||||||
assert response.json == {
|
assert response.json == {
|
||||||
'err': 0,
|
'err': 0,
|
||||||
'data': PLATFORM_REFERENT,
|
'data': [ref for ref in PLATFORM_REFERENT if ref['statut'] == 'Actif'],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue