mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-12 09:24:15 -04:00
Add /services prefix to all service-related URLs
The URLs will be easier to parse if the parts are clearly labelled. This is a precursor to making a blueprint for all service-related URLs.
This commit is contained in:
@@ -6,7 +6,7 @@ from app.main import main
|
||||
from ._jobs import jobs
|
||||
|
||||
|
||||
@main.route("/<int:service_id>/dashboard")
|
||||
@main.route("/services/<int:service_id>/dashboard")
|
||||
@login_required
|
||||
def dashboard(service_id):
|
||||
return render_template(
|
||||
|
||||
@@ -20,25 +20,25 @@ def verifymobile():
|
||||
return render_template('views/verify-mobile.html')
|
||||
|
||||
|
||||
@main.route("/<int:service_id>/send-email")
|
||||
@main.route("/services/<int:service_id>/send-email")
|
||||
@login_required
|
||||
def sendemail(service_id):
|
||||
return render_template('views/send-email.html')
|
||||
|
||||
|
||||
@main.route("/<int:service_id>/check-email")
|
||||
@main.route("/services/<int:service_id>/check-email")
|
||||
@login_required
|
||||
def checkemail(service_id):
|
||||
return render_template('views/check-email.html')
|
||||
|
||||
|
||||
@main.route("/<int:service_id>/manage-users")
|
||||
@main.route("/services/<int:service_id>/manage-users")
|
||||
@login_required
|
||||
def manageusers(service_id):
|
||||
return render_template('views/manage-users.html', service_id=service_id)
|
||||
|
||||
|
||||
@main.route("/<int:service_id>/api-keys")
|
||||
@main.route("/services/<int:service_id>/api-keys")
|
||||
@login_required
|
||||
def apikeys(service_id):
|
||||
return render_template('views/api-keys.html', service_id=service_id)
|
||||
|
||||
@@ -42,7 +42,7 @@ messages = [
|
||||
]
|
||||
|
||||
|
||||
@main.route("/<int:service_id>/jobs")
|
||||
@main.route("/services/<int:service_id>/jobs")
|
||||
@login_required
|
||||
def showjobs(service_id):
|
||||
return render_template(
|
||||
@@ -52,7 +52,7 @@ def showjobs(service_id):
|
||||
)
|
||||
|
||||
|
||||
@main.route("/<int:service_id>/jobs/<job_id>")
|
||||
@main.route("/services/<int:service_id>/jobs/<job_id>")
|
||||
@login_required
|
||||
def showjob(service_id, job_id):
|
||||
return render_template(
|
||||
@@ -76,7 +76,7 @@ def showjob(service_id, job_id):
|
||||
)
|
||||
|
||||
|
||||
@main.route("/<int:service_id>/jobs/<job_id>/notification/<string:notification_id>")
|
||||
@main.route("/services/<int:service_id>/jobs/<job_id>/notification/<string:notification_id>")
|
||||
@login_required
|
||||
def shownotification(service_id, job_id, notification_id):
|
||||
return render_template(
|
||||
|
||||
@@ -11,7 +11,7 @@ service = {
|
||||
}
|
||||
|
||||
|
||||
@main.route("/<int:service_id>/service-settings")
|
||||
@main.route("/services/<int:service_id>/service-settings")
|
||||
@login_required
|
||||
def service_settings(service_id):
|
||||
return render_template(
|
||||
@@ -21,7 +21,7 @@ def service_settings(service_id):
|
||||
)
|
||||
|
||||
|
||||
@main.route("/<int:service_id>/service-settings/name", methods=['GET', 'POST'])
|
||||
@main.route("/services/<int:service_id>/service-settings/name", methods=['GET', 'POST'])
|
||||
@login_required
|
||||
def name(service_id):
|
||||
|
||||
@@ -39,7 +39,7 @@ def name(service_id):
|
||||
return redirect(url_for('.confirm_name_change', service_id=service_id))
|
||||
|
||||
|
||||
@main.route("/<int:service_id>/service-settings/name/confirm", methods=['GET', 'POST'])
|
||||
@main.route("/services/<int:service_id>/service-settings/name/confirm", methods=['GET', 'POST'])
|
||||
@login_required
|
||||
def confirm_name_change(service_id):
|
||||
|
||||
@@ -56,7 +56,7 @@ def confirm_name_change(service_id):
|
||||
return redirect(url_for('.service_settings', service_id=service_id))
|
||||
|
||||
|
||||
@main.route("/<int:service_id>/service-settings/request-to-go-live", methods=['GET', 'POST'])
|
||||
@main.route("/services/<int:service_id>/service-settings/request-to-go-live", methods=['GET', 'POST'])
|
||||
@login_required
|
||||
def request_to_go_live(service_id):
|
||||
if request.method == 'GET':
|
||||
@@ -69,7 +69,7 @@ def request_to_go_live(service_id):
|
||||
return redirect(url_for('.service_settings', service_id=service_id))
|
||||
|
||||
|
||||
@main.route("/<int:service_id>/service-settings/status", methods=['GET', 'POST'])
|
||||
@main.route("/services/<int:service_id>/service-settings/status", methods=['GET', 'POST'])
|
||||
@login_required
|
||||
def status(service_id):
|
||||
if request.method == 'GET':
|
||||
@@ -82,7 +82,7 @@ def status(service_id):
|
||||
return redirect(url_for('.confirm_status_change', service_id=service_id))
|
||||
|
||||
|
||||
@main.route("/<int:service_id>/service-settings/status/confirm", methods=['GET', 'POST'])
|
||||
@main.route("/services/<int:service_id>/service-settings/status/confirm", methods=['GET', 'POST'])
|
||||
@login_required
|
||||
def confirm_status_change(service_id):
|
||||
|
||||
@@ -100,7 +100,7 @@ def confirm_status_change(service_id):
|
||||
return redirect(url_for('.service_settings', service_id=service_id))
|
||||
|
||||
|
||||
@main.route("/<int:service_id>/service-settings/delete", methods=['GET', 'POST'])
|
||||
@main.route("/services/<int:service_id>/service-settings/delete", methods=['GET', 'POST'])
|
||||
@login_required
|
||||
def delete(service_id):
|
||||
if request.method == 'GET':
|
||||
@@ -113,7 +113,7 @@ def delete(service_id):
|
||||
return redirect(url_for('.confirm_delete', service_id=service_id))
|
||||
|
||||
|
||||
@main.route("/<int:service_id>/service-settings/delete/confirm", methods=['GET', 'POST'])
|
||||
@main.route("/services/<int:service_id>/service-settings/delete/confirm", methods=['GET', 'POST'])
|
||||
@login_required
|
||||
def confirm_delete(service_id):
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ message_templates = [
|
||||
]
|
||||
|
||||
|
||||
@main.route("/<int:service_id>/sms/send", methods=['GET', 'POST'])
|
||||
@main.route("/services/<int:service_id>/sms/send", methods=['GET', 'POST'])
|
||||
@login_required
|
||||
def sendsms(service_id):
|
||||
form = CsvUploadForm()
|
||||
@@ -65,7 +65,7 @@ def sendsms(service_id):
|
||||
service_id=service_id)
|
||||
|
||||
|
||||
@main.route("/<int:service_id>/sms/check", methods=['GET', 'POST'])
|
||||
@main.route("/services/<int:service_id>/sms/check", methods=['GET', 'POST'])
|
||||
@login_required
|
||||
def checksms(service_id):
|
||||
if request.method == 'GET':
|
||||
|
||||
@@ -5,7 +5,7 @@ from app.main import main
|
||||
from app.main.forms import TemplateForm
|
||||
|
||||
|
||||
@main.route("/<int:service_id>/templates")
|
||||
@main.route("/services/<int:service_id>/templates")
|
||||
@login_required
|
||||
def manage_templates(service_id):
|
||||
return render_template(
|
||||
@@ -14,7 +14,7 @@ def manage_templates(service_id):
|
||||
)
|
||||
|
||||
|
||||
@main.route("/<int:service_id>/templates/template", methods=['GET', 'POST'])
|
||||
@main.route("/services/<int:service_id>/templates/template", methods=['GET', 'POST'])
|
||||
@login_required
|
||||
def add_template(service_id):
|
||||
|
||||
@@ -34,7 +34,7 @@ def add_template(service_id):
|
||||
return redirect(url_for('.manage_templates', service_id=service_id))
|
||||
|
||||
|
||||
@main.route("/<int:service_id>/templates/template/add", methods=['GET', 'POST'])
|
||||
@main.route("/services/<int:service_id>/templates/template/add", methods=['GET', 'POST'])
|
||||
@login_required
|
||||
def edit_template(service_id):
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ def test_should_add_service_and_redirect_to_next_page(notifications_admin, notif
|
||||
client.post('/two-factor', data={'sms_code': '12345'})
|
||||
response = client.post('/add-service', data={'service_name': 'testing the post'})
|
||||
assert response.status_code == 302
|
||||
assert response.location == 'http://localhost/123/dashboard'
|
||||
assert response.location == 'http://localhost/services/123/dashboard'
|
||||
saved_service = services_dao.find_service_by_service_name('testing the post')
|
||||
assert saved_service is not None
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ def test_should_show_recent_jobs_on_dashboard(notifications_admin,
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.get('/123/dashboard')
|
||||
response = client.get('/services/123/dashboard')
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'Test message 1' in response.get_data(as_text=True)
|
||||
|
||||
@@ -6,7 +6,7 @@ def test_should_return_list_of_all_jobs(notifications_admin, notifications_admin
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.get('/123/jobs')
|
||||
response = client.get('/services/123/jobs')
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'Test message 1' in response.get_data(as_text=True)
|
||||
@@ -18,7 +18,7 @@ def test_should_show_page_for_one_job(notifications_admin, notifications_admin_d
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.get('/123/jobs/456')
|
||||
response = client.get('/services/123/jobs/456')
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'dispatch_20151114.csv' in response.get_data(as_text=True)
|
||||
@@ -30,7 +30,7 @@ def test_should_show_page_for_one_notification(notifications_admin, notification
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.get('/123/jobs/456/notification/3')
|
||||
response = client.get('/services/123/jobs/456/notification/3')
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'Text message' in response.get_data(as_text=True)
|
||||
|
||||
@@ -6,7 +6,7 @@ def test_should_show_overview(notifications_admin, notifications_admin_db, notif
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.get('/123/service-settings')
|
||||
response = client.get('/services/123/service-settings')
|
||||
assert response.status_code == 200
|
||||
assert 'Service settings' in response.get_data(as_text=True)
|
||||
|
||||
@@ -16,7 +16,7 @@ def test_should_show_service_name(notifications_admin, notifications_admin_db, n
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.get('/123/service-settings/name')
|
||||
response = client.get('/services/123/service-settings/name')
|
||||
assert response.status_code == 200
|
||||
assert 'Change your service name' in response.get_data(as_text=True)
|
||||
|
||||
@@ -26,10 +26,10 @@ def test_should_redirect_after_change_service_name(notifications_admin, notifica
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.post('/123/service-settings/request-to-go-live')
|
||||
response = client.post('/services/123/service-settings/request-to-go-live')
|
||||
|
||||
assert response.status_code == 302
|
||||
assert 'http://localhost/123/service-settings' == response.location
|
||||
assert 'http://localhost/services/123/service-settings' == response.location
|
||||
|
||||
|
||||
def test_should_show_service_name_confirmation(notifications_admin, notifications_admin_db, notify_db_session):
|
||||
@@ -37,7 +37,7 @@ def test_should_show_service_name_confirmation(notifications_admin, notification
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.get('/123/service-settings/name/confirm')
|
||||
response = client.get('/services/123/service-settings/name/confirm')
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'Change your service name' in response.get_data(as_text=True)
|
||||
@@ -49,10 +49,10 @@ def test_should_redirect_after_service_name_confirmation(notifications_admin, no
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.post('/123/service-settings/name/confirm')
|
||||
response = client.post('/services/123/service-settings/name/confirm')
|
||||
|
||||
assert response.status_code == 302
|
||||
assert 'http://localhost/123/service-settings' == response.location
|
||||
assert 'http://localhost/services/123/service-settings' == response.location
|
||||
|
||||
|
||||
def test_should_show_request_to_go_live(notifications_admin, notifications_admin_db, notify_db_session):
|
||||
@@ -60,7 +60,7 @@ def test_should_show_request_to_go_live(notifications_admin, notifications_admin
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.get('/123/service-settings/request-to-go-live')
|
||||
response = client.get('/services/123/service-settings/request-to-go-live')
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'Request to go live' in response.get_data(as_text=True)
|
||||
@@ -71,10 +71,10 @@ def test_should_redirect_after_request_to_go_live(notifications_admin, notificat
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.post('/123/service-settings/request-to-go-live')
|
||||
response = client.post('/services/123/service-settings/request-to-go-live')
|
||||
|
||||
assert response.status_code == 302
|
||||
assert 'http://localhost/123/service-settings' == response.location
|
||||
assert 'http://localhost/services/123/service-settings' == response.location
|
||||
|
||||
|
||||
def test_should_show_status_page(notifications_admin, notifications_admin_db, notify_db_session):
|
||||
@@ -82,7 +82,7 @@ def test_should_show_status_page(notifications_admin, notifications_admin_db, no
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.get('/123/service-settings/status')
|
||||
response = client.get('/services/123/service-settings/status')
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'Turn off all outgoing notifications' in response.get_data(as_text=True)
|
||||
@@ -93,10 +93,10 @@ def test_should_show_redirect_after_status_change(notifications_admin, notificat
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.post('/123/service-settings/status')
|
||||
response = client.post('/services/123/service-settings/status')
|
||||
|
||||
assert response.status_code == 302
|
||||
assert 'http://localhost/123/service-settings/status/confirm' == response.location
|
||||
assert 'http://localhost/services/123/service-settings/status/confirm' == response.location
|
||||
|
||||
|
||||
def test_should_show_status_confirmation(notifications_admin, notifications_admin_db, notify_db_session):
|
||||
@@ -104,7 +104,7 @@ def test_should_show_status_confirmation(notifications_admin, notifications_admi
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.get('/123/service-settings/status/confirm')
|
||||
response = client.get('/services/123/service-settings/status/confirm')
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'Turn off all outgoing notifications' in response.get_data(as_text=True)
|
||||
@@ -115,10 +115,10 @@ def test_should_redirect_after_status_confirmation(notifications_admin, notifica
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.post('/123/service-settings/status/confirm')
|
||||
response = client.post('/services/123/service-settings/status/confirm')
|
||||
|
||||
assert response.status_code == 302
|
||||
assert 'http://localhost/123/service-settings' == response.location
|
||||
assert 'http://localhost/services/123/service-settings' == response.location
|
||||
|
||||
|
||||
def test_should_show_delete_page(notifications_admin, notifications_admin_db, notify_db_session):
|
||||
@@ -126,7 +126,7 @@ def test_should_show_delete_page(notifications_admin, notifications_admin_db, no
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.get('/123/service-settings/delete')
|
||||
response = client.get('/services/123/service-settings/delete')
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'Delete this service from Notify' in response.get_data(as_text=True)
|
||||
@@ -137,10 +137,10 @@ def test_should_show_redirect_after_deleting_service(notifications_admin, notifi
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.post('/123/service-settings/delete')
|
||||
response = client.post('/services/123/service-settings/delete')
|
||||
|
||||
assert response.status_code == 302
|
||||
assert 'http://localhost/123/service-settings/delete/confirm' == response.location
|
||||
assert 'http://localhost/services/123/service-settings/delete/confirm' == response.location
|
||||
|
||||
|
||||
def test_should_show_delete_confirmation(notifications_admin, notifications_admin_db, notify_db_session):
|
||||
@@ -148,7 +148,7 @@ def test_should_show_delete_confirmation(notifications_admin, notifications_admi
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.get('/123/service-settings/delete/confirm')
|
||||
response = client.get('/services/123/service-settings/delete/confirm')
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'Delete this service from Notify' in response.get_data(as_text=True)
|
||||
@@ -159,7 +159,7 @@ def test_should_redirect_delete_confirmation(notifications_admin, notifications_
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.post('/123/service-settings/delete/confirm')
|
||||
response = client.post('/services/123/service-settings/delete/confirm')
|
||||
|
||||
assert response.status_code == 302
|
||||
assert 'http://localhost/123/dashboard' == response.location
|
||||
assert 'http://localhost/services/123/dashboard' == response.location
|
||||
|
||||
@@ -34,7 +34,7 @@ def test_sign_out_user(notifications_admin,
|
||||
with notifications_admin.test_client() as client:
|
||||
client.login(user)
|
||||
# Check we are logged in
|
||||
response = client.get('/123/dashboard')
|
||||
response = client.get('/services/123/dashboard')
|
||||
assert response.status_code == 200
|
||||
response = client.get(url_for('main.sign_out'))
|
||||
assert response.status_code == 302
|
||||
|
||||
@@ -9,7 +9,7 @@ def test_upload_empty_csvfile_returns_to_upload_page(notifications_admin, notifi
|
||||
client.login(user)
|
||||
|
||||
upload_data = {'file': (BytesIO(''.encode('utf-8')), 'emtpy.csv')}
|
||||
response = client.post('/123/sms/send', data=upload_data,
|
||||
response = client.post('/services/123/sms/send', data=upload_data,
|
||||
follow_redirects=True)
|
||||
|
||||
assert response.status_code == 200
|
||||
@@ -27,7 +27,7 @@ def test_upload_csvfile_with_invalid_phone_shows_check_page_with_errors(
|
||||
|
||||
file_contents = 'phone\n+44 123\n+44 456'.encode('utf-8')
|
||||
upload_data = {'file': (BytesIO(file_contents), 'invalid.csv')}
|
||||
response = client.post('/123/sms/send', data=upload_data,
|
||||
response = client.post('/services/123/sms/send', data=upload_data,
|
||||
follow_redirects=True)
|
||||
assert response.status_code == 200
|
||||
content = response.get_data(as_text=True)
|
||||
@@ -48,7 +48,7 @@ def test_upload_csvfile_with_valid_phone_shows_first3_and_last3_numbers(
|
||||
file_contents = 'phone\n+44 7700 900981\n+44 7700 900982\n+44 7700 900983\n+44 7700 900984\n+44 7700 900985\n+44 7700 900986\n+44 7700 900987\n+44 7700 900988\n+44 7700 900989'.encode('utf-8') # noqa
|
||||
|
||||
upload_data = {'file': (BytesIO(file_contents), 'valid.csv')}
|
||||
response = client.post('/123/sms/send', data=upload_data,
|
||||
response = client.post('/services/123/sms/send', data=upload_data,
|
||||
follow_redirects=True)
|
||||
|
||||
content = response.get_data(as_text=True)
|
||||
@@ -79,7 +79,7 @@ def test_upload_csvfile_with_valid_phone_shows_all_if_6_or_less_numbers(
|
||||
file_contents = 'phone\n+44 7700 900981\n+44 7700 900982\n+44 7700 900983\n+44 7700 900984\n+44 7700 900985\n+44 7700 900986'.encode('utf-8') # noqa
|
||||
|
||||
upload_data = {'file': (BytesIO(file_contents), 'valid.csv')}
|
||||
response = client.post('/123/sms/send', data=upload_data,
|
||||
response = client.post('/services/123/sms/send', data=upload_data,
|
||||
follow_redirects=True)
|
||||
|
||||
content = response.get_data(as_text=True)
|
||||
@@ -102,7 +102,7 @@ def test_should_redirect_to_job(notifications_admin, notifications_admin_db,
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
|
||||
response = client.post('/123/sms/check')
|
||||
response = client.post('/services/123/sms/check')
|
||||
|
||||
assert response.status_code == 302
|
||||
assert response.location == 'http://localhost/123/jobs/456'
|
||||
assert response.location == 'http://localhost/services/123/jobs/456'
|
||||
|
||||
@@ -6,7 +6,7 @@ def test_should_return_list_of_all_templates(notifications_admin, notifications_
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.get('/123/templates')
|
||||
response = client.get('/services/123/templates')
|
||||
|
||||
assert response.status_code == 200
|
||||
|
||||
@@ -16,7 +16,7 @@ def test_should_show_page_for_one_templates(notifications_admin, notifications_a
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.get('/123/templates/template')
|
||||
response = client.get('/services/123/templates/template')
|
||||
|
||||
assert response.status_code == 200
|
||||
|
||||
@@ -26,7 +26,7 @@ def test_should_redirect_when_saving_a_template(notifications_admin, notificatio
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.post('/123/templates/template')
|
||||
response = client.post('/services/123/templates/template')
|
||||
|
||||
assert response.status_code == 302
|
||||
assert response.location == 'http://localhost/123/templates'
|
||||
assert response.location == 'http://localhost/services/123/templates'
|
||||
|
||||
Reference in New Issue
Block a user