From 0715c1c33721281a2837b4f9832116be1c95ee55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Mon, 27 Mar 2017 09:23:39 +0200 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(-) diff --git a/tests/test_api.py b/tests/test_api.py index e23a75b0..9c0f8a37 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -730,10 +730,16 @@ def test_categories(pub): assert resp.json == resp2.json assert resp.json['data'][0]['title'] == 'Category' assert resp.json['data'][0]['url'] == 'http://example.net/category/' - assert resp.json['data'][0]['description'] == 'hello world' + assert resp.json['data'][0]['description'] == '

hello world

' assert set(resp.json['data'][0]['keywords']) == set(['foobar', 'mobile', 'test']) assert not 'forms' in resp.json['data'][0] + # check HTML description + category.description = '

hello world

' + category.store() + resp = get_app(pub).get('/api/categories/') + assert resp.json['data'][0]['description'] == category.description + def test_categories_private(pub, local_user): FormDef.wipe() Category.wipe() diff --git a/wcs/api.py b/wcs/api.py index a018aa72..bd131757 100644 --- a/wcs/api.py +++ b/wcs/api.py @@ -394,7 +394,7 @@ class ApiCategoriesDirectory(Directory): d['slug'] = category.url_name d['url'] = category.get_url() if category.description: - d['description'] = unicode(category.description, charset) + d['description'] = unicode(str(category.get_description_html_text(editable=False)), charset) formdefs = ApiFormdefsDirectory(category).get_list_forms(user, formdefs=all_formdefs, list_all_forms=list_all_forms) if not formdefs: -- 2.11.0