diff --git a/cms/envs/common.py b/cms/envs/common.py index 99db8900d3c4..15db31c9f6a5 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -1208,7 +1208,7 @@ ################# EDX MARKETING SITE ################################## -MKTG_URL_LINK_MAP = {} +MKTG_URLS = {} ID_VERIFICATION_SUPPORT_LINK = '' PASSWORD_RESET_SUPPORT_LINK = '' diff --git a/cms/envs/production.py b/cms/envs/production.py index c6a0f090f39e..ea1dec3e1d36 100644 --- a/cms/envs/production.py +++ b/cms/envs/production.py @@ -84,7 +84,6 @@ def get_env_setting(setting): 'EVENT_TRACKING_BACKENDS', 'JWT_AUTH', 'CELERY_QUEUES', - 'MKTG_URL_LINK_MAP', 'REST_FRAMEWORK', 'EVENT_BUS_PRODUCER_CONFIG', 'DEFAULT_FILE_STORAGE', @@ -151,8 +150,6 @@ def get_env_setting(setting): CACHES['staticfiles']['KEY_PREFIX'] = EDX_PLATFORM_REVISION -MKTG_URL_LINK_MAP.update(_YAML_TOKENS.get('MKTG_URL_LINK_MAP', {})) - #Timezone overrides TIME_ZONE = CELERY_TIMEZONE diff --git a/common/djangoapps/edxmako/shortcuts.py b/common/djangoapps/edxmako/shortcuts.py index a8b0e7a0d9f5..b88ad6e62ba3 100644 --- a/common/djangoapps/edxmako/shortcuts.py +++ b/common/djangoapps/edxmako/shortcuts.py @@ -18,14 +18,11 @@ from django.conf import settings from django.http import HttpResponse # lint-amnesty, pylint: disable=unused-import from django.template import engines -from django.urls import reverse, NoReverseMatch from six.moves.urllib.parse import urljoin from django.core.validators import URLValidator from django.core.exceptions import ValidationError -from edx_django_utils.monitoring import set_custom_attribute from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers -from xmodule.util.xmodule_django import get_current_request_hostname # lint-amnesty, pylint: disable=wrong-import-order from . import Engines @@ -33,20 +30,11 @@ def marketing_link(name): - """Returns the correct URL for a link to the marketing site - depending on if the marketing site is enabled + """Returns the correct URL for a link to the marketing site. - Since the marketing site is enabled by a setting, we have two - possible URLs for certain links. This function is to decides - which URL should be provided. + This function returns marketing URLs based on the MKTG_URLS setting, + which can be overridden via MKTG_URL_OVERRIDES for specific links. """ - # link_map maps URLs from the marketing site to the old equivalent on - # the Django site - link_map = settings.MKTG_URL_LINK_MAP - enable_mktg_site = configuration_helpers.get_value( - 'ENABLE_MKTG_SITE', - settings.FEATURES.get('ENABLE_MKTG_SITE', False) - ) marketing_urls = configuration_helpers.get_value( 'MKTG_URLS', settings.MKTG_URLS @@ -66,7 +54,7 @@ def marketing_link(name): log.debug("Invalid link set for link %s: %s", name, err) return '#' - if enable_mktg_site and name in marketing_urls: + if name in marketing_urls: # special case for when we only want the root marketing URL if name == 'ROOT': return marketing_urls.get('ROOT') @@ -81,20 +69,6 @@ def marketing_link(name): # URLs in the MKTG_URLS setting # e.g. urljoin('https://marketing.com', 'https://open-edx.org/about') >>> 'https://open-edx.org/about' return urljoin(marketing_urls.get('ROOT'), marketing_urls.get(name)) - # only link to the old pages when the marketing site isn't on - elif not enable_mktg_site and name in link_map: - # don't try to reverse disabled marketing links - if link_map[name] is not None: - host_name = get_current_request_hostname() # lint-amnesty, pylint: disable=unused-variable - if link_map[name].startswith('http'): - return link_map[name] - else: - try: - return reverse(link_map[name]) - except NoReverseMatch: - log.debug("Cannot find corresponding link for name: %s", name) - set_custom_attribute('unresolved_marketing_link', name) - return '#' else: log.debug("Cannot find corresponding link for name: %s", name) return '#' @@ -113,19 +87,12 @@ def is_marketing_link_set(name): Returns a boolean if a given named marketing link is configured. """ - enable_mktg_site = configuration_helpers.get_value( - 'ENABLE_MKTG_SITE', - settings.FEATURES.get('ENABLE_MKTG_SITE', False) - ) marketing_urls = configuration_helpers.get_value( 'MKTG_URLS', settings.MKTG_URLS ) - if enable_mktg_site: - return name in marketing_urls - else: - return name in settings.MKTG_URL_LINK_MAP + return name in marketing_urls def marketing_link_context_processor(request): @@ -144,9 +111,7 @@ def marketing_link_context_processor(request): return { "MKTG_URL_" + k: marketing_link(k) - for k in ( - settings.MKTG_URL_LINK_MAP.keys() | marketing_urls.keys() - ) + for k in marketing_urls.keys() } diff --git a/common/djangoapps/edxmako/tests.py b/common/djangoapps/edxmako/tests.py index 51c2ab4efdd1..8610a288986a 100644 --- a/common/djangoapps/edxmako/tests.py +++ b/common/djangoapps/edxmako/tests.py @@ -3,12 +3,10 @@ from unittest.mock import Mock, patch import ddt -from django.conf import settings from django.http import HttpResponse from django.test import TestCase from django.test.client import RequestFactory from django.test.utils import override_settings -from django.urls import reverse from edx_django_utils.cache import RequestCache from common.djangoapps.edxmako import LOOKUP, add_lookup @@ -33,92 +31,34 @@ class ShortcutsTests(UrlResetMixin, TestCase): @override_settings(MKTG_URLS={'ROOT': 'https://dummy-root', 'ABOUT': '/about-us'}) def test_marketing_link(self): - with override_settings(MKTG_URL_LINK_MAP={'ABOUT': self._get_test_url_name()}): - # test marketing site on - with patch.dict('django.conf.settings.FEATURES', {'ENABLE_MKTG_SITE': True}): - expected_link = 'https://dummy-root/about-us' - link = marketing_link('ABOUT') - assert link == expected_link - # test marketing site off - with patch.dict('django.conf.settings.FEATURES', {'ENABLE_MKTG_SITE': False}): - expected_link = reverse(self._get_test_url_name()) - link = marketing_link('ABOUT') - assert link == expected_link + expected_link = 'https://dummy-root/about-us' + link = marketing_link('ABOUT') + assert link == expected_link @override_settings(MKTG_URLS={'ROOT': 'https://dummy-root', 'ABOUT': '/about-us'}) def test_is_marketing_link_set(self): - with override_settings(MKTG_URL_LINK_MAP={'ABOUT': self._get_test_url_name()}): - # test marketing site on - with patch.dict('django.conf.settings.FEATURES', {'ENABLE_MKTG_SITE': True}): - assert is_marketing_link_set('ABOUT') - assert not is_marketing_link_set('NOT_CONFIGURED') - # test marketing site off - with patch.dict('django.conf.settings.FEATURES', {'ENABLE_MKTG_SITE': False}): - assert is_marketing_link_set('ABOUT') - assert not is_marketing_link_set('NOT_CONFIGURED') + assert is_marketing_link_set('ABOUT') + assert not is_marketing_link_set('NOT_CONFIGURED') @override_settings(MKTG_URLS={'ROOT': 'https://dummy-root', 'ABOUT': '/about-us'}) def test_is_any_marketing_link_set(self): - with override_settings(MKTG_URL_LINK_MAP={'ABOUT': self._get_test_url_name()}): - # test marketing site on - with patch.dict('django.conf.settings.FEATURES', {'ENABLE_MKTG_SITE': True}): - assert is_any_marketing_link_set(['ABOUT']) - assert is_any_marketing_link_set(['ABOUT', 'NOT_CONFIGURED']) - assert not is_any_marketing_link_set(['NOT_CONFIGURED']) - # test marketing site off - with patch.dict('django.conf.settings.FEATURES', {'ENABLE_MKTG_SITE': False}): - assert is_any_marketing_link_set(['ABOUT']) - assert is_any_marketing_link_set(['ABOUT', 'NOT_CONFIGURED']) - assert not is_any_marketing_link_set(['NOT_CONFIGURED']) - - def _get_test_url_name(self): # lint-amnesty, pylint: disable=missing-function-docstring - if settings.ROOT_URLCONF == 'lms.urls': - # return any lms url name - return 'dashboard' - else: - # return any cms url name - return 'organizations' + assert is_any_marketing_link_set(['ABOUT']) + assert is_any_marketing_link_set(['ABOUT', 'NOT_CONFIGURED']) + assert not is_any_marketing_link_set(['NOT_CONFIGURED']) @override_settings(MKTG_URLS={'ROOT': 'https://dummy-root', 'TOS': '/tos'}) @override_settings(MKTG_URL_OVERRIDES={'TOS': 'https://edx.org'}) def test_override_marketing_link_valid(self): expected_link = 'https://edx.org' - # test marketing site on - with patch.dict('django.conf.settings.FEATURES', {'ENABLE_MKTG_SITE': True}): - link = marketing_link('TOS') - assert link == expected_link - # test marketing site off - with patch.dict('django.conf.settings.FEATURES', {'ENABLE_MKTG_SITE': False}): - link = marketing_link('TOS') - assert link == expected_link + link = marketing_link('TOS') + assert link == expected_link @override_settings(MKTG_URLS={'ROOT': 'https://dummy-root', 'TOS': '/tos'}) @override_settings(MKTG_URL_OVERRIDES={'TOS': '123456'}) def test_override_marketing_link_invalid(self): expected_link = '#' - # test marketing site on - with patch.dict('django.conf.settings.FEATURES', {'ENABLE_MKTG_SITE': True}): - link = marketing_link('TOS') - assert link == expected_link - # test marketing site off - with patch.dict('django.conf.settings.FEATURES', {'ENABLE_MKTG_SITE': False}): - link = marketing_link('TOS') - assert link == expected_link - - @skip_unless_lms - def test_link_map_url_reverse(self): - url_link_map = { - 'ABOUT': 'dashboard', - 'BAD_URL': 'foobarbaz', - } - - with patch.dict('django.conf.settings.FEATURES', {'ENABLE_MKTG_SITE': False}): - with override_settings(MKTG_URL_LINK_MAP=url_link_map): - link = marketing_link('ABOUT') - assert link == '/dashboard' - - link = marketing_link('BAD_URL') - assert link == '#' + link = marketing_link('TOS') + assert link == expected_link class AddLookupTests(TestCase): diff --git a/common/djangoapps/student/tests/test_tasks.py b/common/djangoapps/student/tests/test_tasks.py index d5fc3d3db0a2..a26580237027 100644 --- a/common/djangoapps/student/tests/test_tasks.py +++ b/common/djangoapps/student/tests/test_tasks.py @@ -22,6 +22,7 @@ @override_settings( BRAZE_COURSE_ENROLLMENT_CANVAS_ID=BRAZE_COURSE_ENROLLMENT_CANVAS_ID, LEARNING_MICROFRONTEND_URL="https://learningmfe.openedx.org", + MKTG_URLS={'ROOT': None}, ) class TestCourseEnrollmentEmailTask(ModuleStoreTestCase): """ diff --git a/lms/djangoapps/branding/tests/test_api.py b/lms/djangoapps/branding/tests/test_api.py index 71819a98d940..78272d66dfbc 100644 --- a/lms/djangoapps/branding/tests/test_api.py +++ b/lms/djangoapps/branding/tests/test_api.py @@ -46,12 +46,20 @@ class TestFooter(TestCase): """Test retrieving the footer. """ maxDiff = None - @mock.patch.dict('django.conf.settings.FEATURES', {'ENABLE_MKTG_SITE': True}) - @mock.patch.dict('django.conf.settings.MKTG_URLS', { - "ROOT": "https://edx.org", - "ENTERPRISE": "/enterprise" + @override_settings( + MKTG_URLS={ + "ROOT": "https://edx.org", + "ENTERPRISE": "/enterprise" + }, + ENTERPRISE_MARKETING_FOOTER_QUERY_PARAMS={}, + PLATFORM_NAME='\xe9dX' + ) + @with_site_configuration(configuration={ + 'MKTG_URLS': { + "ROOT": "https://edx.org", + "ENTERPRISE": "/enterprise" + } }) - @override_settings(ENTERPRISE_MARKETING_FOOTER_QUERY_PARAMS={}, PLATFORM_NAME='\xe9dX') def test_footer_business_links_no_marketing_query_params(self): """ Enterprise marketing page values returned should be a concatenation of ROOT and @@ -62,27 +70,28 @@ def test_footer_business_links_no_marketing_query_params(self): business_links = _footer_business_links() assert business_links[0]['url'] == 'https://edx.org/enterprise' - @mock.patch.dict('django.conf.settings.FEATURES', {'ENABLE_MKTG_SITE': True}) - @mock.patch.dict('django.conf.settings.MKTG_URLS', { - "ROOT": "https://edx.org", - "ABOUT": "/about-us", - "NEWS": "/news-announcements", - "CONTACT": "/contact", - "CAREERS": '/careers', - "FAQ": "/student-faq", - "BLOG": "/edx-blog", - "DONATE": "/donate", - "JOBS": "/jobs", - "SITE_MAP": "/sitemap", - "TRADEMARKS": "/trademarks", - "TOS_AND_HONOR": "/edx-terms-service", - "PRIVACY": "/edx-privacy-policy", - "ACCESSIBILITY": "/accessibility", - "AFFILIATES": '/affiliate-program', - "MEDIA_KIT": "/media-kit", - "ENTERPRISE": "https://business.edx.org" - }) - @override_settings(PLATFORM_NAME='\xe9dX') + @override_settings( + MKTG_URLS={ + "ROOT": "https://edx.org", + "ABOUT": "/about-us", + "NEWS": "/news-announcements", + "CONTACT": "/contact", + "CAREERS": '/careers', + "FAQ": "/student-faq", + "BLOG": "/edx-blog", + "DONATE": "/donate", + "JOBS": "/jobs", + "SITE_MAP": "/sitemap", + "TRADEMARKS": "/trademarks", + "TOS_AND_HONOR": "/edx-terms-service", + "PRIVACY": "/edx-privacy-policy", + "ACCESSIBILITY": "/accessibility", + "AFFILIATES": '/affiliate-program', + "MEDIA_KIT": "/media-kit", + "ENTERPRISE": "https://business.edx.org" + }, + PLATFORM_NAME='\xe9dX' + ) def test_get_footer(self): actual_footer = get_footer(is_secure=True) business_url = 'https://business.edx.org/?utm_campaign=edX.org+Referral&utm_source=edX.org&utm_medium=Footer' diff --git a/lms/djangoapps/learner_home/test_views.py b/lms/djangoapps/learner_home/test_views.py index 8722629371cc..aa32572321ae 100644 --- a/lms/djangoapps/learner_home/test_views.py +++ b/lms/djangoapps/learner_home/test_views.py @@ -91,7 +91,7 @@ def test_happy_path(self, mock_marketing_link): @ddt.data( (True, f'{settings.CATALOG_MICROFRONTEND_URL}/courses'), - (False, '/courses'), + (False, 'courses'), ) @ddt.unpack def test_link_with_new_catalog_page(self, catalog_mfe_enabled, expected_catalog_link): diff --git a/lms/djangoapps/static_template_view/urls.py b/lms/djangoapps/static_template_view/urls.py index 231913fbfcc1..4f41aea90a36 100644 --- a/lms/djangoapps/static_template_view/urls.py +++ b/lms/djangoapps/static_template_view/urls.py @@ -26,7 +26,7 @@ # Only enable URLs for those marketing links actually enabled in the # settings. Disable URLs by marking them as None. -for key, value in settings.MKTG_URL_LINK_MAP.items(): +for key, value in settings.MKTG_URLS.items(): # Skip disabled URLs if value is None: continue diff --git a/lms/envs/common.py b/lms/envs/common.py index 3dde7156b93e..a554257ee48b 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -2397,7 +2397,7 @@ ######################### MARKETING SITE ############################### -MKTG_URL_LINK_MAP = { +MKTG_URLS = { 'ABOUT': 'about', 'CONTACT': 'contact', 'FAQ': 'help', diff --git a/lms/envs/minimal.yml b/lms/envs/minimal.yml index f4f9bd8a8a8a..e01c3a6433cd 100644 --- a/lms/envs/minimal.yml +++ b/lms/envs/minimal.yml @@ -15,7 +15,6 @@ TRACKING_BACKENDS: {} EVENT_TRACKING_BACKENDS: {} JWT_AUTH: {} CELERY_QUEUES: {} -MKTG_URL_LINK_MAP: {} MKTG_URL_OVERRIDES: {} REST_FRAMEWORK: {} diff --git a/lms/envs/mock.yml b/lms/envs/mock.yml index 611b35d63176..33014c178192 100644 --- a/lms/envs/mock.yml +++ b/lms/envs/mock.yml @@ -831,7 +831,6 @@ MKTG_URLS: TOS_AND_HONOR: hello TRADEMARKS: hello WHAT_IS_VERIFIED_CERT: hello -MKTG_URL_LINK_MAP: {} MKTG_URL_OVERRIDES: course-v1:Org+Course+Run: hello MOBILE_STORE_URLS: diff --git a/lms/envs/production.py b/lms/envs/production.py index aeccaf0c0fbf..047932ffb263 100644 --- a/lms/envs/production.py +++ b/lms/envs/production.py @@ -79,7 +79,6 @@ def get_env_setting(setting): 'EVENT_TRACKING_BACKENDS', 'JWT_AUTH', 'CELERY_QUEUES', - 'MKTG_URL_LINK_MAP', 'REST_FRAMEWORK', 'EVENT_BUS_PRODUCER_CONFIG', 'DEFAULT_FILE_STORAGE', @@ -177,8 +176,6 @@ def get_env_setting(setting): } ) -MKTG_URL_LINK_MAP.update(_YAML_TOKENS.get('MKTG_URL_LINK_MAP', {})) - # Timezone overrides TIME_ZONE = CELERY_TIMEZONE diff --git a/lms/envs/test.py b/lms/envs/test.py index 218a7e8461b8..28c5bbf470c5 100644 --- a/lms/envs/test.py +++ b/lms/envs/test.py @@ -272,7 +272,7 @@ ######################### MARKETING SITE ############################### -MKTG_URL_LINK_MAP = { +MKTG_URLS = { 'ABOUT': 'about', 'CONTACT': 'contact', 'HELP_CENTER': 'help-center', diff --git a/openedx/core/djangoapps/schedules/tests/test_resolvers.py b/openedx/core/djangoapps/schedules/tests/test_resolvers.py index 2c37608e5cff..69c525dfe921 100644 --- a/openedx/core/djangoapps/schedules/tests/test_resolvers.py +++ b/openedx/core/djangoapps/schedules/tests/test_resolvers.py @@ -184,7 +184,7 @@ def test_schedule_context(self): 'course_name': self.course.display_name, 'course_url': f'http://learning-mfe/course/{self.course.id}/home', 'dashboard_url': '/dashboard', - 'homepage_url': '/', + 'homepage_url': 'root', 'mobile_store_logo_urls': {'apple': apple_logo_url, 'google': google_logo_url}, 'mobile_store_urls': {'apple': apple_store_url, @@ -299,7 +299,7 @@ def test_schedule_context(self): 'course_name': self.course.display_name, 'course_url': f'http://learning-mfe/course/{self.course.id}/home', 'dashboard_url': '/dashboard', - 'homepage_url': '/', + 'homepage_url': 'root', 'mobile_store_logo_urls': {'apple': apple_logo_url, 'google': google_logo_url}, 'mobile_store_urls': {'apple': apple_store_url, diff --git a/openedx/core/djangoapps/user_authn/views/tests/test_register.py b/openedx/core/djangoapps/user_authn/views/tests/test_register.py index 54d42efa55c0..daea9f536737 100644 --- a/openedx/core/djangoapps/user_authn/views/tests/test_register.py +++ b/openedx/core/djangoapps/user_authn/views/tests/test_register.py @@ -561,7 +561,7 @@ class RegistrationViewTestV1( "default": False } ] - link_template = "{link_label}" + link_template = "{link_label}" @classmethod def setUpClass(cls): @@ -1153,7 +1153,6 @@ def test_registration_form_confirm_email(self): @override_settings( MKTG_URLS={"ROOT": "https://www.test.com/", "HONOR": "honor"}, ) - @mock.patch.dict(settings.FEATURES, {"ENABLE_MKTG_SITE": True}) def test_registration_honor_code_mktg_site_enabled(self): link_template = "{link_label}" link_template2 = "{link_label}" @@ -1185,10 +1184,9 @@ def test_registration_honor_code_mktg_site_enabled(self): } ) - @override_settings(MKTG_URLS_LINK_MAP={"HONOR": "honor"}) - @mock.patch.dict(settings.FEATURES, {"ENABLE_MKTG_SITE": False}) + @override_settings(MKTG_URLS={"HONOR": "honor", "PRIVACY": "privacy"}) def test_registration_honor_code_mktg_site_disabled(self): - link_template = "{link_label}" + link_template = "{link_label}" link_label = "Terms of Service and Honor Code" link_label2 = "Privacy Policy" self._assert_reg_field( @@ -1222,7 +1220,6 @@ def test_registration_honor_code_mktg_site_disabled(self): "HONOR": "honor", "TOS": "tos", }) - @mock.patch.dict(settings.FEATURES, {"ENABLE_MKTG_SITE": True}) def test_registration_separate_terms_of_service_mktg_site_enabled(self): # Honor code field should say ONLY honor code, # not "terms of service and honor code" @@ -1271,8 +1268,7 @@ def test_registration_separate_terms_of_service_mktg_site_enabled(self): } ) - @override_settings(MKTG_URLS_LINK_MAP={"HONOR": "honor", "TOS": "tos"}) - @mock.patch.dict(settings.FEATURES, {"ENABLE_MKTG_SITE": False}) + @override_settings(MKTG_URLS={"HONOR": "honor", "TOS": "tos"}) def test_registration_separate_terms_of_service_mktg_site_disabled(self): # Honor code field should say ONLY honor code, # not "terms of service and honor code" @@ -1298,7 +1294,7 @@ def test_registration_separate_terms_of_service_mktg_site_disabled(self): link_label = 'Terms of Service' # Terms of service field should also be present - link_template = "{link_label}" + link_template = "{link_label}" self._assert_reg_field( {"honor_code": "required", "terms_of_service": "required"}, { diff --git a/themes/stanford-style/lms/templates/register-sidebar.html b/themes/stanford-style/lms/templates/register-sidebar.html index 97c2e35881cf..c3938d3f1386 100644 --- a/themes/stanford-style/lms/templates/register-sidebar.html +++ b/themes/stanford-style/lms/templates/register-sidebar.html @@ -27,7 +27,7 @@
${_("You will receive an activation email. You must click on the activation link to complete the process. Don't see the email? Check your spam folder and mark emails from class.stanford.edu as 'not spam', since you'll want to be able to receive email from your courses.")}
-% if settings.MKTG_URL_LINK_MAP.get('FAQ'): +% if settings.MKTG_URLS.get('FAQ'):${_("Need help in registering with {platform_name}?").format(platform_name=platform_name)}