2012-08-01 21:30:18 +00:00
|
|
|
from django.conf import settings
|
|
|
|
|
from django.http import HttpResponseRedirect
|
|
|
|
|
from django.core.urlresolvers import reverse
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Public(object):
|
2019-02-22 17:40:02 +08:00
|
|
|
|
2012-08-01 21:30:18 +00:00
|
|
|
def process_request(self, request):
|
2019-02-22 17:40:02 +08:00
|
|
|
if settings.PUBLIC is False and not request.user.is_authenticated():
|
2012-08-01 21:30:18 +00:00
|
|
|
acceptable_paths = [
|
|
|
|
|
'/login/',
|
|
|
|
|
'/private/',
|
|
|
|
|
'/register/',
|
|
|
|
|
]
|
|
|
|
|
if request.path not in acceptable_paths:
|
2013-03-03 22:47:25 +00:00
|
|
|
return HttpResponseRedirect(reverse('users:private'))
|