Commit 10361a4a by Calen Pennington

WIP to update the navigation bar when adding a new module

parent c5e225c4
......@@ -18,6 +18,7 @@ from mitxmako.shortcuts import render_to_response, render_to_string
from xmodule.modulestore.django import modulestore
from xmodule_modifiers import replace_static_urls, wrap_xmodule
from xmodule.exceptions import NotFoundError
from xmodule.course_module import CourseDescriptor
from functools import partial
from itertools import groupby
from operator import attrgetter
......@@ -74,20 +75,35 @@ def has_access(user, location):
@login_required
@ensure_csrf_cookie
def course_index(request, org, course, name):
def course_index(request, course_id):
"""
Display an editable course overview.
org, course, name: Attributes of the Location for the item to edit
"""
location = ['i4x', org, course, 'course', name]
location = CourseDescriptor.id_to_location(course_id)
if not has_access(request.user, location):
raise Http404 # TODO (vshnayder): better error
return render_to_response('course_index.html', {'course_id': course_id})
@login_required
def navigation(request, course_id):
"""
Render the course navigation
org, course, name: Attributes of the Location for the course to edit
"""
location = CourseDescriptor.id_to_location(course_id)
if not has_access(request.user, location):
raise Http404 # TODO (vshnayder): better error
# TODO (cpennington): These need to be read in from the active user
course = modulestore().get_item(location)
weeks = course.get_children()
return render_to_response('course_index.html', {'weeks': weeks})
return render_to_response('widgets/navigation.html', {'weeks': weeks})
@login_required
......
......@@ -4,6 +4,7 @@ class CMS.Views.Course extends Backbone.View
CMS.on('content.hide', @hideContent)
render: ->
@$el.find('.navigation').load("/#{@$el.data('course-id')}/navigation")
@$('#weeks > li').each (index, week) =>
new CMS.Views.Week(el: week, height: @maxWeekHeight()).render()
return @
......
......@@ -8,6 +8,7 @@ class CMS.Views.Week extends Backbone.View
CMS.on('content.hide', @setHeight)
render: ->
@$el.load 'navigation'
@setHeight()
@$('.editable').inlineEdit()
@$('.editable-textarea').inlineEdit(control: 'textarea')
......
......@@ -3,12 +3,10 @@
<%include file="widgets/header.html"/>
<%block name="content">
<section class="main-container">
<section class="main-container" data-course-id="${course_id}">
<%include file="widgets/navigation.html"/>
<section class="main-content">
</section>
<section class="navigation"></section>
<section class="main-content"></section>
</section>
</%block>
......@@ -13,7 +13,9 @@ urlpatterns = ('',
url(r'^edit_item$', 'contentstore.views.edit_item', name='edit_item'),
url(r'^save_item$', 'contentstore.views.save_item', name='save_item'),
url(r'^clone_item$', 'contentstore.views.clone_item', name='clone_item'),
url(r'^(?P<org>[^/]+)/(?P<course>[^/]+)/course/(?P<name>[^/]+)$',
url(r'^(?P<course_id>[^/]+/[^/]+/[^/]+)/navigation$',
'contentstore.views.navigation', name='navigation'),
url(r'^(?P<course_id>[^/]+/[^/]+/[^/]+)$',
'contentstore.views.course_index', name='course_index'),
url(r'^github_service_hook$', 'github_sync.views.github_post_receive'),
url(r'^preview/modx/(?P<preview_id>[^/]*)/(?P<location>.*?)/(?P<dispatch>[^/]*)$',
......
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