Commit 3f2c4c73 by Jason Bau

changes to make sneakpeek work with new tabs

parent 280c3ebd
......@@ -691,14 +691,18 @@ class CourseTabList(List):
return tab
return None
SNEAKPEEK_TAB_TYPES = [CoursewareTab, CourseInfoTab, StaticTab, SyllabusTab]
@staticmethod
def iterate_displayable(course, settings, is_user_authenticated=True, is_user_staff=True, include_instructor_tab=False):
def iterate_displayable(course, settings, is_user_authenticated=True, is_user_staff=True, is_user_sneakpeek=False, include_instructor_tab=False):
"""
Generator method for iterating through all tabs that can be displayed for the given course and
the given user with the provided access settings.
"""
for tab in course.tabs:
if tab.can_display(course, settings, is_user_authenticated, is_user_staff):
if (tab.can_display(course, settings, is_user_authenticated, is_user_staff) and
(not is_user_sneakpeek or
any([isinstance(tab, t) for t in CourseTabList.SNEAKPEEK_TAB_TYPES]))):
if isinstance(tab, TextbookTabsBase):
for book in tab.books(course):
yield book
......
......@@ -14,6 +14,7 @@ def url_class(is_active):
%>
<%! from xmodule.tabs import CourseTabList %>
<%! from courseware.access import has_access %>
<%! from student.models import UserProfile %>
<%! from django.conf import settings %>
<%! from django.core.urlresolvers import reverse %>
<%! from django.utils.translation import ugettext as _ %>
......@@ -38,7 +39,7 @@ def url_class(is_active):
<nav class="${active_page} course-material">
<div class="inner-wrapper">
<ol class="course-tabs">
% for tab in CourseTabList.iterate_displayable(course, settings, user.is_authenticated(), has_access(user, course, 'staff'), include_instructor_tab=True):
% for tab in CourseTabList.iterate_displayable(course, settings, user.is_authenticated(), has_access(user, course, 'staff'), not UserProfile.has_registered(user), include_instructor_tab=True):
<%
tab_is_active = (tab.tab_id == active_page)
tab_image = notification_image_for_tab(tab, user, course)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment