0001-api-export-Role.details-Role.emails-and-.emails_to_m.patch
tests/test_api.py | ||
---|---|---|
421 | 421 |
def test_roles(local_user): |
422 | 422 |
Role.wipe() |
423 | 423 |
role = Role(name='Hello World') |
424 |
role.emails = ['toto@example.com', 'zozo@example.com'] |
|
425 |
role.details = 'kouign amann' |
|
424 | 426 |
role.store() |
425 | 427 | |
426 | 428 |
resp = get_app(pub).get('/api/roles', status=403) |
... | ... | |
428 | 430 |
resp = get_app(pub).get(sign_uri('/api/roles')) |
429 | 431 |
assert resp.json['data'][0]['text'] == 'Hello World' |
430 | 432 |
assert resp.json['data'][0]['slug'] == 'hello-world' |
433 |
assert resp.json['data'][0]['emails'] == ['toto@example.com', 'zozo@example.com'] |
|
434 |
assert resp.json['data'][0]['emails_to_members'] == False |
|
435 |
assert resp.json['data'][0]['details'] == 'kouign amann' |
|
431 | 436 | |
432 | 437 |
# also check old endpoint, for compatibility |
433 | 438 |
resp = get_app(pub).get(sign_uri('/roles'), headers={'Accept': 'application/json'}) |
434 | 439 |
assert resp.json['data'][0]['text'] == 'Hello World' |
435 | 440 |
assert resp.json['data'][0]['slug'] == 'hello-world' |
441 |
assert resp.json['data'][0]['emails'] == ['toto@example.com', 'zozo@example.com'] |
|
442 |
assert resp.json['data'][0]['emails_to_members'] == False |
|
443 |
assert resp.json['data'][0]['details'] == 'kouign amann' |
wcs/api.py | ||
---|---|---|
186 | 186 |
for role in Role.select(): |
187 | 187 |
list_roles.append({'text': unicode(role.name, charset), |
188 | 188 |
'allows_backoffice_access': role.allows_backoffice_access, |
189 |
'slug': role.slug, |
|
189 |
'emails': [unicode(email, charset) for email in role.emails or []], |
|
190 |
'details': unicode(role.details or '', charset), |
|
191 |
'emails_to_members': role.emails_to_members, |
|
192 |
'slug': unicode(role.slug, charset), |
|
190 | 193 |
'id': role.id}) |
191 | 194 |
get_response().set_content_type('application/json') |
192 | 195 |
return json.dumps({'data': list_roles}) |
193 |
- |