Added instructor availability model and admin

This commit is contained in:
2025-12-02 12:00:15 +01:00
parent 5d1686f24b
commit 3ee2269d70
10 changed files with 236 additions and 9 deletions

View File

@@ -7,8 +7,10 @@ class RedirectNonSuperuserFromAdminMiddleware:
self.get_response = get_response
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/... o qualsiasi altro path
if hasattr(request, "user") and not request.user.is_superuser:
if "/admin/" in request.path:
if hasattr(request.user, "student") and not "/user/" in request.path:
return redirect("/user/") # redirect automatico
elif hasattr(request.user, "instructor") and not "/staff/" in request.path:
return redirect("/staff/") # redirect automatico
return self.get_response(request)