Update middleware to new style classes
Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -49,6 +49,7 @@
|
||||
* Increase the default number of recently added documents and
|
||||
recently accessed documents from 40 to 400.
|
||||
* Integrate django-autoadmin into the core apps.
|
||||
* Update middleware to new style classes.
|
||||
|
||||
3.1.11 (2019-04-XX)
|
||||
===================
|
||||
|
||||
@@ -73,6 +73,7 @@ Other changes
|
||||
* Increase the default number of recently added documents and
|
||||
recently accessed documents from 40 to 400.
|
||||
* Integrate django-autoadmin into the core apps.
|
||||
* Update middleware to new style classes.
|
||||
|
||||
Removals
|
||||
--------
|
||||
|
||||
@@ -2,9 +2,10 @@ from __future__ import unicode_literals
|
||||
|
||||
from django.conf import settings
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.utils.deprecation import MiddlewareMixin
|
||||
|
||||
|
||||
class AjaxRedirect(object):
|
||||
class AjaxRedirect(MiddlewareMixin):
|
||||
def process_request(self, request):
|
||||
ajax_referer = request.META.get('HTTP_X_ALT_REFERER')
|
||||
|
||||
|
||||
@@ -4,11 +4,12 @@ import logging
|
||||
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.http import Http404
|
||||
from django.utils.deprecation import MiddlewareMixin
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ErrorLoggingMiddleware(object):
|
||||
class ErrorLoggingMiddleware(MiddlewareMixin):
|
||||
def process_exception(self, request, exception):
|
||||
if not isinstance(exception, (PermissionDenied, Http404)):
|
||||
# Don't log non critical exceptions
|
||||
|
||||
@@ -4,9 +4,10 @@ import pytz
|
||||
|
||||
from django.conf import settings
|
||||
from django.utils import timezone
|
||||
from django.utils.deprecation import MiddlewareMixin
|
||||
|
||||
|
||||
class TimezoneMiddleware(object):
|
||||
class TimezoneMiddleware(MiddlewareMixin):
|
||||
def process_request(self, request):
|
||||
if hasattr(request, 'session'):
|
||||
tzname = request.session.get(settings.TIMEZONE_SESSION_KEY)
|
||||
|
||||
@@ -127,7 +127,7 @@ INSTALLED_APPS = (
|
||||
'drf_yasg',
|
||||
)
|
||||
|
||||
MIDDLEWARE_CLASSES = (
|
||||
MIDDLEWARE = (
|
||||
'mayan.apps.common.middleware.error_logging.ErrorLoggingMiddleware',
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'whitenoise.middleware.WhiteNoiseMiddleware',
|
||||
|
||||
@@ -12,8 +12,8 @@ COMMON_PRODUCTION_ERROR_LOG_PATH = '/tmp/mayan-errors.log'
|
||||
|
||||
# Remove whitenoise from middlewares. Causes out of memory errors during test
|
||||
# suit
|
||||
MIDDLEWARE_CLASSES = [
|
||||
cls for cls in MIDDLEWARE_CLASSES if cls != 'whitenoise.middleware.WhiteNoiseMiddleware'
|
||||
MIDDLEWARE = [
|
||||
cls for cls in MIDDLEWARE if cls != 'whitenoise.middleware.WhiteNoiseMiddleware'
|
||||
]
|
||||
|
||||
# User a simpler password hasher
|
||||
@@ -38,8 +38,8 @@ CELERY_EAGER_PROPAGATES_EXCEPTIONS = True
|
||||
BROKER_BACKEND = 'memory'
|
||||
|
||||
# Remove middlewares not used for tests
|
||||
MIDDLEWARE_CLASSES = [
|
||||
cls for cls in MIDDLEWARE_CLASSES if cls not in [
|
||||
MIDDLEWARE = [
|
||||
cls for cls in MIDDLEWARE if cls not in [
|
||||
'common.middleware.error_logging.ErrorLoggingMiddleware',
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'corsheaders.middleware.CorsMiddleware',
|
||||
|
||||
Reference in New Issue
Block a user