Skip to content

Commit

Permalink
Allow the 'My account' url to be changed at the environment level, an…
Browse files Browse the repository at this point in the history
…d do not show the link when the value is not set
  • Loading branch information
ababic committed Jul 1, 2022
1 parent 0f4d11b commit 9c3496a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
"wagtail.contrib.settings.context_processors.settings",
"etna.core.context_processors.globals",
"etna.core.context_processors.feature_flags",
],
},
Expand All @@ -134,6 +135,7 @@
LOGIN_REDIRECT_URL = "/"
LOGOUT_URL = "/accounts/logout"
LOGOUT_REDIRECT_URL = "/"
MY_ACCOUNT_URL = os.getenv("MY_ACCOUNT_URL")
WAGTAIL_FRONTEND_LOGIN_URL = LOGIN_URL
# View access control
IMAGE_VIEWER_REQUIRE_LOGIN = strtobool(os.getenv("IMAGE_VIEWER_REQUIRE_LOGIN", "True"))
Expand Down
9 changes: 9 additions & 0 deletions etna/core/context_processors.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
from django.conf import settings


def globals(request):
"""
Adds common setting (and potentially other values) to the context.
"""
return {
"MY_ACCOUNT_URL": settings.MY_ACCOUNT_URL,
}


def feature_flags(request):
"""
Makes any settings with the "FEATURE_" prefix available template contexts,
Expand Down
2 changes: 1 addition & 1 deletion templates/includes/login-status.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="login-status" role="region" aria-labelledby="authentication_link">
{% if request.user.is_authenticated %}
<a href="https://tna-account-management-poc.torchbox.dev/" class="login-status__link">My account</a>
{% if MY_ACCOUNT_URL %}<a href="{{ MY_ACCOUNT_URL }}" class="login-status__link">My account</a>{% endif %}
<a href="{% url 'account_logout' %}" class="login-status__link" id="authentication_link">Logout</a>
{% else %}
<a href="{% url 'account_login' %}" class="login-status__link" id="authentication_link">Login</a>
Expand Down

0 comments on commit 9c3496a

Please sign in to comment.