diff --git a/lms/djangoapps/courseware/tabs.py b/lms/djangoapps/courseware/tabs.py index 2dfa7afed3..c05a872382 100644 --- a/lms/djangoapps/courseware/tabs.py +++ b/lms/djangoapps/courseware/tabs.py @@ -235,12 +235,14 @@ def get_default_tabs(user, course, active_page): return tabs -def get_static_tab_by_slug(tabs, tab_slug): +def get_static_tab_by_slug(course, tab_slug): """ Look for a tab with type 'static_tab' and the specified 'tab_slug'. Returns the tab (a config dict), or None if not found. """ - for tab in tabs: + if course.tabs is None: + return None + for tab in course.tabs: # if the tab is misconfigured, this will blow up. The validation code should check... if tab['type'] == 'static_tab' and tab['url_slug'] == tab_slug: return tab diff --git a/lms/djangoapps/courseware/views.py b/lms/djangoapps/courseware/views.py index b03c1c932e..269977e458 100644 --- a/lms/djangoapps/courseware/views.py +++ b/lms/djangoapps/courseware/views.py @@ -353,7 +353,7 @@ def static_tab(request, course_id, tab_slug): """ course = get_course_with_access(request.user, course_id, 'load') - tab = tabs.get_static_tab_by_slug(course.tabs, tab_slug) + tab = tabs.get_static_tab_by_slug(course, tab_slug) if tab is None: raise Http404 diff --git a/lms/urls.py b/lms/urls.py index 6741113507..6b44cf9b43 100644 --- a/lms/urls.py +++ b/lms/urls.py @@ -97,6 +97,33 @@ urlpatterns = ('', if settings.PERFSTATS: urlpatterns += (url(r'^reprofile$','perfstats.views.end_profile'),) + + +# Multicourse wiki (Note: wiki urls must be above the courseware ones because of +# the custom tab catch-all) +if settings.WIKI_ENABLED: + from wiki.urls import get_pattern as wiki_pattern + from django_notify.urls import get_pattern as notify_pattern + + # Note that some of these urls are repeated in course_wiki.course_nav. Make sure to update + # them together. + urlpatterns += ( + # First we include views from course_wiki that we use to override the default views. + # They come first in the urlpatterns so they get resolved first + url('^wiki/create-root/$', 'course_wiki.views.root_create', name='root_create'), + + + url(r'^wiki/', include(wiki_pattern())), + url(r'^notify/', include(notify_pattern())), + + # These urls are for viewing the wiki in the context of a course. They should + # never be returned by a reverse() so they come after the other url patterns + url(r'^courses/(?P[^/]+/[^/]+/[^/]+)/course_wiki/?$', + 'course_wiki.views.course_wiki_redirect', name="course_wiki"), + url(r'^courses/(?:[^/]+/[^/]+/[^/]+)/wiki/', include(wiki_pattern())), + ) + + if settings.COURSEWARE_ENABLED: urlpatterns += ( # Hook django-masquerade, allowing staff to view site as other users @@ -180,29 +207,6 @@ if settings.COURSEWARE_ENABLED: include('django_comment_client.urls')) ) - # Multicourse wiki -if settings.WIKI_ENABLED: - from wiki.urls import get_pattern as wiki_pattern - from django_notify.urls import get_pattern as notify_pattern - - # Note that some of these urls are repeated in course_wiki.course_nav. Make sure to update - # them together. - urlpatterns += ( - # First we include views from course_wiki that we use to override the default views. - # They come first in the urlpatterns so they get resolved first - url('^wiki/create-root/$', 'course_wiki.views.root_create', name='root_create'), - - - url(r'^wiki/', include(wiki_pattern())), - url(r'^notify/', include(notify_pattern())), - - # These urls are for viewing the wiki in the context of a course. They should - # never be returned by a reverse() so they come after the other url patterns - url(r'^courses/(?P[^/]+/[^/]+/[^/]+)/course_wiki/?$', - 'course_wiki.views.course_wiki_redirect', name="course_wiki"), - url(r'^courses/(?:[^/]+/[^/]+/[^/]+)/wiki/', include(wiki_pattern())), - ) - if settings.QUICKEDIT: urlpatterns += (url(r'^quickedit/(?P[^/]*)$', 'dogfood.views.quickedit'),) urlpatterns += (url(r'^dogfood/(?P[^/]*)$', 'dogfood.views.df_capa_problem'),)