Commit 5034c038 by David Ormsbee Committed by Matthew Mongeau

Add info page support with multiple courses

parent 069d649c
...@@ -57,9 +57,23 @@ def send_feedback(request): ...@@ -57,9 +57,23 @@ def send_feedback(request):
) )
return HttpResponse(json.dumps({'success':True})) return HttpResponse(json.dumps({'success':True}))
def info(request): def info(request, course_id=None):
''' Info page (link from main header) ''' ''' 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/ # From http://djangosnippets.org/snippets/1042/
def parse_accept_header(accept): def parse_accept_header(accept):
......
...@@ -29,7 +29,7 @@ class Course(namedtuple('Course', _FIELDS)): ...@@ -29,7 +29,7 @@ class Course(namedtuple('Course', _FIELDS)):
""" """
@property @property
def id(self): 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 @classmethod
def load_from_path(cls, course_path): def load_from_path(cls, course_path):
......
...@@ -65,8 +65,9 @@ sys.path.append(COMMON_ROOT / 'djangoapps') ...@@ -65,8 +65,9 @@ sys.path.append(COMMON_ROOT / 'djangoapps')
sys.path.append(COMMON_ROOT / 'lib') sys.path.append(COMMON_ROOT / 'lib')
######### EDX dormsbee/portal changes ################# ######### 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 = load_courses(ENV_ROOT / "data")
COURSES_BY_ID = create_lookup_table(COURSES)
####################################################### #######################################################
################################## MITXWEB ##################################### ################################## MITXWEB #####################################
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
<hgroup> <hgroup>
<h2>${course.title}</h2> <h2>${course.title}</h2>
<p>${",".join(course.instructors)} &mdash; ${course.institution}</p> <p>${",".join(course.instructors)} &mdash; ${course.institution}</p>
<p>${course.id}</p>
</hgroup> </hgroup>
<div class="edit">Register</div> <div class="edit">Register</div>
<section class="meta"> <section class="meta">
...@@ -22,5 +23,6 @@ ...@@ -22,5 +23,6 @@
</section> </section>
</section> </section>
</a> </a>
<p><a href="courses/${course.id}/info">Hackish temp link to courseware</a></p>
</article> </article>
%endfor %endfor
...@@ -7,17 +7,17 @@ ...@@ -7,17 +7,17 @@
<div class="info-wrapper"> <div class="info-wrapper">
% if user.is_authenticated(): % if user.is_authenticated():
<section class="updates"> <section class="updates">
<%include file="updates.html" /> ${updates}
</section> </section>
<section aria-label="Handout Navigation" class="handouts"> <section aria-label="Handout Navigation" class="handouts">
<%include file="handouts.html" /> ${handouts}
</section> </section>
% else: % else:
<section class="updates"> <section class="updates">
<%include file="guest_updates.html" /> ${guest_updates}
</section> </section>
<section aria-label="Handout Navigation" class="handouts"> <section aria-label="Handout Navigation" class="handouts">
<%include file="guest_handouts.html" /> ${guest_handouts}
</section> </section>
% endif % endif
</div> </div>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <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 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" /> <link rel="stylesheet" href="${static.url('js/jquery.treeview.css')}" type="text/css" media="all" />
......
## 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'/> <%namespace name='static' file='static_content.html'/>
<header class="app" aria-label="Global Navigation"> <header class="app" aria-label="Global Navigation">
<section class="wrapper"> <section class="wrapper">
......
...@@ -50,7 +50,6 @@ if settings.PERFSTATS: ...@@ -50,7 +50,6 @@ if settings.PERFSTATS:
if settings.COURSEWARE_ENABLED: if settings.COURSEWARE_ENABLED:
urlpatterns += ( urlpatterns += (
url(r'^courseware/$', 'courseware.views.index', name="courseware"), url(r'^courseware/$', 'courseware.views.index', name="courseware"),
url(r'^info$', 'util.views.info'),
url(r'^wiki/', include('simplewiki.urls')), url(r'^wiki/', include('simplewiki.urls')),
url(r'^masquerade/', include('masquerade.urls')), url(r'^masquerade/', include('masquerade.urls')),
url(r'^courseware/(?P<course>[^/]*)/(?P<chapter>[^/]*)/(?P<section>[^/]*)/(?P<position>[^/]*)$', 'courseware.views.index'), url(r'^courseware/(?P<course>[^/]*)/(?P<chapter>[^/]*)/(?P<section>[^/]*)/(?P<position>[^/]*)$', 'courseware.views.index'),
...@@ -76,6 +75,8 @@ if settings.COURSEWARE_ENABLED: ...@@ -76,6 +75,8 @@ if settings.COURSEWARE_ENABLED:
# Multicourse related: # Multicourse related:
url(r'^courses$', 'courseware.views.courses'), url(r'^courses$', 'courseware.views.courses'),
url(r'^courses/(?P<course_id>[^/]*)/info$', 'util.views.info'),
) )
if settings.ENABLE_MULTICOURSE: if settings.ENABLE_MULTICOURSE:
......
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