code: def require_component_access(view_func, component):
      
      from horizon.exceptions import NotAuthorized
  
      @functools.wraps(view_func, assigned=available_attrs(view_func))
      def dec(request, *args, **kwargs):
          if not component.can_access({'request': request}):
              raise NotAuthorized(_("You are not authorized to access %s")
                                  % request.path)
  
          return view_func(request, *args, **kwargs)
  
      return dec
docs: Perform component can_access check to access the view.
  
      :param component containing the view (panel or dashboard).
  
      Raises a :exc:`~horizon.exceptions.NotAuthorized` exception if the
      user cannot access the component containing the view.
      By example the check of component policy rules will be applied to its
      views.