2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-16 10:07:25 +00:00

not found now does 404 & moved login

This commit is contained in:
Philip Sargent
2021-05-03 20:35:35 +01:00
parent 254b465755
commit 9b9f6720e0
8 changed files with 37 additions and 35 deletions

View File

@@ -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