From c7e1e1cd83abb6cd6b3e4c89bd45c714b571b53e Mon Sep 17 00:00:00 2001 From: Isaac Bythewood Date: Sun, 3 Mar 2013 22:50:29 +0000 Subject: [PATCH] Move location of users middleware --- pinry/core/middleware.py | 15 --------------- pinry/settings/__init__.py | 2 +- pinry/users/middleware.py | 15 +++++++++++++++ 3 files changed, 16 insertions(+), 16 deletions(-) delete mode 100644 pinry/core/middleware.py create mode 100644 pinry/users/middleware.py diff --git a/pinry/core/middleware.py b/pinry/core/middleware.py deleted file mode 100644 index 71234d1..0000000 --- a/pinry/core/middleware.py +++ /dev/null @@ -1,15 +0,0 @@ -from django.conf import settings -from django.http import HttpResponseRedirect -from django.core.urlresolvers import reverse - - -class Public(object): - def process_request(self, request): - if settings.PUBLIC == False and not request.user.is_authenticated(): - acceptable_paths = [ - '/login/', - '/private/', - '/register/', - ] - if request.path not in acceptable_paths: - return HttpResponseRedirect(reverse('users:private')) diff --git a/pinry/settings/__init__.py b/pinry/settings/__init__.py index 27a1d24..fc8e2b0 100644 --- a/pinry/settings/__init__.py +++ b/pinry/settings/__init__.py @@ -44,7 +44,7 @@ MIDDLEWARE_CLASSES = ( 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', - 'pinry.core.middleware.Public', + 'pinry.users.middleware.Public', ) TEMPLATE_CONTEXT_PROCESSORS = ( 'django.contrib.auth.context_processors.auth', diff --git a/pinry/users/middleware.py b/pinry/users/middleware.py new file mode 100644 index 0000000..71234d1 --- /dev/null +++ b/pinry/users/middleware.py @@ -0,0 +1,15 @@ +from django.conf import settings +from django.http import HttpResponseRedirect +from django.core.urlresolvers import reverse + + +class Public(object): + def process_request(self, request): + if settings.PUBLIC == False and not request.user.is_authenticated(): + acceptable_paths = [ + '/login/', + '/private/', + '/register/', + ] + if request.path not in acceptable_paths: + return HttpResponseRedirect(reverse('users:private'))