Skip to content

Commit

Permalink
Merge pull request #446 from edly-io/alisalman/fix-multisites-urls
Browse files Browse the repository at this point in the history
fix: get marketing and auth urls from site configurations
  • Loading branch information
Ali-Salman29 authored Nov 3, 2023
2 parents fed311d + db884c5 commit 804d9b1
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 7 deletions.
11 changes: 9 additions & 2 deletions cms/djangoapps/contentstore/views/public.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from django.shortcuts import redirect

from common.djangoapps.edxmako.shortcuts import render_to_response
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers

from ..config.waffle import ENABLE_ACCESSIBILITY_POLICY_PAGE

Expand All @@ -23,8 +24,11 @@ def register_redirect_to_lms(request):
This view redirects to the LMS register view. It is used to temporarily keep the old
Studio signup url alive.
"""
frontend_register_url = configuration_helpers.get_value(
"FRONTEND_REGISTER_URL", settings.FRONTEND_REGISTER_URL
)
register_url = '{register_url}{params}'.format(
register_url=settings.FRONTEND_REGISTER_URL,
register_url=frontend_register_url,
params=_build_next_param(request),
)
return redirect(register_url, permanent=True)
Expand All @@ -35,8 +39,11 @@ def login_redirect_to_lms(request):
This view redirects to the LMS login view. It is used for Django's LOGIN_URL
setting, which is where unauthenticated requests to protected endpoints are redirected.
"""
frontend_login_url = configuration_helpers.get_value(
"FRONTEND_LOGIN_URL", settings.FRONTEND_LOGIN_URL
)
login_url = '{login_url}{params}'.format(
login_url=settings.FRONTEND_LOGIN_URL,
login_url=frontend_login_url,
params=_build_next_param(request),
)
return redirect(login_url)
Expand Down
14 changes: 12 additions & 2 deletions cms/templates/howitworks.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@
from django.utils.translation import gettext as _
from urllib.parse import quote_plus
from openedx.core.djangolib.markup import HTML, Text
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
%>

<%!
frontend_register_url = configuration_helpers.get_value(
"FRONTEND_REGISTER_URL", settings.FRONTEND_REGISTER_URL
)
login_url = configuration_helpers.get_value(
"LOGIN_URL", settings.LOGIN_URL
)
%>

<%block name="title">${_("Welcome")}</%block>
Expand Down Expand Up @@ -163,10 +173,10 @@ <h2 class="sr">${_("Sign Up for {studio_name} Today!").format(studio_name=settin

<ul class="list-actions">
<li class="action-item">
<a href="${settings.FRONTEND_REGISTER_URL}?next=${quote_plus(request.build_absolute_uri(settings.LOGIN_URL))}" class="action action-primary">${_("Sign Up & Start Making Your {platform_name} Course").format(platform_name=settings.PLATFORM_NAME)}</a>
<a href="${frontend_register_url}?next=${quote_plus(request.build_absolute_uri(settings.LOGIN_URL))}" class="action action-primary">${_("Sign Up & Start Making Your {platform_name} Course").format(platform_name=settings.PLATFORM_NAME)}</a>
</li>
<li class="action-item">
<a href="${settings.LOGIN_URL}?next=${current_url}" class="action action-secondary">${_("Already have a {studio_name} Account? Sign In").format(studio_name=settings.STUDIO_SHORT_NAME)}</a>
<a href="${login_url}?next=${current_url}" class="action action-secondary">${_("Already have a {studio_name} Account? Sign In").format(studio_name=settings.STUDIO_SHORT_NAME)}</a>
</li>
</ul>
</section>
Expand Down
15 changes: 13 additions & 2 deletions cms/templates/widgets/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,18 @@
from cms.djangoapps.contentstore.utils import get_pages_and_resources_url
from openedx.core.djangoapps.discussions.config.waffle import ENABLE_PAGES_AND_RESOURCES_MICROFRONTEND
from openedx.core.djangoapps.lang_pref.api import header_language_selector_is_enabled, released_languages
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
%>

<%!
frontend_register_url = configuration_helpers.get_value(
"FRONTEND_REGISTER_URL", settings.FRONTEND_REGISTER_URL
)
login_url = configuration_helpers.get_value(
"LOGIN_URL", settings.LOGIN_URL
)
%>

<div class="wrapper-header wrapper" id="view-top">
<header class="primary" role="banner">
<div class="wrapper wrapper-l">
Expand Down Expand Up @@ -270,11 +281,11 @@ <h2 class="sr-only">${_("Account Navigation")}</h2>
</li>
% if static.get_value('ALLOW_PUBLIC_ACCOUNT_CREATION', settings.FEATURES.get('ALLOW_PUBLIC_ACCOUNT_CREATION')):
<li class="nav-item nav-not-signedin-signup">
<a class="action action-signup" href="${settings.FRONTEND_REGISTER_URL}?next=${quote_plus(request.build_absolute_uri(settings.LOGIN_URL))}">${_("Sign Up")}</a>
<a class="action action-signup" href="${frontend_register_url}?next=${quote_plus(request.build_absolute_uri(settings.LOGIN_URL))}">${_("Sign Up")}</a>
</li>
% endif
<li class="nav-item nav-not-signedin-signin">
<a class="action action-signin" href="${settings.LOGIN_URL}?next=${current_url}">${_("Sign In")}</a>
<a class="action action-signin" href="${login_url}?next=${current_url}">${_("Sign In")}</a>
</li>
</ol>
</nav>
Expand Down
5 changes: 4 additions & 1 deletion openedx/core/djangoapps/programs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ def get_program_marketing_url(programs_config, mobile_only=False):
if mobile_only:
marketing_url = 'edxapp://course?programs'
else:
marketing_url = urljoin(settings.MKTG_URLS.get('ROOT'), programs_config.marketing_path).rstrip('/')
mktg_urls = configuration_helpers.get_value(
"MKTG_URLS", settings.MKTG_URLS
)
marketing_url = urljoin(mktg_urls.get('ROOT'), programs_config.marketing_path).rstrip('/')

return marketing_url

Expand Down

0 comments on commit 804d9b1

Please sign in to comment.