Projet

Général

Profil

0001-api-always-return-category-description-as-valid-HTML.patch

Frédéric Péters, 27 mars 2017 09:24

Télécharger (1,95 ko)

Voir les différences:

Subject: [PATCH] api: always return category description as valid HTML
 (#15633)

 tests/test_api.py | 8 +++++++-
 wcs/api.py        | 2 +-
 2 files changed, 8 insertions(+), 2 deletions(-)
tests/test_api.py
730 730
    assert resp.json == resp2.json
731 731
    assert resp.json['data'][0]['title'] == 'Category'
732 732
    assert resp.json['data'][0]['url'] == 'http://example.net/category/'
733
    assert resp.json['data'][0]['description'] == 'hello world'
733
    assert resp.json['data'][0]['description'] == '<p>hello world</p>'
734 734
    assert set(resp.json['data'][0]['keywords']) == set(['foobar', 'mobile', 'test'])
735 735
    assert not 'forms' in resp.json['data'][0]
736 736

  
737
    # check HTML description
738
    category.description = '<p><strong>hello world</strong></p>'
739
    category.store()
740
    resp = get_app(pub).get('/api/categories/')
741
    assert resp.json['data'][0]['description'] == category.description
742

  
737 743
def test_categories_private(pub, local_user):
738 744
    FormDef.wipe()
739 745
    Category.wipe()
wcs/api.py
394 394
            d['slug'] = category.url_name
395 395
            d['url'] = category.get_url()
396 396
            if category.description:
397
                d['description'] = unicode(category.description, charset)
397
                d['description'] = unicode(str(category.get_description_html_text(editable=False)), charset)
398 398
            formdefs = ApiFormdefsDirectory(category).get_list_forms(user,
399 399
                    formdefs=all_formdefs, list_all_forms=list_all_forms)
400 400
            if not formdefs:
401
-