Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
ce6b3192
Commit
ce6b3192
authored
Jun 20, 2013
by
David Baumgold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added jsonable_server_error in common/util/views.py
parent
f9369b4f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
2 deletions
+17
-2
common/djangoapps/util/views.py
+17
-2
No files found.
common/djangoapps/util/views.py
View file @
ce6b3192
...
...
@@ -4,7 +4,10 @@ import sys
from
django.conf
import
settings
from
django.core.validators
import
ValidationError
,
validate_email
from
django.http
import
Http404
,
HttpResponse
,
HttpResponseNotAllowed
from
django.views.decorators.csrf
import
requires_csrf_token
from
django.views.defaults
import
server_error
from
django.http
import
(
Http404
,
HttpResponse
,
HttpResponseNotAllowed
,
HttpResponseServerError
)
from
dogapi
import
dog_stats_api
from
mitxmako.shortcuts
import
render_to_response
import
zendesk
...
...
@@ -16,6 +19,19 @@ import track.views
log
=
logging
.
getLogger
(
__name__
)
@requires_csrf_token
def
jsonable_server_error
(
request
,
template_name
=
'500.html'
):
"""
500 error handler that serves JSON on an AJAX request, and proxies
to the Django default `server_error` view otherwise.
"""
if
request
.
is_ajax
():
msg
=
{
"error"
:
"The edX servers encountered an error"
}
return
HttpResponseServerError
(
json
.
dumps
(
msg
))
else
:
return
server_error
(
request
,
template_name
=
template_name
)
def
calculate
(
request
):
''' Calculator in footer of every page. '''
equation
=
request
.
GET
[
'equation'
]
...
...
@@ -228,4 +244,3 @@ def accepts(request, media_type):
"""Return whether this request has an Accept header that matches type"""
accept
=
parse_accept_header
(
request
.
META
.
get
(
"HTTP_ACCEPT"
,
""
))
return
media_type
in
[
t
for
(
t
,
p
,
q
)
in
accept
]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment