Install polymorphic in prod

This commit is contained in:
2025-11-25 12:26:48 +01:00
parent bf9f43eed8
commit b32d0fd032
2 changed files with 4 additions and 7 deletions

View File

@@ -47,6 +47,7 @@ INSTALLED_APPS = [
'colorfield',
'import_export',
'django_admin_action_forms',
'polymorphic'
]
# Import Export plugin settings
@@ -56,7 +57,7 @@ IMPORT_EXPORT_SKIP_ADMIN_LOG = True
IMPORT_FORMATS = [CSV]
MIDDLEWARE = [
'flightslot.middleware.RedirectNonSuperuserFromAdminMiddleware',
'flightslot.middleware.RedirectNonSuperuserFromAdminMiddleware', # custom middleware to show "user" page to non superuser
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',

View File

@@ -8,11 +8,7 @@ class RedirectNonSuperuserFromAdminMiddleware:
def __call__(self, request: HttpRequest):
# Se l'utente è loggato, non è superuser e prova ad andare in /admin/...
if hasattr(request,"user"):
if (
request.path.startswith("/admin/") and
hasattr(request.user, 'student')
):
if hasattr(request, "user") and hasattr(request.user, 'student'):
if "/admin/" in request.path:
return redirect("/user/") # redirect automatico
return self.get_response(request)