2025-04-11 13:03:40 -07:00
|
|
|
import logging
|
|
|
|
|
|
2024-10-31 12:04:26 -07:00
|
|
|
from flask import (
|
|
|
|
|
abort,
|
|
|
|
|
current_app,
|
|
|
|
|
jsonify,
|
|
|
|
|
redirect,
|
|
|
|
|
render_template,
|
|
|
|
|
request,
|
|
|
|
|
url_for,
|
|
|
|
|
)
|
2019-07-01 15:22:08 +01:00
|
|
|
from flask_login import current_user
|
2016-07-04 16:25:20 +01:00
|
|
|
|
2024-11-25 13:33:33 -05:00
|
|
|
from app import status_api_client
|
2024-01-03 22:01:07 -07:00
|
|
|
from app.formatters import apply_html_class, convert_markdown_template
|
2018-02-20 11:22:17 +00:00
|
|
|
from app.main import main
|
2022-05-04 15:04:06 +01:00
|
|
|
from app.main.views.pricing import CURRENT_SMS_RATE
|
2024-09-19 09:55:59 -07:00
|
|
|
from app.main.views.sub_navigation_dictionaries import (
|
2024-11-13 14:32:15 -08:00
|
|
|
about_notify_nav,
|
2024-09-19 09:55:59 -07:00
|
|
|
using_notify_nav,
|
|
|
|
|
)
|
2023-07-03 15:03:33 -04:00
|
|
|
from app.utils.user import user_is_logged_in
|
2015-11-20 16:22:44 +00:00
|
|
|
|
2025-04-11 13:03:40 -07:00
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
2024-11-15 12:00:06 -05:00
|
|
|
|
2024-11-14 10:53:48 -05:00
|
|
|
# Hook to check for feature flags
|
2024-10-14 14:44:20 -04:00
|
|
|
@main.before_request
|
2024-11-15 11:55:16 -05:00
|
|
|
def check_feature_flags():
|
2025-03-20 14:22:41 -04:00
|
|
|
# Placeholder for future feature flag checks
|
|
|
|
|
# Example:
|
|
|
|
|
# if request.path.startswith("/some-feature") and not current_app.config.get("FEATURE_SOME_FEATURE_ENABLED", False):
|
|
|
|
|
# abort(404)
|
|
|
|
|
pass
|
2023-12-22 10:13:18 -07:00
|
|
|
|
2024-10-15 12:54:37 -04:00
|
|
|
|
2024-10-31 12:04:26 -07:00
|
|
|
@main.route("/test/feature-flags")
|
|
|
|
|
def test_feature_flags():
|
2024-10-31 12:26:20 -07:00
|
|
|
return jsonify(
|
2025-04-10 12:35:04 -07:00
|
|
|
{"FEATURE_SOCKET_ENABLED": current_app.config["FEATURE_SOCKET_ENABLED"]}
|
2024-10-31 12:26:20 -07:00
|
|
|
)
|
2024-10-31 12:04:26 -07:00
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
@main.route("/")
|
2015-11-20 16:22:44 +00:00
|
|
|
def index():
|
2016-05-04 13:01:55 +01:00
|
|
|
if current_user and current_user.is_authenticated:
|
2023-08-25 09:12:23 -07:00
|
|
|
return redirect(url_for("main.choose_account"))
|
2024-10-15 16:52:29 -04:00
|
|
|
|
2019-04-10 17:20:51 +01:00
|
|
|
return render_template(
|
2023-08-25 09:12:23 -07:00
|
|
|
"views/signedout.html",
|
2022-05-04 15:04:06 +01:00
|
|
|
sms_rate=CURRENT_SMS_RATE,
|
2025-05-02 10:43:07 -04:00
|
|
|
counts=status_api_client.get_count_of_live_services_and_organizations(),
|
2019-04-10 17:20:51 +01:00
|
|
|
)
|
2015-11-23 16:07:19 +00:00
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
@main.route("/error/<int:status_code>")
|
2018-03-08 17:49:08 +00:00
|
|
|
def error(status_code):
|
2018-03-09 12:28:55 +00:00
|
|
|
if status_code >= 500:
|
|
|
|
|
abort(404)
|
2018-03-08 17:49:08 +00:00
|
|
|
abort(status_code)
|
|
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
@main.route("/privacy")
|
2023-07-03 15:03:33 -04:00
|
|
|
@user_is_logged_in
|
2018-05-23 14:35:26 +01:00
|
|
|
def privacy():
|
2023-08-25 09:12:23 -07:00
|
|
|
return render_template("views/privacy.html")
|
2018-05-23 14:35:26 +01:00
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
@main.route("/accessibility-statement")
|
2023-07-03 15:03:33 -04:00
|
|
|
@user_is_logged_in
|
2020-09-18 14:40:47 +01:00
|
|
|
def accessibility_statement():
|
2023-08-25 09:12:23 -07:00
|
|
|
return render_template("views/accessibility_statement.html")
|
2020-09-18 14:40:47 +01:00
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
@main.route("/delivery-and-failure")
|
|
|
|
|
@main.route("/features/messages-status")
|
2016-05-09 16:18:13 +01:00
|
|
|
def delivery_and_failure():
|
2023-08-25 09:12:23 -07:00
|
|
|
return redirect(url_for(".message_status"), 301)
|
2016-05-09 16:18:13 +01:00
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
@main.route("/design-patterns-content-guidance")
|
2023-07-03 15:03:33 -04:00
|
|
|
@user_is_logged_in
|
2016-06-08 15:48:03 +01:00
|
|
|
def design_content():
|
2023-08-25 09:12:23 -07:00
|
|
|
return redirect(
|
|
|
|
|
"https://www.gov.uk/service-manual/design/sending-emails-and-text-messages", 301
|
|
|
|
|
)
|
2016-06-08 15:48:03 +01:00
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
@main.route("/documentation")
|
2023-07-03 15:03:33 -04:00
|
|
|
@user_is_logged_in
|
2016-04-15 10:48:31 +01:00
|
|
|
def documentation():
|
2020-01-24 15:57:29 +00:00
|
|
|
return render_template(
|
2023-08-25 09:12:23 -07:00
|
|
|
"views/documentation.html",
|
2020-01-24 15:57:29 +00:00
|
|
|
navigation_links=using_notify_nav(),
|
|
|
|
|
)
|
2017-01-27 17:32:20 +00:00
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
@main.route("/integration-testing")
|
2017-01-27 17:32:20 +00:00
|
|
|
def integration_testing():
|
2023-08-25 09:12:23 -07:00
|
|
|
return render_template("views/integration-testing.html"), 410
|
2017-03-23 15:03:24 +00:00
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
@main.route("/callbacks")
|
2017-11-28 11:56:30 +00:00
|
|
|
def callbacks():
|
2023-08-25 09:12:23 -07:00
|
|
|
return redirect(url_for("main.documentation"), 301)
|
2017-11-28 11:56:30 +00:00
|
|
|
|
2017-06-14 16:05:20 +01:00
|
|
|
|
2023-10-12 13:52:03 -04:00
|
|
|
@main.route("/using-notify/delivery-status")
|
2023-07-03 15:03:33 -04:00
|
|
|
@user_is_logged_in
|
2019-04-09 15:24:07 +01:00
|
|
|
def message_status():
|
|
|
|
|
return render_template(
|
2023-08-25 09:12:23 -07:00
|
|
|
"views/message-status.html",
|
2020-01-24 15:57:29 +00:00
|
|
|
navigation_links=using_notify_nav(),
|
2019-04-09 15:24:07 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
@main.route("/features/get-started")
|
2023-07-03 15:03:33 -04:00
|
|
|
@user_is_logged_in
|
2020-01-24 15:57:29 +00:00
|
|
|
def get_started_old():
|
2023-08-25 09:12:23 -07:00
|
|
|
return redirect(url_for(".get_started"), 301)
|
2020-01-24 15:57:29 +00:00
|
|
|
|
|
|
|
|
|
2023-10-12 13:52:03 -04:00
|
|
|
@main.route("/using-notify/get-started")
|
2023-07-03 15:03:33 -04:00
|
|
|
@user_is_logged_in
|
2019-10-17 16:15:28 +01:00
|
|
|
def get_started():
|
2024-01-11 12:43:49 -05:00
|
|
|
markdown = convert_markdown_template("get-started")
|
|
|
|
|
html_style = apply_html_class(
|
|
|
|
|
[
|
|
|
|
|
["ol", "usa-process-list"],
|
|
|
|
|
["li", "usa-process-list__item padding-bottom-4 margin-top-2"],
|
|
|
|
|
["h2", "usa-process-list__heading line-height-sans-3"],
|
|
|
|
|
],
|
|
|
|
|
markdown,
|
|
|
|
|
)
|
2024-01-03 22:01:07 -07:00
|
|
|
|
2019-10-17 16:15:28 +01:00
|
|
|
return render_template(
|
2023-08-25 09:12:23 -07:00
|
|
|
"views/get-started.html",
|
2023-12-22 10:03:43 -07:00
|
|
|
navigation_links=using_notify_nav(),
|
2024-01-11 12:43:49 -05:00
|
|
|
content=html_style,
|
2019-10-17 16:15:28 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
2023-10-12 13:52:03 -04:00
|
|
|
@main.route("/using-notify/who-its-for")
|
2020-05-21 11:17:44 +01:00
|
|
|
def who_its_for():
|
2023-08-25 09:12:23 -07:00
|
|
|
return redirect(url_for(".features"), 301)
|
2020-03-25 11:52:30 +00:00
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
@main.route("/trial-mode")
|
|
|
|
|
@main.route("/features/trial-mode")
|
2019-04-09 15:27:33 +01:00
|
|
|
def trial_mode():
|
2023-08-25 09:12:23 -07:00
|
|
|
return redirect(url_for(".trial_mode_new"), 301)
|
2019-04-09 15:27:33 +01:00
|
|
|
|
|
|
|
|
|
2023-10-12 13:52:03 -04:00
|
|
|
@main.route("/using-notify/trial-mode")
|
2019-04-09 15:27:33 +01:00
|
|
|
def trial_mode_new():
|
|
|
|
|
return render_template(
|
2023-08-25 09:12:23 -07:00
|
|
|
"views/trial-mode.html",
|
2020-01-24 15:57:29 +00:00
|
|
|
navigation_links=using_notify_nav(),
|
2019-04-09 15:27:33 +01:00
|
|
|
)
|
|
|
|
|
|
2024-09-18 22:45:49 -07:00
|
|
|
|
2025-01-13 14:47:41 -05:00
|
|
|
@main.route("/using-notify/best-practices")
|
2024-09-18 22:40:48 -07:00
|
|
|
@user_is_logged_in
|
2024-10-24 16:28:42 -07:00
|
|
|
def best_practices():
|
2024-09-18 22:40:48 -07:00
|
|
|
return render_template(
|
2024-11-25 18:15:34 -08:00
|
|
|
"views/guides/best-practices.html",
|
2025-01-13 14:47:41 -05:00
|
|
|
navigation_links=using_notify_nav(),
|
2024-09-18 22:40:48 -07:00
|
|
|
)
|
|
|
|
|
|
2024-09-18 22:45:49 -07:00
|
|
|
|
2025-01-13 14:47:41 -05:00
|
|
|
@main.route("/using-notify/best-practices/clear-goals")
|
2024-09-18 22:40:48 -07:00
|
|
|
@user_is_logged_in
|
|
|
|
|
def clear_goals():
|
|
|
|
|
return render_template(
|
2024-11-25 18:15:34 -08:00
|
|
|
"views/guides/clear-goals.html",
|
2025-01-13 14:47:41 -05:00
|
|
|
navigation_links=using_notify_nav(),
|
2024-09-18 22:40:48 -07:00
|
|
|
)
|
|
|
|
|
|
2024-09-18 22:45:49 -07:00
|
|
|
|
2025-01-13 14:47:41 -05:00
|
|
|
@main.route("/using-notify/best-practices/rules-and-regulations")
|
2024-09-18 22:40:48 -07:00
|
|
|
@user_is_logged_in
|
|
|
|
|
def rules_and_regulations():
|
|
|
|
|
return render_template(
|
2024-11-25 18:15:34 -08:00
|
|
|
"views/guides/rules-and-regulations.html",
|
2025-01-13 14:47:41 -05:00
|
|
|
navigation_links=using_notify_nav(),
|
2024-09-18 22:40:48 -07:00
|
|
|
)
|
|
|
|
|
|
2024-09-18 22:45:49 -07:00
|
|
|
|
2025-01-13 14:47:41 -05:00
|
|
|
@main.route("/using-notify/best-practices/establish-trust")
|
2024-09-18 22:40:48 -07:00
|
|
|
@user_is_logged_in
|
|
|
|
|
def establish_trust():
|
|
|
|
|
return render_template(
|
2024-11-25 18:15:34 -08:00
|
|
|
"views/guides/establish-trust.html",
|
2025-01-13 14:47:41 -05:00
|
|
|
navigation_links=using_notify_nav(),
|
2024-09-18 22:40:48 -07:00
|
|
|
)
|
|
|
|
|
|
2024-09-18 22:45:49 -07:00
|
|
|
|
2025-01-13 14:47:41 -05:00
|
|
|
@main.route("/using-notify/best-practices/write-for-action")
|
2024-09-18 22:40:48 -07:00
|
|
|
@user_is_logged_in
|
|
|
|
|
def write_for_action():
|
|
|
|
|
return render_template(
|
2024-11-25 18:15:34 -08:00
|
|
|
"views/guides/write-for-action.html",
|
2025-01-13 14:47:41 -05:00
|
|
|
navigation_links=using_notify_nav(),
|
2024-09-18 22:40:48 -07:00
|
|
|
)
|
|
|
|
|
|
2024-09-18 22:45:49 -07:00
|
|
|
|
2025-01-13 14:47:41 -05:00
|
|
|
@main.route("/using-notify/best-practices/multiple-languages")
|
2024-09-18 22:40:48 -07:00
|
|
|
@user_is_logged_in
|
|
|
|
|
def multiple_languages():
|
|
|
|
|
return render_template(
|
2024-11-25 18:15:34 -08:00
|
|
|
"views/guides/multiple-languages.html",
|
2025-01-13 14:47:41 -05:00
|
|
|
navigation_links=using_notify_nav(),
|
2024-09-25 09:38:21 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
2025-01-13 14:47:41 -05:00
|
|
|
@main.route("/using-notify/best-practices/benchmark-performance")
|
2024-09-25 09:38:21 -07:00
|
|
|
@user_is_logged_in
|
|
|
|
|
def benchmark_performance():
|
|
|
|
|
return render_template(
|
2024-11-25 18:15:34 -08:00
|
|
|
"views/guides/benchmark-performance.html",
|
2025-01-13 14:47:41 -05:00
|
|
|
navigation_links=using_notify_nav(),
|
2024-09-18 22:40:48 -07:00
|
|
|
)
|
|
|
|
|
|
2024-09-18 22:45:49 -07:00
|
|
|
|
2025-01-22 10:41:29 -08:00
|
|
|
@main.route("/using-notify/how-to")
|
2023-07-03 15:03:33 -04:00
|
|
|
@user_is_logged_in
|
2025-01-22 10:41:29 -08:00
|
|
|
def how_to():
|
2020-01-24 15:57:29 +00:00
|
|
|
return render_template(
|
2025-01-22 10:41:29 -08:00
|
|
|
"views/how-to/index.html",
|
2020-01-24 15:57:29 +00:00
|
|
|
navigation_links=using_notify_nav(),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
2024-12-04 14:27:03 -08:00
|
|
|
@main.route("/contact")
|
|
|
|
|
def contact():
|
|
|
|
|
return render_template(
|
2024-12-04 14:29:49 -08:00
|
|
|
"views/contact.html",
|
2025-01-03 15:05:55 -08:00
|
|
|
navigation_links=about_notify_nav(),
|
2024-12-04 14:32:17 -08:00
|
|
|
)
|
2024-12-04 14:27:03 -08:00
|
|
|
|
|
|
|
|
|
2024-11-14 16:18:35 -08:00
|
|
|
@main.route("/about")
|
|
|
|
|
def about_notify():
|
|
|
|
|
return render_template(
|
|
|
|
|
"views/about/about.html",
|
|
|
|
|
navigation_links=about_notify_nav(),
|
|
|
|
|
)
|
|
|
|
|
|
2024-12-04 14:33:05 -08:00
|
|
|
|
2024-11-18 13:35:24 -08:00
|
|
|
@main.route("/about/security")
|
|
|
|
|
def about_security():
|
|
|
|
|
return render_template(
|
|
|
|
|
"views/about/security.html",
|
|
|
|
|
navigation_links=about_notify_nav(),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
2024-11-20 10:25:39 -08:00
|
|
|
@main.route("/about/why-text-messaging")
|
|
|
|
|
def why_text_messaging():
|
|
|
|
|
return render_template(
|
|
|
|
|
"views/about/why-text-messaging.html",
|
|
|
|
|
navigation_links=about_notify_nav(),
|
|
|
|
|
)
|
|
|
|
|
|
2024-11-14 16:25:37 -08:00
|
|
|
|
2025-03-13 15:43:21 -07:00
|
|
|
@main.route("/notify-service-ending")
|
|
|
|
|
@user_is_logged_in
|
|
|
|
|
def notify_service_ending():
|
2024-11-19 10:59:58 -08:00
|
|
|
return render_template(
|
2025-03-13 15:43:21 -07:00
|
|
|
"views/notify-service-ending.html",
|
2024-11-19 10:59:58 -08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
2025-01-22 10:41:29 -08:00
|
|
|
@main.route("/using-notify/how-to/create-and-send-messages")
|
2023-07-03 15:03:33 -04:00
|
|
|
@user_is_logged_in
|
2020-01-27 11:46:09 +00:00
|
|
|
def create_and_send_messages():
|
2020-01-24 15:57:29 +00:00
|
|
|
return render_template(
|
2025-01-22 10:41:29 -08:00
|
|
|
"views/how-to/create-and-send-messages.html",
|
2020-01-24 15:57:29 +00:00
|
|
|
navigation_links=using_notify_nav(),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
2025-01-22 10:41:29 -08:00
|
|
|
@main.route("/using-notify/how-to/edit-and-format-messages")
|
2023-07-03 15:03:33 -04:00
|
|
|
@user_is_logged_in
|
2020-01-24 15:57:29 +00:00
|
|
|
def edit_and_format_messages():
|
|
|
|
|
return render_template(
|
2025-01-22 10:41:29 -08:00
|
|
|
"views/how-to/edit-and-format-messages.html",
|
2020-01-24 15:57:29 +00:00
|
|
|
navigation_links=using_notify_nav(),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
2025-01-22 10:41:29 -08:00
|
|
|
@main.route("/using-notify/how-to/send-files-by-email")
|
2023-07-03 15:03:33 -04:00
|
|
|
@user_is_logged_in
|
2020-01-24 15:57:29 +00:00
|
|
|
def send_files_by_email():
|
|
|
|
|
return render_template(
|
2025-01-22 10:41:29 -08:00
|
|
|
"views/how-to/send-files-by-email.html",
|
2020-01-24 15:57:29 +00:00
|
|
|
navigation_links=using_notify_nav(),
|
|
|
|
|
)
|
|
|
|
|
|
2024-12-20 14:04:25 -05:00
|
|
|
|
2024-12-20 13:38:01 -05:00
|
|
|
@main.route("/studio")
|
|
|
|
|
def studio():
|
|
|
|
|
return render_template(
|
|
|
|
|
"views/studio.html",
|
|
|
|
|
)
|
|
|
|
|
|
2020-01-24 15:57:29 +00:00
|
|
|
|
2025-01-06 10:40:35 -05:00
|
|
|
@main.route("/acceptable-use-policy")
|
|
|
|
|
def acceptable_use_policy():
|
|
|
|
|
return render_template(
|
|
|
|
|
"views/acceptable-use-policy.html",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
2017-11-29 13:59:01 +00:00
|
|
|
# --- Redirects --- #
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
|
|
|
|
|
@main.route("/information-security", endpoint="information_security")
|
|
|
|
|
@main.route("/using_notify", endpoint="old_using_notify")
|
|
|
|
|
@main.route("/information-risk-management", endpoint="information_risk_management")
|
|
|
|
|
@main.route("/integration_testing", endpoint="old_integration_testing")
|
2017-11-29 13:59:01 +00:00
|
|
|
def old_page_redirects():
|
|
|
|
|
redirects = {
|
2023-08-25 09:12:23 -07:00
|
|
|
"main.information_security": "main.using_notify",
|
|
|
|
|
"main.old_using_notify": "main.using_notify",
|
|
|
|
|
"main.information_risk_management": "main.security",
|
|
|
|
|
"main.old_integration_testing": "main.integration_testing",
|
2017-11-29 13:59:01 +00:00
|
|
|
}
|
|
|
|
|
return redirect(url_for(redirects[request.endpoint]), code=301)
|