forked from expo/troggle
not found now does 404 & moved login
This commit is contained in:
@@ -1,8 +1,27 @@
|
||||
from builtins import str
|
||||
|
||||
from django.conf import settings
|
||||
from django.shortcuts import render
|
||||
from django.http import Http404, HttpResponseRedirect
|
||||
from django.contrib.auth import authenticate, login, logout
|
||||
from django.contrib.auth import forms as auth_forms
|
||||
from django.contrib.auth.decorators import login_required
|
||||
|
||||
"""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)
|
||||
|
||||
|
||||
# This is copied from CUYC.cuy.website.view.auth
|
||||
# If we want to do the whole online-email thing, we would also need to copy across the code in these
|
||||
|
||||
Reference in New Issue
Block a user