Projet

Général

Profil

0001-api-export-Role.emails-and-.emails_to_members-8254.patch

Benjamin Dauvergne, 15 septembre 2015 10:05

Télécharger (2,18 ko)

Voir les différences:

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(+)
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']
424 425
    role.store()
425 426

  
426 427
    resp = get_app(pub).get('/api/roles', status=403)
......
428 429
    resp = get_app(pub).get(sign_uri('/api/roles'))
429 430
    assert resp.json['data'][0]['text'] == 'Hello World'
430 431
    assert resp.json['data'][0]['slug'] == 'hello-world'
432
    assert resp.json['data'][0]['emails'] == ['toto@example.com', 'zozo@example.com']
433
    assert resp.json['data'][0]['emails_to_members'] == False
431 434

  
432 435
    # also check old endpoint, for compatibility
433 436
    resp = get_app(pub).get(sign_uri('/roles'), headers={'Accept': 'application/json'})
434 437
    assert resp.json['data'][0]['text'] == 'Hello World'
435 438
    assert resp.json['data'][0]['slug'] == 'hello-world'
439
    assert resp.json['data'][0]['emails'] == ['toto@example.com', 'zozo@example.com']
440
    assert resp.json['data'][0]['emails_to_members'] == False
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
                               'emails': role.emails or [],
190
                               'emails_to_members': role.emails_to_members,
189 191
                               'slug': role.slug,
190 192
                               'id': role.id})
191 193
        get_response().set_content_type('application/json')
192
-