Skip to content

Commit

Permalink
Fix: ensure jinja2 can pick up GA4 vars and remove context processors (
Browse files Browse the repository at this point in the history
…#71)

* fix: ensure jinja2 is using django context processors

* fix: exposing variables without context processors
  • Loading branch information
nboyse authored Aug 22, 2024
1 parent fd45938 commit 8e3e95a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 19 deletions.
16 changes: 0 additions & 16 deletions django_app/redbox_app/context_processors.py

This file was deleted.

5 changes: 4 additions & 1 deletion django_app/redbox_app/jinja2.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ def to_user_timezone(value):
user_tz = pytz.timezone("Europe/London")
return value.astimezone(user_tz).strftime("%H:%M %d/%m/%Y")


def environment(**options):
extra_options = {}
env = jinja2.Environment( # nosec: B701 # noqa: S701
Expand All @@ -77,6 +76,7 @@ def environment(**options):
**extra_options,
},
)

env.filters.update(
{
"static": static,
Expand All @@ -99,6 +99,9 @@ def environment(**options):
"environment": settings.ENVIRONMENT.value,
"security": settings.MAX_SECURITY_CLASSIFICATION.value,
"repo_owner": settings.REPO_OWNER,
"analytics_tag": settings.ANALYTICS_TAG,
"analytics_link": settings.ANALYTICS_LINK,

}
)
return env
4 changes: 2 additions & 2 deletions django_app/redbox_app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,6 @@
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
"redbox_app.context_processors.analytics_tag",
"redbox_app.context_processors.analytics_link",
],
},
},
Expand Down Expand Up @@ -370,3 +368,5 @@
LOGIN_URL = "sign-in"

REPO_OWNER = env.str("REPO_OWNER", "i-dot-ai")
ANALYTICS_TAG = env.str("ANALYTICS_TAG")
ANALYTICS_LINK = env.str("ANALYTICS_LINK")

0 comments on commit 8e3e95a

Please sign in to comment.