decorator to check if user is logged in if settings.PUBLIC_SITE

This commit is contained in:
Martin Green 2011-05-02 02:13:27 +01:00
parent 671e946c6d
commit 872ffe5882

14
helper/__init__.py Normal file
View File

@ -0,0 +1,14 @@
from django.contrib.auth.decorators import login_required
from django.conf import settings
class login_required_if_public(object):
def __init__(self, f):
if settings.PUBLIC_SITE:
self.f = login_required(f)
else:
self.f = f
def __call__(self, *args, **kwargs):
return self.f(*args, **kwargs)