summaryrefslogtreecommitdiffstats
path: root/helper/__init__.py
blob: 687b3702b3024b9f86c1672d81274bb525684d50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from django.contrib.auth.decorators import login_required
from django.conf import settings
"""This enforces the login requirement for non-public pages using 
the decorator mechanism. 
https://www.fullstackpython.com/django-contrib-auth-decorators-login-required-examples.html
"""

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)