From 09fc4bbc3ef66b02f0711dadaf3b10ed53d9d968 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Wed, 10 Dec 2025 12:57:14 -0600 Subject: Feature Flags: Generically deal with HTTP-based feature flags. * Define a default `FEATURE_FLAGS_HTTP` configuration variable that's an empty list to help defining http-based feature flags that can be used to turn on/off features * Build macro to include hidden fields for feature flags where necessary. * Extend flask's `url_for` function to deal with defined feature flags in a mostly transparent way --- uploader/__init__.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'uploader/__init__.py') diff --git a/uploader/__init__.py b/uploader/__init__.py index b7f0ab9..7425b38 100644 --- a/uploader/__init__.py +++ b/uploader/__init__.py @@ -22,6 +22,7 @@ from .files.views import files from .species import speciesbp from .publications import pubbp from .oauth2.views import oauth2 +from .flask_extensions import url_for from .expression_data import exprdatabp from .errors import register_error_handlers from .background_jobs import background_jobs_bp @@ -109,17 +110,22 @@ def create_app(config: Optional[dict] = None): setup_logging(app) setup_modules_logging(app.logger, ( "uploader.base_routes", + "uploader.flask_extensions", "uploader.publications.models", "uploader.publications.datatables", "uploader.phenotypes.models")) # setup jinja2 symbols - app.add_template_global(lambda : request.url, name="request_url") + app.add_template_global(user_logged_in) + app.add_template_global(url_for, name="url_for") app.add_template_global(authserver_authorise_uri) + app.add_template_global(lambda : request.url, name="request_url") app.add_template_global(lambda: app.config["GN2_SERVER_URL"], name="gn2server_uri") - app.add_template_global(user_logged_in) - app.add_template_global(lambda : session.user_details()["email"], name="user_email") + app.add_template_global(lambda : session.user_details()["email"], + name="user_email") + app.add_template_global(lambda: app.config["FEATURE_FLAGS_HTTP"], + name="http_feature_flags") Session(app) -- cgit 1.4.1