Commit 8a86f401 by Victor Shnayder

Make courseware index view more bulletproof

parent 9c67005e
...@@ -184,6 +184,7 @@ def index(request, course_id, chapter=None, section=None, ...@@ -184,6 +184,7 @@ def index(request, course_id, chapter=None, section=None,
chapter = clean(chapter) chapter = clean(chapter)
section = clean(section) section = clean(section)
try:
context = { context = {
'csrf': csrf(request)['csrf_token'], 'csrf': csrf(request)['csrf_token'],
'accordion': render_accordion(request, course, chapter, section), 'accordion': render_accordion(request, course, chapter, section),
...@@ -212,6 +213,25 @@ def index(request, course_id, chapter=None, section=None, ...@@ -212,6 +213,25 @@ def index(request, course_id, chapter=None, section=None,
result = render_to_response('courseware.html', context) result = render_to_response('courseware.html', context)
except:
# In production, don't want to let a 500 out for any reason
if settings.DEBUG:
raise
else:
log.exception("Error in index view: user={user}, course={course},"
" chapter={chapter} section={section}"
"position={position}".format(
user=request.user,
course=course,
chapter=chapter,
section=section,
position=position
))
try:
result = render_to_response('courseware-error.html', {})
except:
result = HttpResponse("There was an unrecoverable error")
return result return result
@ensure_csrf_cookie @ensure_csrf_cookie
......
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