Skip to content

Commit

Permalink
Upgrading pre-Django 1.10-style middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
norkans7 committed Jun 12, 2017
1 parent dd64e31 commit 9205f69
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
10 changes: 8 additions & 2 deletions smartmin/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@
from django.utils import timezone
from six.moves import StringIO

try:
from django.utils.deprecation import MiddlewareMixin
except ImportError:
class MiddlewareMixin(object):
pass


class AjaxRedirect(object):
class AjaxRedirect(MiddlewareMixin):
def process_response(self, request, response):
if request.is_ajax():
if type(response) == HttpResponseRedirect:
Expand All @@ -21,7 +27,7 @@ def process_response(self, request, response):
return response


class ProfileMiddleware(object):
class ProfileMiddleware(MiddlewareMixin):
def __init__(self):
pass

Expand Down
8 changes: 7 additions & 1 deletion smartmin/users/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@
from django.http import HttpResponseRedirect
from .models import PasswordHistory

try:
from django.utils.deprecation import MiddlewareMixin
except ImportError:
class MiddlewareMixin(object):
pass

class ChangePasswordMiddleware:

class ChangePasswordMiddleware(MiddlewareMixin):
"""
Redirects all users to the password change form if we find that a user's
password is expired.
Expand Down

0 comments on commit 9205f69

Please sign in to comment.