Commit e247239b by bridger

Merge pull request #231 from MITx/dormsbee/no_org_fix

Keep courses and front page from erroring when we're missing an org in data
parents 739b9818 17263dcd
......@@ -8,6 +8,7 @@ import uuid
import feedparser
import urllib
import itertools
from collections import defaultdict
from django.conf import settings
from django.contrib.auth import logout, authenticate, login
......@@ -72,9 +73,8 @@ def index(request):
entry.image = soup.img['src'] if soup.img else None
courses = modulestore().get_courses()
universities = dict()
universities = defaultdict(list)
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('index.html', {'universities': universities, 'entries': entries})
......
from collections import defaultdict
import logging
import urllib
import itertools
......@@ -56,9 +57,8 @@ def format_url_params(params):
def courses(request):
# TODO: Clean up how 'error' is done.
courses = modulestore().get_courses()
universities = dict()
universities = defaultdict(list)
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 })
......
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