Display the appropriate type of error message depending on the type of the incoming request

This commit is contained in:
Calen Pennington
2012-05-16 13:45:00 -04:00
parent 698d0a167e
commit 69321b4497
5 changed files with 47 additions and 39 deletions

View File

@@ -227,7 +227,15 @@ def modx_dispatch(request, module=None, dispatch=None, id=None):
ajax_url = settings.MITX_ROOT_URL + '/modx/'+module+'/'+id+'/'
# Grab the XML corresponding to the request from course.xml
xml = content_parser.module_xml(request.user, module, 'id', id)
try:
xml = content_parser.module_xml(request.user, module, 'id', id)
except:
record_exception(log, "Unable to load module during ajax call")
if 'text/html' in request.accepted_types:
return render_to_response("module-error.html", {})
else:
response = HttpResponse(json.dumps({'success': "We're sorry, this module is temporarily unavailable. Our staff is working to fix it as soon as possible"}))
return response
# Create the module
system = I4xSystem(track_function = make_track_function(request),
@@ -242,8 +250,11 @@ def modx_dispatch(request, module=None, dispatch=None, id=None):
id,
state=oldstate)
except:
record_exception(log, "Unable to load module during ajax call")
response = HttpResponse(json.dumps({'success': "We're sorry, this module is temporarily unavailable. Our staff is working to fix it as soon as possible"}))
record_exception(log, "Unable to load module instance during ajax call")
if 'text/html' in request.accepted_types:
return render_to_response("module-error.html", {})
else:
response = HttpResponse(json.dumps({'success': "We're sorry, this module is temporarily unavailable. Our staff is working to fix it as soon as possible"}))
return response
# Let the module handle the AJAX