Added feature flag for route

This commit is contained in:
alexjanousekGSA
2024-11-14 10:53:48 -05:00
parent 3a52cba23e
commit 70ecf8fa09
3 changed files with 15 additions and 8 deletions

View File

@@ -161,7 +161,7 @@
"filename": "app/config.py",
"hashed_secret": "577a4c667e4af8682ca431857214b3a920883efc",
"is_verified": false,
"line_number": 121,
"line_number": 125,
"is_secret": false
}
],
@@ -684,5 +684,5 @@
}
]
},
"generated_at": "2024-10-29T19:28:03Z"
"generated_at": "2024-11-14T15:53:44Z"
}

View File

@@ -91,6 +91,10 @@ class Config(object):
getenv("FEATURE_BEST_PRACTICES_ENABLED", "false") == "true"
)
FEATURE_ABOUT_PAGE_ENABLED = (
getenv("FEATURE_ABOUT_PAGE_ENABLED", "false") == "true"
)
def _s3_credentials_from_env(bucket_prefix):
return {

View File

@@ -19,14 +19,18 @@ from app.utils.user import user_is_logged_in
from notifications_utils.url_safe_token import generate_token
# Hook to check for guidance routes
# Hook to check for feature flags
@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"])
def check_feature_flags():
if (
request.path.startswith("/best-practices")
and not current_app.config["FEATURE_BEST_PRACTICES_ENABLED"]
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)
):
abort(404)
@@ -270,7 +274,6 @@ def benchmark_performance():
@main.route("/about")
@user_is_logged_in
def about_notify():
return render_template(
"views/about/about.html",