From 36c505d3531abf906063190c3565140a8c6fa11d Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Sat, 12 Sep 2015 00:55:51 +0200 Subject: [PATCH] api: export Role.emails and .emails_to_members (#8254) To allow import-wcs-roles on authentic side to import them. --- tests/test_api.py | 5 +++++ wcs/api.py | 2 ++ 2 files changed, 7 insertions(+) diff --git a/tests/test_api.py b/tests/test_api.py index f16b6ca..12d65bd 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -421,6 +421,7 @@ def test_api_list_formdata(local_user): def test_roles(local_user): Role.wipe() role = Role(name='Hello World') + role.emails = ['toto@example.com', 'zozo@example.com'] role.store() resp = get_app(pub).get('/api/roles', status=403) @@ -428,8 +429,12 @@ def test_roles(local_user): resp = get_app(pub).get(sign_uri('/api/roles')) assert resp.json['data'][0]['text'] == 'Hello World' assert resp.json['data'][0]['slug'] == 'hello-world' + assert resp.json['data'][0]['emails'] == ['toto@example.com', 'zozo@example.com'] + assert resp.json['data'][0]['emails_to_members'] == False # also check old endpoint, for compatibility resp = get_app(pub).get(sign_uri('/roles'), headers={'Accept': 'application/json'}) assert resp.json['data'][0]['text'] == 'Hello World' assert resp.json['data'][0]['slug'] == 'hello-world' + assert resp.json['data'][0]['emails'] == ['toto@example.com', 'zozo@example.com'] + assert resp.json['data'][0]['emails_to_members'] == False diff --git a/wcs/api.py b/wcs/api.py index 1a9089a..13ceac2 100644 --- a/wcs/api.py +++ b/wcs/api.py @@ -186,6 +186,8 @@ class ApiDirectory(Directory): for role in Role.select(): list_roles.append({'text': unicode(role.name, charset), 'allows_backoffice_access': role.allows_backoffice_access, + 'emails': role.emails or [], + 'emails_to_members': role.emails_to_members, 'slug': role.slug, 'id': role.id}) get_response().set_content_type('application/json') -- 2.1.4