From 77f605b30a1e32a142a2dfa16001a0a4c2409147 Mon Sep 17 00:00:00 2001 From: Clinton Blackburn Date: Mon, 6 Jun 2016 13:54:45 -0400 Subject: [PATCH] Corrected usage of the title block for the main_django template ECOM-4610 --- .../context_processors.py | 11 ++++++++++ .../tests/test_context_processors.py | 21 +++++++++++++++++++ lms/envs/common.py | 1 + lms/templates/main_django.html | 2 +- lms/templates/wiki/base.html | 4 +++- 5 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 common/djangoapps/microsite_configuration/context_processors.py create mode 100644 common/djangoapps/microsite_configuration/tests/test_context_processors.py 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 %}{% platform_name %}{% endblock %} + {% block title %}{{ platform_name }}{% endblock %} diff --git a/lms/templates/wiki/base.html b/lms/templates/wiki/base.html index fe6112a369..f19e6c20b8 100644 --- a/lms/templates/wiki/base.html +++ b/lms/templates/wiki/base.html @@ -2,7 +2,9 @@ {% with online_help_token="wiki" %} {% load pipeline %}{% load sekizai_tags i18n microsite %}{% load url from future %}{% load staticfiles %} -{% block title %}{% block pagetitle %}{% endblock %} | {% trans "Wiki" %} | {% platform_name %}{% endblock %} +{% block title %} + {% block pagetitle %}{% endblock %} | {% trans "Wiki" %} | {% platform_name %} +{% endblock %} {% block bodyclass %}view-in-course view-wiki{% endblock %}