def require_admin(handler):
 @require_login
 def require_admin_wrapper_fn(request, *args, **kwargs):
  if ((settings.CENTRAL_SERVER and request.user.is_authenticated()) or getattr(request, 'is_admin', False)):
   return handler(request, *args, **kwargs)
  facility_user_id = kwargs.get('facility_user_id')
  if (request.session.get('facility_user') and (facility_user_id == request.session.get('facility_user').id)):
   return handler(request, *args, **kwargs)
  raise PermissionDenied(_('You must be logged in as an admin to access this page.'))
 return require_admin_wrapper_fn

def require_admin ( handler ) : @ require_login def require_admin_wrapper_fn ( request , * args , ** kwargs ) : if ( ( settings . CENTRAL_SERVER and request . user . is_authenticated ( ) ) or getattr ( request , 'is_admin' , False ) ) : return handler ( request , * args , ** kwargs ) facility_user_id = kwargs . get ( 'facility_user_id' ) if ( request . session . get ( 'facility_user' ) and ( facility_user_id == request . session . get ( 'facility_user' ) . id ) ) : return handler ( request , * args , ** kwargs ) raise PermissionDenied ( _ ( 'You must be logged in as an admin to access this page.' ) ) return require_admin_wrapper_fn
level 2: require an admin: * central server: any user with an account * distributed server: any django admin or teacher .