diff --git a/app/__init__.py b/app/__init__.py index 483d89ea0..1e0f9c569 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -162,6 +162,13 @@ def _csp(config): def create_app(application): + + @application.context_processor + def inject_feature_flags(): + feature_best_practices_enabled = os.getenv("FEATURE_BEST_PRACTICES_ENABLED", "false").lower() == "true" + return dict(FEATURE_BEST_PRACTICES_ENABLED=feature_best_practices_enabled) + + notify_environment = os.environ["NOTIFY_ENVIRONMENT"] application.config.from_object(configs[notify_environment]) diff --git a/app/main/views/index.py b/app/main/views/index.py index 8b965991c..a5af4d506 100644 --- a/app/main/views/index.py +++ b/app/main/views/index.py @@ -21,10 +21,8 @@ from notifications_utils.url_safe_token import generate_token # Hook to check for guidance routes @main.before_request def check_guidance_feature(): - current_app.logger.warning("best practices 1234") - current_app.logger.warning(current_app.config["FEATURE_BEST_PRACTICES_ENABLED"]) if ( - request.path.startswith("/best-practices") + request.path.startswith("/guides/best-practices") and not current_app.config["FEATURE_BEST_PRACTICES_ENABLED"] ): abort(404) @@ -205,7 +203,7 @@ def trial_mode_new(): ) -@main.route("/best-practices") +@main.route("/guides/best-practices") @user_is_logged_in def best_practices(): return render_template( @@ -214,7 +212,7 @@ def best_practices(): ) -@main.route("/best-practices/clear-goals") +@main.route("/guides/best-practices/clear-goals") @user_is_logged_in def clear_goals(): return render_template( @@ -223,7 +221,7 @@ def clear_goals(): ) -@main.route("/best-practices/rules-and-regulations") +@main.route("/guides/best-practices/rules-and-regulations") @user_is_logged_in def rules_and_regulations(): return render_template( @@ -232,7 +230,7 @@ def rules_and_regulations(): ) -@main.route("/best-practices/establish-trust") +@main.route("/guides/best-practices/establish-trust") @user_is_logged_in def establish_trust(): return render_template( @@ -241,7 +239,7 @@ def establish_trust(): ) -@main.route("/best-practices/write-for-action") +@main.route("/guides/best-practices/write-for-action") @user_is_logged_in def write_for_action(): return render_template( @@ -250,7 +248,7 @@ def write_for_action(): ) -@main.route("/best-practices/multiple-languages") +@main.route("/guides/best-practices/multiple-languages") @user_is_logged_in def multiple_languages(): return render_template( @@ -259,7 +257,7 @@ def multiple_languages(): ) -@main.route("/best-practices/benchmark-performance") +@main.route("/guides/best-practices/benchmark-performance") @user_is_logged_in def benchmark_performance(): return render_template( @@ -268,7 +266,7 @@ def benchmark_performance(): ) -@main.route("/using-notify/guidance") +@main.route("/guides/using-notify/guidance") @user_is_logged_in def guidance_index(): return render_template( diff --git a/app/main/views/sub_navigation_dictionaries.py b/app/main/views/sub_navigation_dictionaries.py index 0689c198d..1f41c4b40 100644 --- a/app/main/views/sub_navigation_dictionaries.py +++ b/app/main/views/sub_navigation_dictionaries.py @@ -26,6 +26,10 @@ def using_notify_nav(): { "name": "Get started", "link": "main.get_started", + }, + { + "name": "Best Practices", + "link": "main.best_practices", }, { "name": "Trial mode", diff --git a/app/navigation.py b/app/navigation.py index 6ef0907a6..73d86a319 100644 --- a/app/navigation.py +++ b/app/navigation.py @@ -46,6 +46,9 @@ class HeaderNavigation(Navigation): "roadmap", "security", }, + "best_practices": { + "best_practices", + }, "using_notify": { "get_started", "using_notify", diff --git a/app/templates/components/header.html b/app/templates/components/header.html index 5ae37fc71..82ce61852 100644 --- a/app/templates/components/header.html +++ b/app/templates/components/header.html @@ -1,32 +1,43 @@ {% if current_user.is_authenticated %} - {% set navigation = [ - {"href": url_for("main.show_accounts_or_dashboard"), "text": "Current service", "active": header_navigation.is_selected('accounts-or-dashboard')}, - {"href": url_for('main.get_started'), "text": "Using Notify", "active": header_navigation.is_selected('using_notify')}, - {"href": url_for('main.features'), "text": "Features", "active": header_navigation.is_selected('features')}, - {"href": url_for('main.support'), "text": "Contact us", "active": header_navigation.is_selected('support')} - ] %} +{% set navigation = [ +{"href": url_for("main.show_accounts_or_dashboard"), "text": "Current service", "active": +header_navigation.is_selected('accounts-or-dashboard')}, +{"href": url_for('main.get_started'), "text": "Using Notify", "active": header_navigation.is_selected('using_notify')} +] %} - {% if current_user.platform_admin %} - {% set navigation = navigation + [{"href": url_for('main.platform_admin_splash_page'), "text": "Platform admin", "active": header_navigation.is_selected('platform-admin')}] %} - {% else %} - {% set navigation = navigation + [{"href": url_for('main.user_profile'), "text": "User profile", "active": header_navigation.is_selected('user-profile')}] %} - {% endif %} +{% if FEATURE_BEST_PRACTICES_ENABLED %} +{% set navigation = navigation + [{"href": url_for('main.best_practices'), "text": "Best Practices", "active": +header_navigation.is_selected('best_practices')}] %} +{% endif %} - {% if current_service %} - {% if current_user.has_permissions('manage_service') %} - {% set secondaryNavigation = [ - {"href": url_for('main.service_settings', service_id=current_service.id), "text": "Settings", "active": secondary_navigation.is_selected('settings')}, - {"href": url_for('main.sign_out'), "text": "Sign out"} - ] %} - {% else %} - {% set secondaryNavigation = [ - {"href": url_for('main.sign_out'), "text": "Sign out"} - ] %} +{% set navigation = navigation + [ +{"href": url_for('main.features'), "text": "Features", "active": header_navigation.is_selected('features')}, +{"href": url_for('main.support'), "text": "Contact us", "active": header_navigation.is_selected('support')} +] %} - {% endif %} - {% else %} - {% set secondaryNavigation = [{"href": url_for('main.sign_out'), "text": "Sign out"}] %} - {% endif %} +{% if current_user.platform_admin %} +{% set navigation = navigation + [{"href": url_for('main.platform_admin_splash_page'), "text": "Platform admin", +"active": header_navigation.is_selected('platform-admin')}] %} +{% else %} +{% set navigation = navigation + [{"href": url_for('main.user_profile'), "text": "User profile", "active": +header_navigation.is_selected('user-profile')}] %} +{% endif %} + +{% if current_service %} +{% if current_user.has_permissions('manage_service') %} +{% set secondaryNavigation = [ +{"href": url_for('main.service_settings', service_id=current_service.id), "text": "Settings", "active": +secondary_navigation.is_selected('settings')}, +{"href": url_for('main.sign_out'), "text": "Sign out"} +] %} +{% else %} +{% set secondaryNavigation = [ +{"href": url_for('main.sign_out'), "text": "Sign out"} +] %} +{% endif %} +{% else %} +{% set secondaryNavigation = [{"href": url_for('main.sign_out'), "text": "Sign out"}] %} +{% endif %} {% endif %}
@@ -36,12 +47,12 @@
Notify.gov logo - - +
{% if navigation %} - + {% endif %} @@ -52,29 +63,29 @@
diff --git a/urls.js b/urls.js index 8ff543470..0440430ec 100644 --- a/urls.js +++ b/urls.js @@ -13,13 +13,25 @@ const sublinks = [ { label: 'Roadmap', path: '/features/roadmap' }, { label: 'Security', path: '/features/security' }, { label: 'Support', path: '/support' }, - { label: 'Best Practices', path: '/best-practices' }, - { label: 'Clear Goals', path: '/best-practices/clear-goals' }, - { label: 'Rules And Regulations', path: '/best-practices/rules-and-regulations' }, - { label: 'Establish Trust', path: '/best-practices/establish-trust' }, - { label: 'Write For Action', path: '/best-practices/write-for-action' }, - { label: 'Multiple Languages', path: '/best-practices/multiple-languages' }, - { label: 'Benchmark Performance', path: '/best-practices/benchmark-performance' }, + { label: 'Best Practices', path: '/guides/best-practices' }, + { label: 'Clear Goals', path: '/guides/best-practices/clear-goals' }, + { + label: 'Rules And Regulations', + path: '/guides/best-practices/rules-and-regulations', + }, + { label: 'Establish Trust', path: '/guides/best-practices/establish-trust' }, + { + label: 'Write For Action', + path: '/guides/best-practices/write-for-action', + }, + { + label: 'Multiple Languages', + path: '/guides/best-practices/multiple-languages', + }, + { + label: 'Benchmark Performance', + path: '/guides/best-practices/benchmark-performance', + }, // Add more links here as needed ];