Add middleware to allow rewriting the status code of ajax responses' redirects
This commit is contained in:
12
mayan/apps/common/middleware/ajax_redirect.py
Normal file
12
mayan/apps/common/middleware/ajax_redirect.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf import settings
|
||||
from django.http import HttpResponseRedirect
|
||||
|
||||
|
||||
class AjaxRedirect(object):
|
||||
def process_response(self, request, response):
|
||||
if request.is_ajax():
|
||||
if type(response) == HttpResponseRedirect:
|
||||
response.status_code = getattr(settings, 'AJAX_REDIRECT_CODE', 302)
|
||||
return response
|
||||
Reference in New Issue
Block a user