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):
|
||||
if request.method == 'GET':
|
||||
params = {}
|
||||
response = self.get('platform/%s/referent/' % platform_id, email=email, ip=ip)
|
||||
if statut:
|
||||
params['statut'] = statut
|
||||
return self.get('platform/%s/referent/' % platform_id, email=email, ip=ip, params=params)
|
||||
data = []
|
||||
for referent in response.get('data', []):
|
||||
if referent.get('statut') != statut:
|
||||
continue
|
||||
data.append(referent)
|
||||
response['data'] = data
|
||||
return response
|
||||
else:
|
||||
return self.post('platform/%s/referent/' % platform_id, email=email, ip=ip, json=post_data)
|
||||
|
||||
|
|
|
@ -179,7 +179,7 @@ PLATFORM_REFERENT = [
|
|||
"tel": '090909090909',
|
||||
"email": "jane.doe@example.com",
|
||||
"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):
|
||||
response = app.get(url + 'platform/11/referent/?statut=Actif')
|
||||
assert response.json == {
|
||||
'err': 0,
|
||||
'data': PLATFORM_REFERENT,
|
||||
'data': [ref for ref in PLATFORM_REFERENT if ref['statut'] == 'Actif'],
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue