Added instructor availability model and admin
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user