Commit 2d71a716 by David Ormsbee

Merge pull request #219 from MITx/mm-course-page-ordering

Order courses according to univesity on courses page.
parents 1c88c5a1 1f595ef4
import logging import logging
import urllib import urllib
import itertools
from django.conf import settings from django.conf import settings
from django.core.context_processors import csrf from django.core.context_processors import csrf
...@@ -54,8 +55,13 @@ def format_url_params(params): ...@@ -54,8 +55,13 @@ def format_url_params(params):
@cache_if_anonymous @cache_if_anonymous
def courses(request): def courses(request):
# TODO: Clean up how 'error' is done. # TODO: Clean up how 'error' is done.
context = {'courses': modulestore().get_courses()} courses = modulestore().get_courses()
return render_to_response("courses.html", context) universities = dict()
for university, group in itertools.groupby(courses, lambda course: course.org):
universities.setdefault(university, [])
[universities[university].append(course) for course in group]
return render_to_response("courses.html", { 'universities': universities })
@cache_control(no_cache=True, no_store=True, must_revalidate=True) @cache_control(no_cache=True, no_store=True, must_revalidate=True)
def gradebook(request, course_id): def gradebook(request, course_id):
......
...@@ -18,9 +18,21 @@ ...@@ -18,9 +18,21 @@
## I'm removing this for now since we aren't using it for the fall. ## I'm removing this for now since we aren't using it for the fall.
## <%include file="course_filter.html" /> ## <%include file="course_filter.html" />
<section class="courses"> <section class="courses">
%for course in courses: <section class='university-column'>
%for course in universities['MITx']:
<%include file="course.html" args="course=course" /> <%include file="course.html" args="course=course" />
%endfor %endfor
</section> </section>
<section class='university-column'>
%for course in universities['HarvardX']:
<%include file="course.html" args="course=course" />
%endfor
</section>
<section class='university-column'>
%for course in universities['BerkeleyX']:
<%include file="course.html" args="course=course" />
%endfor
</section>
</section>
</section> </section>
</section> </section>
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