diff --git a/common/test/test_microsites/test_microsite/templates/courseware/tabs.html b/common/test/test_microsites/test_microsite/templates/courseware/tabs.html new file mode 100644 index 000000000000..2d70a465d8be --- /dev/null +++ b/common/test/test_microsites/test_microsite/templates/courseware/tabs.html @@ -0,0 +1,33 @@ +## mako +<%namespace name='static' file='/static_content.html'/> +<%! + from django.utils.translation import ugettext as _ + from django.core.urlresolvers import reverse + %> +<%page args="tab_list, active_page, default_tab, tab_image" /> + +<% +def url_class(is_active): + if is_active: + return "active" + return "" +%> +% for tab in tab_list: + <% + tab_is_active = tab.tab_id in (active_page, default_tab) + tab_class = url_class(tab_is_active) + %> +
  • + + Test Microsite Tab: ${_(tab.name) | h} + % if tab_is_active: + , current location + %endif + % if tab_image: + ## Translators: 'needs attention' is an alternative string for the + ## notification image that indicates the tab "needs attention". + ${_('needs attention')} + %endif + +
  • +% endfor diff --git a/lms/djangoapps/courseware/tests/test_microsites.py b/lms/djangoapps/courseware/tests/test_microsites.py index bd30d73ffa11..b8c64bf8d2c0 100644 --- a/lms/djangoapps/courseware/tests/test_microsites.py +++ b/lms/djangoapps/courseware/tests/test_microsites.py @@ -199,6 +199,21 @@ def test_microsite_course_enrollment(self): self.assertNotContains(resp, 'Robot_Super_Course') self.assertContains(resp, 'Robot_Course_Outside_Microsite') + def test_microsite_course_custom_tabs(self): + """ + Enroll user in a course scoped in a Microsite and make sure that + template with tabs is overridden + """ + self.setup_users() + + email, password = self.STUDENT_INFO[1] + self.login(email, password) + self.enroll(self.course, True) + + resp = self.client.get(reverse('courseware', args=[unicode(self.course.id)]), + HTTP_HOST=settings.MICROSITE_TEST_HOSTNAME) + self.assertContains(resp, 'Test Microsite Tab:') + @override_settings(SITE_NAME=settings.MICROSITE_TEST_HOSTNAME) def test_visible_about_page_settings(self): """ diff --git a/lms/templates/courseware/course_navigation.html b/lms/templates/courseware/course_navigation.html index d4a46efc8ddc..22526b5ccda5 100644 --- a/lms/templates/courseware/course_navigation.html +++ b/lms/templates/courseware/course_navigation.html @@ -15,11 +15,6 @@ # If active_page is not passed in as an argument, it may be in the context as active_page_context active_page = active_page_context -def url_class(is_active): - if is_active: - return "active" - return "" - def selected(is_selected): return "selected" if is_selected else "" @@ -83,27 +78,14 @@ % if disable_tabs is UNDEFINED or not disable_tabs: %endif diff --git a/lms/templates/courseware/tabs.html b/lms/templates/courseware/tabs.html new file mode 100644 index 000000000000..0959355302f4 --- /dev/null +++ b/lms/templates/courseware/tabs.html @@ -0,0 +1,33 @@ +## mako +<%namespace name='static' file='/static_content.html'/> +<%! + from django.utils.translation import ugettext as _ + from django.core.urlresolvers import reverse + %> +<%page args="tab_list, active_page, default_tab, tab_image" /> + +<% +def url_class(is_active): + if is_active: + return "active" + return "" +%> +% for tab in tab_list: + <% + tab_is_active = tab.tab_id in (active_page, default_tab) + tab_class = url_class(tab_is_active) + %> +
  • + + ${_(tab.name) | h} + % if tab_is_active: + , current location + %endif + % if tab_image: + ## Translators: 'needs attention' is an alternative string for the + ## notification image that indicates the tab "needs attention". + ${_('needs attention')} + %endif + +
  • +% endfor