Fix bug with reply to email addresses

https://www.pivotaltracker.com/story/show/180026726

There was a bug where if you enter an invalid email address in
to the edit reply to email address form and click save, the
form you get shown with your error message will always contain
the field to set as default the reply to and also delete. This should
not have been the case. If you make an error on the form when
changing a reply to that is already a default, then you should not
be given the chance to change it to not default, nor should you
be able to delete it.

This commit fixes that bug by making sure the additional form fields
are only shown if the reply to being changed is not the default.
This commit is contained in:
David McDonald
2021-11-04 11:21:58 +00:00
parent 1c2b65356f
commit b4b124d681
3 changed files with 67 additions and 2 deletions

View File

@@ -617,9 +617,13 @@ def get_service_verify_reply_to_address_partials(service_id, notification_id):
def service_edit_email_reply_to(service_id, reply_to_email_id):
form = ServiceReplyToEmailForm()
reply_to_email_address = current_service.get_email_reply_to_address(reply_to_email_id)
if request.method == 'GET':
form.email_address.data = reply_to_email_address['email_address']
form.is_default.data = reply_to_email_address['is_default']
show_choice_of_default_checkbox = not reply_to_email_address['is_default']
if form.validate_on_submit():
if form.email_address.data == reply_to_email_address["email_address"] or current_user.platform_admin:
service_api_client.update_reply_to_email_address(
@@ -653,6 +657,7 @@ def service_edit_email_reply_to(service_id, reply_to_email_id):
'views/service-settings/email-reply-to/edit.html',
form=form,
reply_to_email_address_id=reply_to_email_id,
show_choice_of_default_checkbox=show_choice_of_default_checkbox
)