def dispatch(self, request, *args, **kwargs):
"""Override to check settings"""
if django.VERSION < (1, 10):
is_auth = request.user.is_authenticated()
else:
is_auth = request.user.is_authenticated
if not ADMIN_SHELL_ENABLE:
return HttpResponseNotFound("Not found: Django admin shell is not enabled")
elif is_auth is False or request.user.is_staff is False:
return HttpResponseForbidden("Forbidden: To access Django admin shell you must have access the admin site")
elif ADMIN_SHELL_ONLY_DEBUG_MODE and settings.DEBUG is False:
return HttpResponseForbidden("Forbidden :Django admin shell require DEBUG mode")
elif ADMIN_SHELL_ONLY_FOR_SUPERUSER and request.user.is_superuser is False:
return HttpResponseForbidden("Forbidden: To access Django admin shell you must be superuser")
return super(Shell, self).dispatch(request, *args, **kwargs)
评论列表
文章目录