2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-29 21:31:54 +00:00
troggle/helper/__init__.py

18 lines
539 B
Python
Raw Normal View History

from django.contrib.auth.decorators import login_required
from django.conf import settings
2020-07-19 01:23:07 +01:00
"""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)