mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-23 15:57:23 -04:00
Add letter class row to settings page, visible to platform admin
Added a new row to the settings table, 'Post class', which shows the default letter class of a service and is only visible to Platform Admin. Also added a new page to enable Platform Admin users to change the default letter class for a service - this only has two options at the moment, 1st class only and 2nd class only.
This commit is contained in:
@@ -139,6 +139,7 @@ def service_json(
|
||||
email_branding=None,
|
||||
branding='govuk',
|
||||
created_at=None,
|
||||
letter_class='second',
|
||||
letter_contact_block=None,
|
||||
inbound_api=None,
|
||||
service_callback_api=None,
|
||||
@@ -168,6 +169,7 @@ def service_json(
|
||||
'email_branding': email_branding,
|
||||
'branding': branding,
|
||||
'created_at': created_at or str(datetime.utcnow()),
|
||||
'letter_class': letter_class,
|
||||
'letter_contact_block': letter_contact_block,
|
||||
'dvla_organisation': '001',
|
||||
'permissions': permissions,
|
||||
|
||||
@@ -89,6 +89,7 @@ def mock_get_service_settings_page_common(
|
||||
|
||||
'Label Value Action',
|
||||
'Send letters Off Change',
|
||||
'Post class 2nd class only Change',
|
||||
|
||||
'Label Value Action',
|
||||
'Organisation Org 1 Change',
|
||||
@@ -1849,6 +1850,38 @@ def test_set_letter_branding_saves(
|
||||
mock_update_service.assert_called_once_with(service_one['id'], dvla_organisation='500')
|
||||
|
||||
|
||||
def test_set_letter_class_platform_admin_only(
|
||||
logged_in_client,
|
||||
service_one,
|
||||
):
|
||||
response = logged_in_client.get(url_for('main.service_set_letter_class', service_id=SERVICE_ONE_ID))
|
||||
assert response.status_code == 403
|
||||
|
||||
|
||||
def test_set_letter_class_prepopulates(
|
||||
logged_in_platform_admin_client,
|
||||
service_one,
|
||||
):
|
||||
response = logged_in_platform_admin_client.get(url_for('main.service_set_letter_class', service_id=SERVICE_ONE_ID))
|
||||
assert response.status_code == 200
|
||||
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
||||
assert page.select('input[checked]')[0]['value'] == 'second'
|
||||
|
||||
|
||||
def test_set_letter_class_saves(
|
||||
logged_in_platform_admin_client,
|
||||
service_one,
|
||||
mock_update_service,
|
||||
):
|
||||
response = logged_in_platform_admin_client.post(
|
||||
url_for('main.service_set_letter_class', service_id=SERVICE_ONE_ID),
|
||||
data={'letter_class': 'first'}
|
||||
)
|
||||
assert response.status_code == 302
|
||||
assert response.location == url_for('main.service_settings', service_id=SERVICE_ONE_ID, _external=True)
|
||||
mock_update_service.assert_called_once_with(SERVICE_ONE_ID, letter_class='first')
|
||||
|
||||
|
||||
@pytest.mark.parametrize('current_branding, expected_values, expected_labels', [
|
||||
(None, [
|
||||
'None', '1', '2', '3', '4', '5',
|
||||
|
||||
Reference in New Issue
Block a user