mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-02 17:48:50 -04:00
Merge pull request #1923 from alphagov/remove-dvla
Remove anything to do with DVLA format letters
This commit is contained in:
@@ -2,21 +2,12 @@ from datetime import datetime, timedelta
|
|||||||
from string import ascii_uppercase
|
from string import ascii_uppercase
|
||||||
|
|
||||||
from dateutil.parser import parse
|
from dateutil.parser import parse
|
||||||
from flask import (
|
from flask import abort, flash, redirect, render_template, request, url_for
|
||||||
Response,
|
|
||||||
abort,
|
|
||||||
flash,
|
|
||||||
redirect,
|
|
||||||
render_template,
|
|
||||||
request,
|
|
||||||
url_for,
|
|
||||||
)
|
|
||||||
from flask_login import current_user, login_required
|
from flask_login import current_user, login_required
|
||||||
from markupsafe import Markup
|
from markupsafe import Markup
|
||||||
from notifications_python_client.errors import HTTPError
|
from notifications_python_client.errors import HTTPError
|
||||||
from notifications_utils.formatters import nl2br
|
from notifications_utils.formatters import nl2br
|
||||||
from notifications_utils.recipients import first_column_headings
|
from notifications_utils.recipients import first_column_headings
|
||||||
from notifications_utils.template import LetterDVLATemplate
|
|
||||||
|
|
||||||
from app import current_service, service_api_client, template_statistics_client
|
from app import current_service, service_api_client, template_statistics_client
|
||||||
from app.main import main
|
from app.main import main
|
||||||
@@ -159,25 +150,6 @@ def choose_template(service_id, template_type='all'):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@main.route("/services/<service_id>/templates/<template_id>/as-dvla")
|
|
||||||
@login_required
|
|
||||||
@user_has_permissions(admin_override=True)
|
|
||||||
def view_template_as_dvla_markup(service_id, template_id):
|
|
||||||
|
|
||||||
template = service_api_client.get_service_template(service_id, str(template_id))['data']
|
|
||||||
|
|
||||||
if template['template_type'] != 'letter':
|
|
||||||
abort(404)
|
|
||||||
|
|
||||||
return Response(
|
|
||||||
str(LetterDVLATemplate(
|
|
||||||
template,
|
|
||||||
notification_reference=1,
|
|
||||||
)),
|
|
||||||
mimetype='text/plain',
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@main.route("/services/<service_id>/templates/<template_id>.<filetype>")
|
@main.route("/services/<service_id>/templates/<template_id>.<filetype>")
|
||||||
@login_required
|
@login_required
|
||||||
@user_has_permissions('view_activity', admin_override=True)
|
@user_has_permissions('view_activity', admin_override=True)
|
||||||
|
|||||||
@@ -18,4 +18,4 @@ notifications-python-client==4.7.2
|
|||||||
# PaaS
|
# PaaS
|
||||||
awscli-cwlogs>=1.4,<1.5
|
awscli-cwlogs>=1.4,<1.5
|
||||||
|
|
||||||
git+https://github.com/alphagov/notifications-utils.git@23.8.1#egg=notifications-utils==23.8.1
|
git+https://github.com/alphagov/notifications-utils.git@24.0.0#egg=notifications-utils==24.0.0
|
||||||
|
|||||||
@@ -13,13 +13,11 @@ from tests import (
|
|||||||
)
|
)
|
||||||
from tests.conftest import (
|
from tests.conftest import (
|
||||||
SERVICE_ONE_ID,
|
SERVICE_ONE_ID,
|
||||||
active_user_with_permissions,
|
|
||||||
mock_get_service_email_template,
|
mock_get_service_email_template,
|
||||||
mock_get_service_letter_template,
|
mock_get_service_letter_template,
|
||||||
mock_get_service_template,
|
mock_get_service_template,
|
||||||
no_letter_contact_blocks,
|
no_letter_contact_blocks,
|
||||||
normalize_spaces,
|
normalize_spaces,
|
||||||
platform_admin_user,
|
|
||||||
)
|
)
|
||||||
from tests.conftest import service_one as create_sample_service
|
from tests.conftest import service_one as create_sample_service
|
||||||
from tests.conftest import single_letter_contact_block
|
from tests.conftest import single_letter_contact_block
|
||||||
@@ -1229,51 +1227,6 @@ def test_should_show_hint_once_template_redacted(
|
|||||||
assert page.select('.hint')[0].text == 'Personalisation is hidden after sending'
|
assert page.select('.hint')[0].text == 'Personalisation is hidden after sending'
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('test_user, template_mock, expected_response_code', [
|
|
||||||
(
|
|
||||||
active_user_with_permissions,
|
|
||||||
mock_get_service_letter_template,
|
|
||||||
403
|
|
||||||
),
|
|
||||||
(
|
|
||||||
platform_admin_user,
|
|
||||||
mock_get_service_template,
|
|
||||||
404
|
|
||||||
),
|
|
||||||
(
|
|
||||||
platform_admin_user,
|
|
||||||
mock_get_service_email_template,
|
|
||||||
404
|
|
||||||
),
|
|
||||||
(
|
|
||||||
platform_admin_user,
|
|
||||||
mock_get_service_letter_template,
|
|
||||||
200
|
|
||||||
),
|
|
||||||
])
|
|
||||||
def test_should_show_letter_template_as_dvla_markup(
|
|
||||||
client,
|
|
||||||
mocker,
|
|
||||||
service_one,
|
|
||||||
fake_uuid,
|
|
||||||
mock_get_service,
|
|
||||||
test_user,
|
|
||||||
template_mock,
|
|
||||||
expected_response_code,
|
|
||||||
):
|
|
||||||
|
|
||||||
client.login(test_user(fake_uuid), mocker, service_one)
|
|
||||||
template_mock(mocker)
|
|
||||||
|
|
||||||
response = client.get(url_for(
|
|
||||||
'.view_template_as_dvla_markup',
|
|
||||||
service_id=SERVICE_ONE_ID,
|
|
||||||
template_id=fake_uuid,
|
|
||||||
))
|
|
||||||
|
|
||||||
assert response.status_code == expected_response_code
|
|
||||||
|
|
||||||
|
|
||||||
def test_set_template_sender(
|
def test_set_template_sender(
|
||||||
client_request,
|
client_request,
|
||||||
fake_uuid,
|
fake_uuid,
|
||||||
|
|||||||
Reference in New Issue
Block a user