[Chore] Linted Files (#150)

Co-authored-by: Tim Lorsbach <tim@lorsba.ch>
Reviewed-on: enviPath/enviPy#150
This commit is contained in:
2025-10-09 07:25:13 +13:00
parent 22f0bbe10b
commit afeb56622c
50 changed files with 5616 additions and 4408 deletions

View File

@ -3,22 +3,25 @@ from django.shortcuts import redirect
from django.urls import reverse
from urllib.parse import quote
class LoginRequiredMiddleware:
def __init__(self, get_response):
self.get_response = get_response
self.exempt_urls = [
reverse('login'),
reverse('logout'),
reverse('admin:login'),
reverse('admin:index'),
] + getattr(settings, 'LOGIN_EXEMPT_URLS', [])
reverse("login"),
reverse("logout"),
reverse("admin:login"),
reverse("admin:index"),
] + getattr(settings, "LOGIN_EXEMPT_URLS", [])
def __call__(self, request):
if not request.user.is_authenticated:
path = request.path_info
if not any(path.startswith(url) for url in self.exempt_urls):
if request.method == 'GET':
if request.get_full_path() and request.get_full_path() != '/':
return redirect(f"{settings.LOGIN_URL}?next={quote(request.get_full_path())}")
if request.method == "GET":
if request.get_full_path() and request.get_full_path() != "/":
return redirect(
f"{settings.LOGIN_URL}?next={quote(request.get_full_path())}"
)
return redirect(settings.LOGIN_URL)
return self.get_response(request)