Merge branch 'main' into 2105-contact

This commit is contained in:
Beverly Nguyen
2024-12-04 14:27:03 -08:00
38 changed files with 757 additions and 370 deletions

View File

@@ -1,11 +1,15 @@
import os
import secrets
from urllib.parse import unquote
from flask import abort, current_app, redirect, render_template, request, url_for
from flask import (
abort,
current_app,
jsonify,
redirect,
render_template,
request,
url_for,
)
from flask_login import current_user
from app import redis_client, status_api_client
from app import status_api_client
from app.formatters import apply_html_class, convert_markdown_template
from app.main import main
from app.main.views.pricing import CURRENT_SMS_RATE
@@ -16,55 +20,42 @@ from app.main.views.sub_navigation_dictionaries import (
using_notify_nav,
)
from app.utils.user import user_is_logged_in
from notifications_utils.url_safe_token import generate_token
# Hook to check for feature flags
@main.before_request
def check_feature_flags():
if (
request.path.startswith("/guides/best-practices")
and not current_app.config.get("FEATURE_BEST_PRACTICES_ENABLED", False)
if request.path.startswith("/guides") and not current_app.config.get(
"FEATURE_BEST_PRACTICES_ENABLED", False
):
abort(404)
if (
request.path.startswith("/about")
and not current_app.config.get("FEATURE_ABOUT_PAGE_ENABLED", False)
if request.path.startswith("/about") and not current_app.config.get(
"FEATURE_ABOUT_PAGE_ENABLED", False
):
abort(404)
@main.route("/test/feature-flags")
def test_feature_flags():
return jsonify(
{
"FEATURE_BEST_PRACTICES_ENABLED": current_app.config[
"FEATURE_BEST_PRACTICES_ENABLED"
]
}
)
@main.route("/")
def index():
if current_user and current_user.is_authenticated:
return redirect(url_for("main.choose_account"))
ttl = 24 * 60 * 60
# make and store the state
state = generate_token(
str(request.remote_addr),
current_app.config["SECRET_KEY"],
current_app.config["DANGEROUS_SALT"],
)
state_key = f"login-state-{unquote(state)}"
redis_client.set(state_key, state, ex=ttl)
# make and store the nonce
nonce = secrets.token_urlsafe()
nonce_key = f"login-nonce-{unquote(nonce)}"
redis_client.set(nonce_key, nonce, ex=ttl)
url = os.getenv("LOGIN_DOT_GOV_INITIAL_SIGNIN_URL")
if url is not None:
url = url.replace("NONCE", nonce)
url = url.replace("STATE", state)
return render_template(
"views/signedout.html",
sms_rate=CURRENT_SMS_RATE,
counts=status_api_client.get_count_of_live_services_and_organizations(),
initial_signin_url=url,
counts=status_api_client.get_count_of_live_services_and_organizations()
)
@@ -216,61 +207,61 @@ def trial_mode_new():
@user_is_logged_in
def best_practices():
return render_template(
"views/best-practices/best-practices.html",
"views/guides/best-practices.html",
navigation_links=best_practices_nav(),
)
@main.route("/guides/best-practices/clear-goals")
@main.route("/guides/clear-goals")
@user_is_logged_in
def clear_goals():
return render_template(
"views/best-practices/clear-goals.html",
"views/guides/clear-goals.html",
navigation_links=best_practices_nav(),
)
@main.route("/guides/best-practices/rules-and-regulations")
@main.route("/guides/rules-and-regulations")
@user_is_logged_in
def rules_and_regulations():
return render_template(
"views/best-practices/rules-and-regulations.html",
"views/guides/rules-and-regulations.html",
navigation_links=best_practices_nav(),
)
@main.route("/guides/best-practices/establish-trust")
@main.route("/guides/establish-trust")
@user_is_logged_in
def establish_trust():
return render_template(
"views/best-practices/establish-trust.html",
"views/guides/establish-trust.html",
navigation_links=best_practices_nav(),
)
@main.route("/guides/best-practices/write-for-action")
@main.route("/guides/write-for-action")
@user_is_logged_in
def write_for_action():
return render_template(
"views/best-practices/write-for-action.html",
"views/guides/write-for-action.html",
navigation_links=best_practices_nav(),
)
@main.route("/guides/best-practices/multiple-languages")
@main.route("/guides/multiple-languages")
@user_is_logged_in
def multiple_languages():
return render_template(
"views/best-practices/multiple-languages.html",
"views/guides/multiple-languages.html",
navigation_links=best_practices_nav(),
)
@main.route("/guides/best-practices/benchmark-performance")
@main.route("/guides/benchmark-performance")
@user_is_logged_in
def benchmark_performance():
return render_template(
"views/best-practices/benchmark-performance.html",
"views/guides/benchmark-performance.html",
navigation_links=best_practices_nav(),
)
@@ -287,6 +278,13 @@ def guidance_index():
)
@main.route("/contact")
def contact():
return render_template(
"views/about/contact.html",
)
@main.route("/about")
def about_notify():
return render_template(
@@ -295,10 +293,18 @@ def about_notify():
)
@main.route("/about/contact")
def contact():
@main.route("/about/security")
def about_security():
return render_template(
"views/about/contact.html",
"views/about/security.html",
navigation_links=about_notify_nav(),
)
@main.route("/about/why-text-messaging")
def why_text_messaging():
return render_template(
"views/about/why-text-messaging.html",
navigation_links=about_notify_nav(),
)

View File

@@ -1,3 +1,6 @@
from flask import current_app
def features_nav():
return [
{
@@ -22,46 +25,20 @@ def features_nav():
def using_notify_nav():
return [
{
"name": "Get started",
"link": "main.get_started",
},
{
"name": "Guides",
"link": "main.best_practices",
},
{
"name": "Trial mode",
"link": "main.trial_mode_new",
},
{
"name": "Tracking usage",
"link": "main.pricing",
},
{
"name": "Delivery status",
"link": "main.message_status",
},
{
"name": "Guidance",
"link": "main.guidance_index",
# "sub_navigation_items": [
# {
# "name": "Formatting",
# "link": "main.edit_and_format_messages",
# },
# {
# "name": "Send files by email",
# "link": "main.send_files_by_email",
# },
# ]
# {
# "name": "API documentation",
# "link": "main.documentation",
# },
},
nav_items = [
{"name": "Get started", "link": "main.get_started"},
{"name": "Guides", "link": "main.best_practices"},
{"name": "Trial mode", "link": "main.trial_mode_new"},
{"name": "Tracking usage", "link": "main.pricing"},
{"name": "Delivery Status", "link": "main.message_status"},
{"name": "Guidance", "link": "main.guidance_index"},
]
if not current_app.config.get("FEATURE_BEST_PRACTICES_ENABLED"):
nav_items = [
item for item in nav_items if item["link"] != "main.best_practices"
]
return nav_items
def best_practices_nav():
@@ -110,8 +87,32 @@ def best_practices_nav():
def about_notify_nav():
return [
{
"name": "About notify",
"name": "About Notify",
"link": "main.about_notify",
"sub_navigation_items": [
{
"name": "Why text messaging",
"link": "main.why_text_messaging",
"sub_sub_navigation_items": [
{
"name": "Reach people using a common method",
"link": "main.why_text_messaging#reach-people-using-a-common-method",
},
{
"name": "Improve customer experience",
"link": "main.why_text_messaging#improve-customer-experience",
},
{
"name": "What texting is best for",
"link": "main.why_text_messaging#what-texting-is-best-for",
},
],
},
{
"name": "Security",
"link": "main.about_security",
},
],
},
{
"name": "Contact",