Updated code based on comments

This commit is contained in:
alexjanousekGSA
2024-10-29 15:28:07 -04:00
parent 7ed04c82d6
commit b806fd5eec
7 changed files with 19 additions and 19 deletions

View File

@@ -161,7 +161,7 @@
"filename": "app/config.py", "filename": "app/config.py",
"hashed_secret": "577a4c667e4af8682ca431857214b3a920883efc", "hashed_secret": "577a4c667e4af8682ca431857214b3a920883efc",
"is_verified": false, "is_verified": false,
"line_number": 119, "line_number": 121,
"is_secret": false "is_secret": false
} }
], ],
@@ -684,5 +684,5 @@
} }
] ]
}, },
"generated_at": "2024-10-24T21:58:17Z" "generated_at": "2024-10-29T19:28:03Z"
} }

View File

@@ -87,7 +87,9 @@ class Config(object):
"tts-benefits-studio@gsa.gov", "tts-benefits-studio@gsa.gov",
], ],
} }
FEATURE_BEST_PRACTICES_ENABLED = getenv("FEATURE_BEST_PRACTICES_ENABLED", "false") FEATURE_BEST_PRACTICES_ENABLED = (
getenv("FEATURE_BEST_PRACTICES_ENABLED", "false") == "true"
)
def _s3_credentials_from_env(bucket_prefix): def _s3_credentials_from_env(bucket_prefix):

View File

@@ -17,17 +17,15 @@ from app.main.views.sub_navigation_dictionaries import (
from app.utils.user import user_is_logged_in from app.utils.user import user_is_logged_in
from notifications_utils.url_safe_token import generate_token from notifications_utils.url_safe_token import generate_token
feature_best_practices_enabled = (
os.getenv("FEATURE_BEST_PRACTICES_ENABLED", "false").lower() == "true"
)
# Hook to check for guidance routes # Hook to check for guidance routes
@main.before_request @main.before_request
def check_guidance_feature(): def check_guidance_feature():
current_app.logger.warning("best practices 1234")
current_app.logger.warning(current_app.config["FEATURE_BEST_PRACTICES_ENABLED"])
if ( if (
request.path.startswith("/best-practices") request.path.startswith("/best-practices")
and not feature_best_practices_enabled and not current_app.config["FEATURE_BEST_PRACTICES_ENABLED"]
): ):
abort(404) abort(404)
@@ -276,7 +274,9 @@ def guidance_index():
return render_template( return render_template(
"views/guidance/index.html", "views/guidance/index.html",
navigation_links=using_notify_nav(), navigation_links=using_notify_nav(),
feature_best_practices_enabled=feature_best_practices_enabled feature_best_practices_enabled=current_app.config[
"FEATURE_BEST_PRACTICES_ENABLED"
],
) )

View File

@@ -1,7 +1,7 @@
env: demo env: demo
instances: 1 instances: 1
memory: 1G memory: 1G
command: gunicorn -c /home/vcap/app/gunicorn_config.py application command: newrelic-admin run-program gunicorn -c /home/vcap/app/gunicorn_config.py application
public_admin_route: notify-demo.app.cloud.gov public_admin_route: notify-demo.app.cloud.gov
cloud_dot_gov_route: notify-demo.app.cloud.gov cloud_dot_gov_route: notify-demo.app.cloud.gov
redis_enabled: 1 redis_enabled: 1

View File

@@ -1,7 +1,7 @@
env: production env: production
instances: 2 instances: 2
memory: 1.5G memory: 1.5G
command: gunicorn -c /home/vcap/app/gunicorn_config.py application command: newrelic-admin run-program gunicorn -c /home/vcap/app/gunicorn_config.py application
public_admin_route: beta.notify.gov public_admin_route: beta.notify.gov
cloud_dot_gov_route: notify.app.cloud.gov cloud_dot_gov_route: notify.app.cloud.gov
redis_enabled: 1 redis_enabled: 1

View File

@@ -1,7 +1,7 @@
env: staging env: staging
instances: 1 instances: 1
memory: 1G memory: 1G
command: gunicorn -c /home/vcap/app/gunicorn_config.py application command: newrelic-admin run-program gunicorn -c /home/vcap/app/gunicorn_config.py application
public_admin_route: notify-staging.app.cloud.gov public_admin_route: notify-staging.app.cloud.gov
cloud_dot_gov_route: notify-staging.app.cloud.gov cloud_dot_gov_route: notify-staging.app.cloud.gov
redis_enabled: 1 redis_enabled: 1

View File

@@ -1,9 +1,8 @@
import os
from functools import partial from functools import partial
import pytest import pytest
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
from flask import url_for from flask import current_app, url_for
from freezegun import freeze_time from freezegun import freeze_time
from tests.conftest import SERVICE_ONE_ID, normalize_spaces from tests.conftest import SERVICE_ONE_ID, normalize_spaces
@@ -118,10 +117,6 @@ def test_static_pages(client_request, mock_get_organization_by_domain, view, moc
# Function to check if a view is feature-flagged and should return 404 when disabled # Function to check if a view is feature-flagged and should return 404 when disabled
def is_feature_flagged(view): def is_feature_flagged(view):
feature_best_practices_enabled = (
os.getenv("FEATURE_BEST_PRACTICES_ENABLED", "false").lower() == "true"
)
feature_flagged_views = [ feature_flagged_views = [
"best_practices", "best_practices",
"clear_goals", "clear_goals",
@@ -131,7 +126,10 @@ def test_static_pages(client_request, mock_get_organization_by_domain, view, moc
"multiple_languages", "multiple_languages",
"benchmark_performance", "benchmark_performance",
] ]
return not feature_best_practices_enabled and view in feature_flagged_views return (
not current_app.config["FEATURE_BEST_PRACTICES_ENABLED"]
and view in feature_flagged_views
)
request = partial(client_request.get, "main.{}".format(view)) request = partial(client_request.get, "main.{}".format(view))