mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-07 20:03:33 -05:00
Merge pull request #570 from alphagov/reply-to-email
Admin app settings to save reply to email address for service.
This commit is contained in:
@@ -314,3 +314,7 @@ class RequestToGoLiveForm(Form):
|
||||
|
||||
class ProviderForm(Form):
|
||||
priority = IntegerField('Priority', [validators.NumberRange(min=1, max=100, message="Must be between 1 and 100")])
|
||||
|
||||
|
||||
class ServiceReplyToEmailFrom(Form):
|
||||
email_address = email_address()
|
||||
|
||||
@@ -19,7 +19,12 @@ from notifications_python_client.errors import HTTPError
|
||||
from app import service_api_client
|
||||
from app.main import main
|
||||
from app.utils import user_has_permissions, email_safe
|
||||
from app.main.forms import ConfirmPasswordForm, ServiceNameForm, RequestToGoLiveForm
|
||||
from app.main.forms import (
|
||||
ConfirmPasswordForm,
|
||||
ServiceNameForm,
|
||||
RequestToGoLiveForm,
|
||||
ServiceReplyToEmailFrom
|
||||
)
|
||||
from app import user_api_client
|
||||
from app import current_service
|
||||
|
||||
@@ -217,3 +222,26 @@ def service_delete_confirm(service_id):
|
||||
heading='Delete this service from Notify',
|
||||
destructive=True,
|
||||
form=form)
|
||||
|
||||
|
||||
@main.route("/services/<service_id>/service-settings/set-reply-to-email", methods=['GET', 'POST'])
|
||||
@login_required
|
||||
@user_has_permissions('manage_settings', admin_override=True)
|
||||
def service_set_reply_to_email(service_id):
|
||||
form = ServiceReplyToEmailFrom()
|
||||
if form.validate_on_submit():
|
||||
message = 'Reply to email set to {}'.format(form.email_address.data)
|
||||
service_api_client.update_service(
|
||||
current_service['id'],
|
||||
current_service['name'],
|
||||
current_service['active'],
|
||||
current_service['message_limit'],
|
||||
current_service['restricted'],
|
||||
current_service['users'],
|
||||
current_service['email_from'],
|
||||
reply_to_email_address=form.email_address.data)
|
||||
flash(message, 'default_with_tick')
|
||||
return redirect(url_for('.service_settings', service_id=service_id))
|
||||
return render_template(
|
||||
'views/service-settings/set-reply-to-email.html',
|
||||
form=form)
|
||||
|
||||
@@ -62,7 +62,8 @@ class ServiceAPIClient(NotificationsAPIClient):
|
||||
message_limit,
|
||||
restricted,
|
||||
users,
|
||||
email_from):
|
||||
email_from,
|
||||
reply_to_email_address=None):
|
||||
"""
|
||||
Update a service.
|
||||
"""
|
||||
@@ -73,7 +74,8 @@ class ServiceAPIClient(NotificationsAPIClient):
|
||||
"message_limit": message_limit,
|
||||
"restricted": restricted,
|
||||
"users": users,
|
||||
"email_from": email_from
|
||||
"email_from": email_from,
|
||||
"reply_to_email_address": reply_to_email_address
|
||||
}
|
||||
_attach_current_user(data)
|
||||
endpoint = "/service/{0}".format(service_id)
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
'title': 'Change your service name',
|
||||
'link': url_for('.service_name_change', service_id=current_service.id)
|
||||
},
|
||||
{
|
||||
'title': 'Set email reply to address',
|
||||
'link': url_for('.service_set_reply_to_email', service_id=current_service.id)
|
||||
},
|
||||
{
|
||||
'title': 'Request to go live and turn off trial mode',
|
||||
'link': url_for('.service_request_to_go_live', service_id=current_service.id),
|
||||
|
||||
28
app/templates/views/service-settings/set-reply-to-email.html
Normal file
28
app/templates/views/service-settings/set-reply-to-email.html
Normal file
@@ -0,0 +1,28 @@
|
||||
{% extends "withnav_template.html" %}
|
||||
{% from "components/textbox.html" import textbox %}
|
||||
{% from "components/page-footer.html" import page_footer %}
|
||||
|
||||
{% block page_title %}
|
||||
Request to go live – GOV.UK Notify
|
||||
{% endblock %}
|
||||
|
||||
{% block maincolumn_content %}
|
||||
|
||||
<div class="grid-row">
|
||||
<div class="column-three-quarters">
|
||||
<h1 class="heading-large">Set email reply to address</h1>
|
||||
<form method="post">
|
||||
{{ textbox(
|
||||
form.email_address,
|
||||
width='1-1',
|
||||
safe_error_message=True
|
||||
) }}
|
||||
{{ page_footer(
|
||||
'Save',
|
||||
back_link=url_for('.service_settings', service_id=current_service.id)
|
||||
) }}
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
@@ -35,7 +35,7 @@ def generate_uuid():
|
||||
return uuid.uuid4()
|
||||
|
||||
|
||||
def service_json(id_, name, users, message_limit=1000, active=False, restricted=True, email_from=None):
|
||||
def service_json(id_, name, users, message_limit=1000, active=False, restricted=True, email_from=None, reply_to_email_address=None): # noqa
|
||||
return {
|
||||
'id': id_,
|
||||
'name': name,
|
||||
@@ -43,7 +43,8 @@ def service_json(id_, name, users, message_limit=1000, active=False, restricted=
|
||||
'message_limit': message_limit,
|
||||
'active': active,
|
||||
'restricted': restricted,
|
||||
'email_from': email_from
|
||||
'email_from': email_from,
|
||||
'reply_to_email_address': reply_to_email_address
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -526,3 +526,26 @@ def test_route_for_platform_admin(mocker, app_, platform_admin_user, service_one
|
||||
[],
|
||||
platform_admin_user,
|
||||
service_one)
|
||||
|
||||
|
||||
def test_set_reply_to_email_address(app_,
|
||||
active_user_with_permissions,
|
||||
mocker,
|
||||
mock_update_service,
|
||||
service_one):
|
||||
with app_.test_request_context():
|
||||
with app_.test_client() as client:
|
||||
client.login(active_user_with_permissions, mocker, service_one)
|
||||
data = {"email_address": "test@someservice.gov.uk"}
|
||||
response = client.post(url_for('main.service_set_reply_to_email', service_id=service_one['id']),
|
||||
data=data,
|
||||
follow_redirects=True)
|
||||
assert response.status_code == 200
|
||||
mock_update_service.assert_called_with(service_one['id'],
|
||||
service_one['name'],
|
||||
service_one['active'],
|
||||
service_one['message_limit'],
|
||||
service_one['restricted'],
|
||||
ANY,
|
||||
service_one['email_from'],
|
||||
"test@someservice.gov.uk")
|
||||
|
||||
@@ -99,10 +99,11 @@ def mock_update_service(mocker):
|
||||
message_limit,
|
||||
restricted,
|
||||
users,
|
||||
email_from):
|
||||
email_from,
|
||||
reply_to_email_address=None):
|
||||
service = service_json(
|
||||
service_id, service_name, users, message_limit=message_limit,
|
||||
active=active, restricted=restricted, email_from=email_from)
|
||||
active=active, restricted=restricted, email_from=email_from, reply_to_email_address=reply_to_email_address)
|
||||
return {'data': service}
|
||||
|
||||
return mocker.patch(
|
||||
|
||||
Reference in New Issue
Block a user