Skip to content

Commit

Permalink
Added Turnstile URLs to settings. Moved context processor and removed…
Browse files Browse the repository at this point in the history
… redundant processor (#2532)
  • Loading branch information
joshuastegmaier authored Sep 19, 2024
1 parent aaf0608 commit 6a6ca06
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 37 deletions.
29 changes: 0 additions & 29 deletions concordia/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,32 +32,3 @@ def site_navigation(request):
def maintenance_mode_frontend_available(request):
value = cache.get("maintenance_mode_frontend_available", False)
return {"maintenance_mode_frontend_available": value}


def turnstile_default_settings(request):
"""
Expose turnstile default settings to the default template context
- Cloudflare Turnstile
"""

return {
"TURNSTILE_JS_API_URL": getattr(
settings,
"TURN_JS_API_URL",
"https://challenges.cloudflare.com/turnstile/v0/api.js",
),
"TURNSTILE_VERIFY_URL": getattr(
settings,
"TURNSTILE_VERIFY_URL",
"https://challenges.cloudflare.com/turnstile/v0/siteverify",
),
"TURNSTILE_SITEKEY": getattr(
settings, "TURNSTILE_SITEKEY", "1x00000000000000000000BB"
),
"TURNSTILE_SECRET": getattr(
settings, "TURNSTILE_SECRET", "1x0000000000000000000000000000000AA"
),
"TURNSTILE_TIMEOUT": getattr(settings, "TURNSTILE_TIMEOUT", 5),
"TURNSTILE_DEFAULT_CONFIG": getattr(settings, "TURNSTILE_DEFAULT_CONFIG", {}),
"TURNSTILE_PROXIES": getattr(settings, "TURNSTILE_PROXIES", {}),
}
10 changes: 7 additions & 3 deletions concordia/settings_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
"concordia.context_processors.system_configuration",
"concordia.context_processors.site_navigation",
"concordia.context_processors.maintenance_mode_frontend_available",
"concordia.context_processors.turnstile_default_settings",
"concordia.turnstile.context_processors.turnstile_default_settings",
],
"libraries": {
"staticfiles": "django.templatetags.static",
Expand Down Expand Up @@ -318,8 +318,12 @@
]

# Turnstile settings
TURNSTILE_JS_API_URL = os.environ.get("TURNSTILE_JS_API_URL", "")
TURNSTILE_VERIFY_URL = os.environ.get("TURNSTILE_VERIFY_URL", "")
TURNSTILE_JS_API_URL = os.environ.get(
"TURNSTILE_JS_API_URL", "https://challenges.cloudflare.com/turnstile/v0/api.js"
)
TURNSTILE_VERIFY_URL = os.environ.get(
"TURNSTILE_VERIFY_URL", "https://challenges.cloudflare.com/turnstile/v0/siteverify"
)
TURNSTILE_SITEKEY = os.environ.get("TURNSTILE_SITEKEY", "")
TURNSTILE_SECRET = os.environ.get("TURNSTILE_SECRET", "")
TURNSTILE_TIMEOUT = os.environ.get("TURNSTILE_TIMEOUT", 5)
Expand Down
5 changes: 0 additions & 5 deletions concordia/turnstile/context_processor.py

This file was deleted.

30 changes: 30 additions & 0 deletions concordia/turnstile/context_processors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from django.conf import settings


def turnstile_default_settings(request):
"""
Expose turnstile default settings to the default template context
- Cloudflare Turnstile
"""

return {
"TURNSTILE_JS_API_URL": getattr(
settings,
"TURN_JS_API_URL",
"https://challenges.cloudflare.com/turnstile/v0/api.js",
),
"TURNSTILE_VERIFY_URL": getattr(
settings,
"TURNSTILE_VERIFY_URL",
"https://challenges.cloudflare.com/turnstile/v0/siteverify",
),
"TURNSTILE_SITEKEY": getattr(
settings, "TURNSTILE_SITEKEY", "1x00000000000000000000BB"
),
"TURNSTILE_SECRET": getattr(
settings, "TURNSTILE_SECRET", "1x0000000000000000000000000000000AA"
),
"TURNSTILE_TIMEOUT": getattr(settings, "TURNSTILE_TIMEOUT", 5),
"TURNSTILE_DEFAULT_CONFIG": getattr(settings, "TURNSTILE_DEFAULT_CONFIG", {}),
"TURNSTILE_PROXIES": getattr(settings, "TURNSTILE_PROXIES", {}),
}

0 comments on commit 6a6ca06

Please sign in to comment.