From cc4f8916b3401afea1539f8b9da5ec005faf8ca4 Mon Sep 17 00:00:00 2001 From: stvnrlly Date: Mon, 5 Dec 2022 16:40:59 -0500 Subject: [PATCH] remove letter template preview --- app/main/views/templates.py | 8 ------ app/template_previews.py | 49 ------------------------------------ tests/app/test_navigation.py | 1 - tests/conftest.py | 11 -------- 4 files changed, 69 deletions(-) delete mode 100644 app/template_previews.py diff --git a/app/main/views/templates.py b/app/main/views/templates.py index 6ebafa539..d033b0c94 100644 --- a/app/main/views/templates.py +++ b/app/main/views/templates.py @@ -34,7 +34,6 @@ from app.main.forms import ( from app.main.views.send import get_sender_details from app.models.service import Service from app.models.template_list import TemplateList, TemplateLists -from app.template_previews import TemplatePreview from app.utils import NOTIFICATION_TYPES, should_skip_template_page from app.utils.templates import get_template from app.utils.user import user_has_permissions @@ -216,13 +215,6 @@ def view_template_version(service_id, template_id, version): ) -@no_cookie.route("/services//templates//version/.") -@user_has_permissions() -def view_template_version_preview(service_id, template_id, version, filetype): - db_template = current_service.get_template(template_id, version=version) - return TemplatePreview.from_database_object(db_template, filetype) - - def _add_template_by_type(template_type, template_folder_id): if template_type == 'copy-existing': diff --git a/app/template_previews.py b/app/template_previews.py deleted file mode 100644 index 311186d66..000000000 --- a/app/template_previews.py +++ /dev/null @@ -1,49 +0,0 @@ -import requests -from flask import current_app - -from app import current_service - - -class TemplatePreview: - @classmethod - def from_database_object(cls, template, filetype, values=None, page=None): - data = { - 'letter_contact_block': template.get('reply_to_text', ''), - 'template': template, - 'values': values, - 'filename': current_service.letter_branding and current_service.letter_branding['filename'] - } - resp = requests.post( - '{}/preview.{}{}'.format( - current_app.config['TEMPLATE_PREVIEW_API_HOST'], - filetype, - '?page={}'.format(page) if page else '', - ), - json=data, - headers={'Authorization': 'Token {}'.format(current_app.config['TEMPLATE_PREVIEW_API_KEY'])} - ) - return (resp.content, resp.status_code, resp.headers.items()) - - @classmethod - def from_example_template(cls, template, filename): - data = { - 'letter_contact_block': template.get('reply_to_text'), - 'template': template, - 'values': None, - 'filename': filename - } - resp = requests.post( - '{}/preview.png'.format(current_app.config['TEMPLATE_PREVIEW_API_HOST']), - json=data, - headers={'Authorization': 'Token {}'.format(current_app.config['TEMPLATE_PREVIEW_API_KEY'])} - ) - return (resp.content, resp.status_code, resp.headers.items()) - - @classmethod - def from_utils_template(cls, template, filetype, page=None): - return cls.from_database_object( - template._template, - filetype, - template.values, - page=page, - ) diff --git a/tests/app/test_navigation.py b/tests/app/test_navigation.py index 565ca9ffa..f6de9543e 100644 --- a/tests/app/test_navigation.py +++ b/tests/app/test_navigation.py @@ -141,7 +141,6 @@ EXCLUDED_ENDPOINTS = tuple(map(Navigation.get_endpoint_with_blueprint, { 'message_status', 'monthly', 'new_password', - 'no_cookie.view_template_version_preview', 'notifications_sent_by_service', 'old_guest_list', 'old_integration_testing', diff --git a/tests/conftest.py b/tests/conftest.py index 7ba8aedb0..851da8aa5 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3113,17 +3113,6 @@ def mock_get_service_history(mocker): }) -@pytest.fixture -def mock_template_preview(mocker): - content = b'{"count":1}' - status_code = 200 - headers = {} - example_response = (content, status_code, headers) - mocker.patch('app.template_previews.TemplatePreview.from_database_object', return_value=example_response) - mocker.patch('app.template_previews.TemplatePreview.from_example_template', return_value=example_response) - mocker.patch('app.template_previews.TemplatePreview.from_utils_template', return_value=example_response) - - def create_api_user_active(with_unique_id=False): return create_user( id=str(uuid4()) if with_unique_id else sample_uuid(),