- Change update service name to check that the name/email_from is unique across all services.

- This is done using a new endpoint in the api.
- Removed the AddServiceForm in favor or using the ServiceNameForm
- Removed ServiceApiClient.find_all_service_email_from
This commit is contained in:
Rebecca Law
2017-08-09 16:52:10 +01:00
parent 14be8dc463
commit 9b9c6d75dc
6 changed files with 29 additions and 37 deletions

View File

@@ -14,7 +14,7 @@ from notifications_python_client.errors import HTTPError
from werkzeug.exceptions import abort
from app.main import main
from app.main.forms import AddServiceForm
from app.main.forms import ServiceNameForm
from app.notify_client.models import InvitedUser
from app import (
@@ -78,7 +78,7 @@ def add_service():
if not is_gov_user(current_user.email_address):
abort(403)
form = AddServiceForm()
form = ServiceNameForm()
heading = 'Which service do you want to set up notifications for?'
if form.validate_on_submit():

View File

@@ -81,12 +81,16 @@ def service_settings(service_id):
@login_required
@user_has_permissions('manage_settings', admin_override=True)
def service_name_change(service_id):
form = ServiceNameForm(service_api_client.find_all_service_email_from)
form = ServiceNameForm()
if request.method == 'GET':
form.name.data = current_service.get('name')
if form.validate_on_submit():
unique_name = service_api_client.is_service_name_unique(form.name.data, email_safe(form.name.data))
if not unique_name:
form.name.errors.append("This service name is already in use")
return render_template('views/service-settings/name.html', form=form)
session['service_name_change'] = form.name.data
return redirect(url_for('.service_name_change_confirm', service_id=service_id))