Merge pull request #11076 from CredoReference/render-lms-main-navigation-with-template
Render lms main navigation (tabs) with template
This commit is contained in:
@@ -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)
|
||||
%>
|
||||
<li>
|
||||
<a href="${tab.link_func(course, reverse) | h}" class="${tab_class}">
|
||||
Test Microsite Tab: ${_(tab.name) | h}
|
||||
% if tab_is_active:
|
||||
<span class="sr">, current location</span>
|
||||
%endif
|
||||
% if tab_image:
|
||||
## Translators: 'needs attention' is an alternative string for the
|
||||
## notification image that indicates the tab "needs attention".
|
||||
<img src="${tab_image}" alt="${_('needs attention')}" />
|
||||
%endif
|
||||
</a>
|
||||
</li>
|
||||
% endfor
|
||||
@@ -199,6 +199,21 @@ class TestMicrosites(SharedModuleStoreTestCase, LoginEnrollmentTestCase):
|
||||
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):
|
||||
"""
|
||||
|
||||
@@ -15,11 +15,6 @@ if active_page is None and active_page_context is not UNDEFINED:
|
||||
# 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 @@ include_special_exams = settings.FEATURES.get('ENABLE_SPECIAL_EXAMS', False) and
|
||||
% if disable_tabs is UNDEFINED or not disable_tabs:
|
||||
<nav class="${active_page} wrapper-course-material" aria-label="${_('Course Material')}">
|
||||
<div class="course-material">
|
||||
<ol class="course-tabs">
|
||||
% for tab in get_course_tab_list(request, course):
|
||||
<%
|
||||
tab_is_active = (tab.tab_id == active_page) or (tab.tab_id == default_tab)
|
||||
%>
|
||||
<li>
|
||||
<a href="${tab.link_func(course, reverse) | h}" class="${url_class(tab_is_active)}">
|
||||
${_(tab.name) | h}
|
||||
% if tab_is_active:
|
||||
<span class="sr">, current location</span>
|
||||
%endif
|
||||
% if tab_image:
|
||||
## Translators: 'needs attention' is an alternative string for the
|
||||
## notification image that indicates the tab "needs attention".
|
||||
<img src="${tab_image}" alt="${_('needs attention')}" />
|
||||
%endif
|
||||
</a>
|
||||
</li>
|
||||
% endfor
|
||||
<%
|
||||
tab_list = get_course_tab_list(request, course)
|
||||
tabs_tmpl = static.get_template_path('/courseware/tabs.html')
|
||||
%>
|
||||
<ol class="course-tabs">
|
||||
<%include file="${tabs_tmpl}" args="tab_list=tab_list,active_page=active_page,default_tab=default_tab,tab_image=tab_image" />
|
||||
<%block name="extratabs" />
|
||||
</ol>
|
||||
</ol>
|
||||
</div>
|
||||
</nav>
|
||||
%endif
|
||||
|
||||
33
lms/templates/courseware/tabs.html
Normal file
33
lms/templates/courseware/tabs.html
Normal file
@@ -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)
|
||||
%>
|
||||
<li>
|
||||
<a href="${tab.link_func(course, reverse) | h}" class="${tab_class}">
|
||||
${_(tab.name) | h}
|
||||
% if tab_is_active:
|
||||
<span class="sr">, current location</span>
|
||||
%endif
|
||||
% if tab_image:
|
||||
## Translators: 'needs attention' is an alternative string for the
|
||||
## notification image that indicates the tab "needs attention".
|
||||
<img src="${tab_image}" alt="${_('needs attention')}" />
|
||||
%endif
|
||||
</a>
|
||||
</li>
|
||||
% endfor
|
||||
Reference in New Issue
Block a user