diff --git a/app/main/views/service_settings.py b/app/main/views/service_settings.py index dfa382714..3d690bf2f 100644 --- a/app/main/views/service_settings.py +++ b/app/main/views/service_settings.py @@ -187,6 +187,9 @@ def estimate_usage(service_id): @main.route("/services//service-settings/request-to-go-live", methods=['GET']) @user_has_permissions('manage_service') def request_to_go_live(service_id): + if current_service.live: + return render_template('views/service-settings/service-already-live.html') + return render_template( 'views/service-settings/request-to-go-live.html' ) diff --git a/app/templates/views/service-settings/service-already-live.html b/app/templates/views/service-settings/service-already-live.html new file mode 100644 index 000000000..950e0a094 --- /dev/null +++ b/app/templates/views/service-settings/service-already-live.html @@ -0,0 +1,28 @@ +{% extends "withnav_template.html" %} +{% from "components/page-header.html" import page_header %} + +{% block service_page_title %} + Your service is already live +{% endblock %} + +{% block maincolumn_content %} +
+
+ {{ page_header('Your service is already live') }} + +

+ {% if current_service.go_live_at %} + ‘{{ current_service.name }}’ went live on {{ current_service.go_live_at | format_date_normal }}. + {% else %} + ‘{{ current_service.name }}’ is already live. + {% endif %} +

+ +

+ Switch service + if you want to make a different service live. +

+ +
+
+{% endblock %} diff --git a/tests/app/main/views/test_service_settings.py b/tests/app/main/views/test_service_settings.py index 61511985d..f69e8c74e 100644 --- a/tests/app/main/views/test_service_settings.py +++ b/tests/app/main/views/test_service_settings.py @@ -1037,6 +1037,28 @@ def test_should_not_show_go_live_button_if_checklist_not_complete( ) +@pytest.mark.parametrize('go_live_at, message', [ + (None, '‘service one’ is already live.'), + ('2020-10-09 13:55:20', '‘service one’ went live on 9 October 2020.'), +]) +def test_request_to_go_live_redirects_if_service_already_live( + client_request, + service_one, + go_live_at, + message, +): + service_one['restricted'] = False + service_one['go_live_at'] = go_live_at + + page = client_request.get( + 'main.request_to_go_live', + service_id=SERVICE_ONE_ID, + ) + + assert page.h1.text == 'Your service is already live' + assert normalize_spaces(page.select_one('main p').text) == message + + @pytest.mark.parametrize(( 'estimated_sms_volume,' 'organisation_type,'