diff --git a/common/djangoapps/microsite_configuration/context_processors.py b/common/djangoapps/microsite_configuration/context_processors.py new file mode 100644 index 0000000000..f1d91598d3 --- /dev/null +++ b/common/djangoapps/microsite_configuration/context_processors.py @@ -0,0 +1,11 @@ +""" Django template ontext processors. """ + +from django.conf import settings + +from microsite_configuration import microsite + + +def microsite_context(request): # pylint: disable=unused-argument + return { + 'platform_name': microsite.get_value('platform_name', settings.PLATFORM_NAME) + } diff --git a/common/djangoapps/microsite_configuration/tests/test_context_processors.py b/common/djangoapps/microsite_configuration/tests/test_context_processors.py new file mode 100644 index 0000000000..af3e1d8b2d --- /dev/null +++ b/common/djangoapps/microsite_configuration/tests/test_context_processors.py @@ -0,0 +1,21 @@ +""" Tests for Django template context processors. """ +from django.test import TestCase +from django.test.client import RequestFactory +from django.test.utils import override_settings + +from microsite_configuration.context_processors import microsite_context + +PLATFORM_NAME = 'Test Platform' + + +@override_settings(PLATFORM_NAME=PLATFORM_NAME) +class MicrositeContextProcessorTests(TestCase): + """ Tests for the microsite context processor. """ + + def setUp(self): + request = RequestFactory().get('/') + self.context = microsite_context(request) + + def test_platform_name(self): + """ Verify the context includes the platform name. """ + self.assertEqual(self.context['platform_name'], PLATFORM_NAME) diff --git a/lms/envs/common.py b/lms/envs/common.py index 01d86d119f..8f1588f1ce 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -499,6 +499,7 @@ TEMPLATES = [ 'django.template.context_processors.i18n', 'django.contrib.auth.context_processors.auth', # this is required for admin 'django.template.context_processors.csrf', + 'microsite_configuration.context_processors.microsite_context', # Added for django-wiki 'django.template.context_processors.media', diff --git a/lms/templates/main_django.html b/lms/templates/main_django.html index 932ecdf3ae..b2dd8e6672 100644 --- a/lms/templates/main_django.html +++ b/lms/templates/main_django.html @@ -4,7 +4,7 @@
- {% block title %}