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

View File

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