mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-03-13 14:53:08 -04:00
Go back to template after editing contact details
Users who go to edit the contact details for a letter from the template page get very confused when they click save and are dumped on the settings page. It doesn’t match the way editing other parts of letter works, and you can’t see an accurate preview of the changes from the settings page. So this commit changes the flow to go from the _edit contact details_ page back to the _view template_ page when the user has got there by clicking the blue _Edit_ button on the _view template_ page.
This commit is contained in:
@@ -275,6 +275,10 @@ def service_set_letter_contact_block(service_id):
|
||||
current_service['id'],
|
||||
letter_contact_block=form.letter_contact_block.data.replace('\r', '') or None
|
||||
)
|
||||
if request.args.get('from_template'):
|
||||
return redirect(
|
||||
url_for('.view_template', service_id=service_id, template_id=request.args.get('from_template'))
|
||||
)
|
||||
return redirect(url_for('.service_settings', service_id=service_id))
|
||||
return render_template(
|
||||
'views/service-settings/set-letter-contact-block.html',
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
<div class="column-whole template-container">
|
||||
{% if current_user.has_permissions(permissions=['manage_templates'], admin_override=True) and template.template_type == 'letter' %}
|
||||
<a href="{{ url_for(".edit_service_template", service_id=current_service.id, template_id=template.id) }}" class="edit-template-link-letter-body">Edit</a>
|
||||
<a href="{{ url_for(".service_set_letter_contact_block", service_id=current_service.id) }}" class="edit-template-link-letter-contact">Edit</a>
|
||||
<a href="{{ url_for(".service_set_letter_contact_block", service_id=current_service.id, from_template=template.id) }}" class="edit-template-link-letter-contact">Edit</a>
|
||||
<a href="#" class="edit-template-link-letter-address">Edit</a>
|
||||
{% endif %}
|
||||
{{ template|string }}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from unittest.mock import call, ANY, Mock
|
||||
|
||||
import pytest
|
||||
import uuid
|
||||
from flask import url_for
|
||||
from bs4 import BeautifulSoup
|
||||
from werkzeug.exceptions import InternalServerError
|
||||
@@ -619,6 +620,30 @@ def test_set_letter_contact_block_saves(
|
||||
mock_update_service.assert_called_once_with(service_one['id'], letter_contact_block='foo bar baz waz')
|
||||
|
||||
|
||||
def test_set_letter_contact_block_redirects_to_template(
|
||||
logged_in_client,
|
||||
service_one,
|
||||
mock_update_service,
|
||||
):
|
||||
service_one['can_send_letters'] = True
|
||||
fake_template_id = uuid.uuid4()
|
||||
response = logged_in_client.post(
|
||||
url_for(
|
||||
'main.service_set_letter_contact_block',
|
||||
service_id=service_one['id'],
|
||||
from_template=fake_template_id,
|
||||
),
|
||||
data={'letter_contact_block': ''},
|
||||
)
|
||||
assert response.status_code == 302
|
||||
assert response.location == url_for(
|
||||
'main.view_template',
|
||||
service_id=service_one['id'],
|
||||
template_id=fake_template_id,
|
||||
_external=True,
|
||||
)
|
||||
|
||||
|
||||
def test_set_letter_contact_block_has_max_10_lines(
|
||||
logged_in_client,
|
||||
service_one,
|
||||
|
||||
Reference in New Issue
Block a user