code: def requires_roles(roles):
      
      def inner(f):
          def is_available_here(context):
              return bool(roles.intersection(context.obj.current_roles))
  
          def is_available(context):
              result = is_available_here(context)
              if result and hasattr(f, 'is_available'):
                  # We passed, but we're wrapping another test, so ask there as well
                  return f.is_available(context)
              return result
  
          @wraps(f)
          def wrapper(self, *args, **kwargs):
              add_auth_attribute('login_required', True)
              if not is_available_here(self):
                  abort(403)
              return f(self, *args, **kwargs)
  
          wrapper.requires_roles = roles
          wrapper.is_available = is_available
          return wrapper
      return inner
docs: Decorator for :class:`ModelView` views that limits access to the specified
      roles.