Commit 3f2c4c73 by Jason Bau

changes to make sneakpeek work with new tabs

parent 280c3ebd
...@@ -691,14 +691,18 @@ class CourseTabList(List): ...@@ -691,14 +691,18 @@ class CourseTabList(List):
return tab return tab
return None return None
SNEAKPEEK_TAB_TYPES = [CoursewareTab, CourseInfoTab, StaticTab, SyllabusTab]
@staticmethod @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 Generator method for iterating through all tabs that can be displayed for the given course and
the given user with the provided access settings. the given user with the provided access settings.
""" """
for tab in course.tabs: 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): if isinstance(tab, TextbookTabsBase):
for book in tab.books(course): for book in tab.books(course):
yield book yield book
......
...@@ -14,6 +14,7 @@ def url_class(is_active): ...@@ -14,6 +14,7 @@ def url_class(is_active):
%> %>
<%! from xmodule.tabs import CourseTabList %> <%! from xmodule.tabs import CourseTabList %>
<%! from courseware.access import has_access %> <%! from courseware.access import has_access %>
<%! from student.models import UserProfile %>
<%! from django.conf import settings %> <%! from django.conf import settings %>
<%! from django.core.urlresolvers import reverse %> <%! from django.core.urlresolvers import reverse %>
<%! from django.utils.translation import ugettext as _ %> <%! from django.utils.translation import ugettext as _ %>
...@@ -38,7 +39,7 @@ def url_class(is_active): ...@@ -38,7 +39,7 @@ def url_class(is_active):
<nav class="${active_page} course-material"> <nav class="${active_page} course-material">
<div class="inner-wrapper"> <div class="inner-wrapper">
<ol class="course-tabs"> <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_is_active = (tab.tab_id == active_page)
tab_image = notification_image_for_tab(tab, user, course) 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