Add info page support with multiple courses
This commit is contained in:
committed by
Matthew Mongeau
parent
3859c2be19
commit
bc8c077379
@@ -57,9 +57,23 @@ def send_feedback(request):
|
||||
)
|
||||
return HttpResponse(json.dumps({'success':True}))
|
||||
|
||||
def info(request):
|
||||
def info(request, course_id=None):
|
||||
''' Info page (link from main header) '''
|
||||
return render_to_response("info.html", {})
|
||||
try:
|
||||
course = settings.COURSES_BY_ID[course_id]
|
||||
except KeyError:
|
||||
raise Http404("Course not found")
|
||||
|
||||
# We're bypassing the templating system for this part. We should cache
|
||||
# this.
|
||||
sections = ["updates", "handouts", "guest_updates", "guest_handouts"]
|
||||
sections_to_content = {}
|
||||
for section in sections:
|
||||
filename = section + ".html"
|
||||
with open(course.path / "info" / filename) as f:
|
||||
sections_to_content[section] = f.read()
|
||||
|
||||
return render_to_response("info.html", sections_to_content)
|
||||
|
||||
# From http://djangosnippets.org/snippets/1042/
|
||||
def parse_accept_header(accept):
|
||||
|
||||
@@ -29,7 +29,7 @@ class Course(namedtuple('Course', _FIELDS)):
|
||||
"""
|
||||
@property
|
||||
def id(self):
|
||||
return "{0.institution},{0.number},{0.run_id}".format(self)
|
||||
return "{0.institution},{0.number},{0.run_id}".format(self).replace(" ", "_")
|
||||
|
||||
@classmethod
|
||||
def load_from_path(cls, course_path):
|
||||
|
||||
@@ -65,8 +65,9 @@ sys.path.append(COMMON_ROOT / 'djangoapps')
|
||||
sys.path.append(COMMON_ROOT / 'lib')
|
||||
|
||||
######### EDX dormsbee/portal changes #################
|
||||
from courseware.courses import load_courses
|
||||
from courseware.courses import create_lookup_table, load_courses
|
||||
COURSES = load_courses(ENV_ROOT / "data")
|
||||
COURSES_BY_ID = create_lookup_table(COURSES)
|
||||
#######################################################
|
||||
|
||||
################################## MITXWEB #####################################
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
<hgroup>
|
||||
<h2>${course.title}</h2>
|
||||
<p>${",".join(course.instructors)} — ${course.institution}</p>
|
||||
<p>${course.id}</p>
|
||||
</hgroup>
|
||||
<div class="edit">Register</div>
|
||||
<section class="meta">
|
||||
@@ -22,5 +23,6 @@
|
||||
</section>
|
||||
</section>
|
||||
</a>
|
||||
<p><a href="courses/${course.id}/info">Hackish temp link to courseware</a></p>
|
||||
</article>
|
||||
%endfor
|
||||
|
||||
@@ -7,17 +7,17 @@
|
||||
<div class="info-wrapper">
|
||||
% if user.is_authenticated():
|
||||
<section class="updates">
|
||||
<%include file="updates.html" />
|
||||
${updates}
|
||||
</section>
|
||||
<section aria-label="Handout Navigation" class="handouts">
|
||||
<%include file="handouts.html" />
|
||||
${handouts}
|
||||
</section>
|
||||
% else:
|
||||
<section class="updates">
|
||||
<%include file="guest_updates.html" />
|
||||
${guest_updates}
|
||||
</section>
|
||||
<section aria-label="Handout Navigation" class="handouts">
|
||||
<%include file="guest_handouts.html" />
|
||||
${guest_handouts}
|
||||
</section>
|
||||
% endif
|
||||
</div>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<%block name="title"><title>MITx 6.002x</title></%block>
|
||||
<%block name="title"><title>edX</title></%block>
|
||||
|
||||
<link href='http://fonts.googleapis.com/css?family=Open+Sans:800italic,400,800' rel='stylesheet' type='text/css'>
|
||||
<link rel="stylesheet" href="${static.url('js/jquery.treeview.css')}" type="text/css" media="all" />
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
## TODO: Split this into two files, one for people who are authenticated, and
|
||||
## one for people who aren't. Assume a Course object is passed to the former,
|
||||
## instead of using settings.COURSE_TITLE
|
||||
<%namespace name='static' file='static_content.html'/>
|
||||
<header class="app" aria-label="Global Navigation">
|
||||
<section class="wrapper">
|
||||
|
||||
@@ -50,7 +50,6 @@ if settings.PERFSTATS:
|
||||
if settings.COURSEWARE_ENABLED:
|
||||
urlpatterns += (
|
||||
url(r'^courseware/$', 'courseware.views.index', name="courseware"),
|
||||
url(r'^info$', 'util.views.info'),
|
||||
url(r'^wiki/', include('simplewiki.urls')),
|
||||
url(r'^masquerade/', include('masquerade.urls')),
|
||||
url(r'^courseware/(?P<course>[^/]*)/(?P<chapter>[^/]*)/(?P<section>[^/]*)/(?P<position>[^/]*)$', 'courseware.views.index'),
|
||||
@@ -76,6 +75,8 @@ if settings.COURSEWARE_ENABLED:
|
||||
|
||||
# Multicourse related:
|
||||
url(r'^courses$', 'courseware.views.courses'),
|
||||
url(r'^courses/(?P<course_id>[^/]*)/info$', 'util.views.info'),
|
||||
|
||||
)
|
||||
|
||||
if settings.ENABLE_MULTICOURSE:
|
||||
|
||||
Reference in New Issue
Block a user