From f7a1cfac503973454be303225da354b328e2560d Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Fri, 4 Mar 2016 13:23:44 +0000 Subject: [PATCH] Revert "Strip HTML from template content" --- app/template/rest.py | 7 ------- requirements.txt | 1 - tests/app/template/test_rest.py | 8 ++++---- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/app/template/rest.py b/app/template/rest.py index 5bea73c8e..26ae98502 100644 --- a/app/template/rest.py +++ b/app/template/rest.py @@ -4,7 +4,6 @@ from flask import ( request, current_app ) -from lxml import html from sqlalchemy.exc import IntegrityError from app.dao.templates_dao import ( @@ -35,7 +34,6 @@ def create_template(service_id): if errors: return jsonify(result="error", message=errors), 400 new_template.service = fetched_service - new_template.content = _strip_html(new_template.content) try: dao_create_template(new_template) except IntegrityError as ex: @@ -57,7 +55,6 @@ def update_template(service_id, template_id): current_data = dict(template_schema.dump(fetched_template).data.items()) current_data.update(request.get_json()) - current_data['content'] = _strip_html(current_data['content']) update_dict, errors = template_schema.load(current_data) if errors: @@ -82,7 +79,3 @@ def get_template_by_id_and_service_id(service_id, template_id): return jsonify(data=data) else: return jsonify(result="error", message="Template not found"), 404 - - -def _strip_html(content): - return html.document_fromstring(content).text_content() diff --git a/requirements.txt b/requirements.txt index 2c9dddbf8..c41e2e6f4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,6 @@ Flask==0.10.1 Flask-Script==2.0.5 Flask-Migrate==1.3.1 Flask-SQLAlchemy==2.0 -lxml==3.5.0 psycopg2==2.6.1 SQLAlchemy==1.0.5 SQLAlchemy-Utils==0.30.5 diff --git a/tests/app/template/test_rest.py b/tests/app/template/test_rest.py index 670862bb5..0ba8c0a68 100644 --- a/tests/app/template/test_rest.py +++ b/tests/app/template/test_rest.py @@ -10,7 +10,7 @@ def test_should_create_a_new_sms_template_for_a_service(notify_api, sample_servi data = { 'name': 'my template', 'template_type': 'sms', - 'content': 'template content', + 'content': 'template content', 'service': str(sample_service.id) } data = json.dumps(data) @@ -42,7 +42,7 @@ def test_should_create_a_new_email_template_for_a_service(notify_api, sample_ser 'name': 'my template', 'template_type': 'email', 'subject': 'subject', - 'content': 'template content', + 'content': 'template content', 'service': str(sample_service.id) } data = json.dumps(data) @@ -222,7 +222,7 @@ def test_should_be_able_to_update_a_template(notify_api, sample_service): json_resp = json.loads(create_response.get_data(as_text=True)) assert json_resp['data']['name'] == 'my template' data = { - 'content': 'my template has new content ' + 'name': 'my template has a new name' } data = json.dumps(data) auth_header = create_authorization_header( @@ -239,7 +239,7 @@ def test_should_be_able_to_update_a_template(notify_api, sample_service): assert update_response.status_code == 200 update_json_resp = json.loads(update_response.get_data(as_text=True)) - assert update_json_resp['data']['content'] == 'my template has new content alert("foo")' + assert update_json_resp['data']['name'] == 'my template has a new name' def test_should_be_able_to_get_all_templates_for_a_service(notify_api, sample_service):