From c56f72878e8d7f76163db962b8b7db54ae7e8317 Mon Sep 17 00:00:00 2001 From: Waheed Ahmed Date: Wed, 18 Oct 2017 13:21:24 +0500 Subject: [PATCH] Fix edX logo links to home page instead of dashboard. When you are on the Dashboard, or on any page in courseware, the logo in the Header links to dashboard and the logo in the footer links to edX home page. LEARNER-2881 --- lms/djangoapps/branding/api.py | 14 ++++++++++++++ lms/djangoapps/branding/tests/test_api.py | 16 +++++++++++++++- lms/templates/header/brand.html | 2 +- lms/templates/navigation/navbar-logo-header.html | 2 +- 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/lms/djangoapps/branding/api.py b/lms/djangoapps/branding/api.py index 4d196d751a..6c9f05f1b2 100644 --- a/lms/djangoapps/branding/api.py +++ b/lms/djangoapps/branding/api.py @@ -17,6 +17,7 @@ import urlparse from django.conf import settings from django.contrib.staticfiles.storage import staticfiles_storage +from django.core.urlresolvers import reverse from django.utils.translation import ugettext as _ from branding.models import BrandingApiConfig @@ -418,3 +419,16 @@ def get_about_url(): Lookup and return About page url """ return get_url("ABOUT") + + +def get_home_url(): + """ + Lookup and return home page url, lookup is performed in the following order + + 1. return marketing root URL, If marketing is enabled + 2. Otherwise return dashboard URL. + """ + if settings.FEATURES.get('ENABLE_MKTG_SITE', False): + return marketing_link('ROOT') + + return reverse('dashboard') diff --git a/lms/djangoapps/branding/tests/test_api.py b/lms/djangoapps/branding/tests/test_api.py index 4886b949ab..29e4695490 100644 --- a/lms/djangoapps/branding/tests/test_api.py +++ b/lms/djangoapps/branding/tests/test_api.py @@ -3,10 +3,12 @@ from __future__ import unicode_literals import mock +from django.core.urlresolvers import reverse from django.test import TestCase from django.test.utils import override_settings -from branding.api import get_footer, get_logo_url +from branding.api import get_footer, get_home_url, get_logo_url +from edxmako.shortcuts import marketing_link class TestHeader(TestCase): @@ -24,6 +26,18 @@ class TestHeader(TestCase): self.assertEqual(logo_url, cdn_url) + def test_home_url_with_mktg_disabled(self): + expected_url = get_home_url() + self.assertEqual(reverse('dashboard'), expected_url) + + @mock.patch.dict('django.conf.settings.FEATURES', {'ENABLE_MKTG_SITE': True}) + @mock.patch.dict('django.conf.settings.MKTG_URLS', { + "ROOT": "https://edx.org", + }) + def test_home_url_with_mktg_enabled(self): + expected_url = get_home_url() + self.assertEqual(marketing_link('ROOT'), expected_url) + class TestFooter(TestCase): """Test retrieving the footer. """ diff --git a/lms/templates/header/brand.html b/lms/templates/header/brand.html index 12c9ea76de..8bd713938b 100644 --- a/lms/templates/header/brand.html +++ b/lms/templates/header/brand.html @@ -14,7 +14,7 @@ from branding import api as branding_api

diff --git a/lms/templates/navigation/navbar-logo-header.html b/lms/templates/navigation/navbar-logo-header.html index b86bd5911b..fa9ca45d38 100644 --- a/lms/templates/navigation/navbar-logo-header.html +++ b/lms/templates/navigation/navbar-logo-header.html @@ -14,7 +14,7 @@ from branding import api as branding_api