def process_request(request: HttpRequest) -> HttpResponse: if not hasattr(request, 'user'): raise ImproperlyConfigured( "Authentication middleware required. Edit your" " MIDDLEWARE_CLASSES setting to insert" " 'django.contrib.auth.middleware.AuthenticationMiddleware'" " before the RestrictDevAdminMiddleware class.") if request.path.startswith(reverse(f"{AdminSiteNames.DEVADMIN}:index")): # noqa if not is_developer(request.user): return HttpResponseForbidden( "Non-developers cannot access the devadmin") if request.path.startswith(reverse(f"{AdminSiteNames.MGRADMIN}:index")): # noqa if not request.user.is_superuser: return HttpResponseForbidden( "Non-superusers cannot access the mgradmin")
def home(request: HttpRequest) -> HttpResponse: # leaflets = [{'key': x[0], 'name': x[1]} for x in Leaflet.LEAFLET_CHOICES] # assert False # log.critical("IP Address for debug-toolbar: " + request.META['REMOTE_ADDR']) # noqa # log.critical("MIDDLEWARE_CLASSES: {}".format(repr(MIDDLEWARE_CLASSES))) context = { 'nav_on_main_menu': True, 'is_clinician': is_clinician(request.user), 'is_developer': is_developer(request.user), 'safety_catch_on': settings.SAFETY_CATCH_ON, 'developer_email': settings.DEVELOPER_EMAIL, # 'leaflets': leaflets, } context.update(query_context(request)) return render(request, 'home.html', context)