mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-11 04:19:25 +00:00
All: Apply Black coding rules
This commit is contained in:
@ -26,14 +26,16 @@ import importlib
|
||||
from django.conf import settings
|
||||
from django.utils.functional import SimpleLazyObject
|
||||
from django.contrib.auth import get_user
|
||||
from django.contrib.auth.middleware import AuthenticationMiddleware as DjangoAuthenticationMiddleware
|
||||
from django.contrib.auth.middleware import (
|
||||
AuthenticationMiddleware as DjangoAuthenticationMiddleware,
|
||||
)
|
||||
|
||||
module, klass = settings.AUTH_ANONYMOUS_MODEL.rsplit('.', 1)
|
||||
module, klass = settings.AUTH_ANONYMOUS_MODEL.rsplit(".", 1)
|
||||
AnonymousUser = getattr(importlib.import_module(module), klass)
|
||||
|
||||
|
||||
def get_cached_user(request):
|
||||
if not hasattr(request, '_cached_user'):
|
||||
if not hasattr(request, "_cached_user"):
|
||||
user = get_user(request)
|
||||
if user.is_anonymous():
|
||||
user = AnonymousUser(request)
|
||||
@ -45,7 +47,7 @@ def get_cached_user(request):
|
||||
|
||||
class AuthenticationMiddleware(DjangoAuthenticationMiddleware):
|
||||
def process_request(self, request):
|
||||
assert hasattr(request, 'session'), (
|
||||
assert hasattr(request, "session"), (
|
||||
"The Django authentication middleware requires session middleware "
|
||||
"to be installed. Edit your MIDDLEWARE_CLASSES setting to insert "
|
||||
"'django.contrib.sessions.middleware.SessionMiddleware' before "
|
||||
|
Reference in New Issue
Block a user