original_docstring: Render returned context in a table view.
docstring: Render returned context in a table view.
docstring_tokens: Render returned context in a table view .
code: def render_with_table_view(
      func: Callable[..., TableContext],
  ) -> Callable[..., TemplateResponse]:
      """Render returned context in a table view."""
  
      @wraps(func)
      def wrapper(*args: Any, **kwargs: Any) -> TemplateResponse:
          request: HttpRequest = args[0]
          context = func(*args, **kwargs)
          func_name = f"{func.__module__}.{func.__qualname__}"  # noqa
          urls: List[URLConfig] = admin_data_settings.URLS
  
          for item in urls:  # pylint: disable=R1702:
              view_name = f"{item['view'].__module__}.{item['view'].__qualname__}"
              if view_name == func_name:
                  context["slug"] = item["route"]  # type: ignore
  
                  # Look for any item links in the rows.
                  if item["items"] is not None:
                      item_view_name = item["items"]["name"]
  
                      for header in context["table"]:
                          for row_no, cell in enumerate(context["table"][header]):
                              if not isinstance(cell, ItemLink):  # pragma: no cover
                                  continue
  
                              context["table"][header][row_no] = format_html(  # type: ignore
                                  '<a href="{}">{}</a>',
                                  reverse(
                                      viewname=f"admin:{item_view_name}",
                                      kwargs=cell.kwargs,
                                      current_app=admin_site.name,
                                  ),
                                  str(cell.link_item),
                              )
  
                          break  # Only the first column
                  break  # Stop searching once view is found
  
          else:
              raise ValueError(f"Cannot find '{func_name}' in ADMIN_DATA_VIEWS setting.")
  
          # Transform the columns into a list of rows.
          # This way the table is easier to render in the template.
          context["headers"] = list(context["table"].keys())  # type: ignore
          context["rows"]: List[List[Any]] = [[] for _ in next(iter(context["table"].values()))]  # type: ignore
          for column in context["table"].values():
              for row_no, cell in enumerate(column):
                  context["rows"][row_no].append(cell)  # type: ignore
  
          context.update(admin_site.each_context(request))
          context["app_label"] = AdminConfig.verbose_name  # type: ignore
          request.current_app = admin_site.name
          return TemplateResponse(request, "admin_data_views/admin_data_table_page.html", context)
  
      return wrapper
code_tokens: def render_with_table_view ( func : Callable [ ... , TableContext ] , ) -> Callable [ ... , TemplateResponse ] : @ wraps ( func ) def wrapper ( * args : Any , ** kwargs : Any ) -> TemplateResponse : request : HttpRequest = args [ 0 ] context = func ( * args , ** kwargs ) func_name = f"{func.__module__}.{func.__qualname__}" urls : List [ URLConfig ] = admin_data_settings . URLS for item in urls : view_name = f"{item['view'].__module__}.{item['view'].__qualname__}" if view_name == func_name : context [ "slug" ] = item [ "route" ] if item [ "items" ] is not None : item_view_name = item [ "items" ] [ "name" ] for header in context [ "table" ] : for row_no , cell in enumerate ( context [ "table" ] [ header ] ) : if not isinstance ( cell , ItemLink ) : continue context [ "table" ] [ header ] [ row_no ] = format_html ( '<a href="{}">{}</a>' , reverse ( viewname = f"admin:{item_view_name}" , kwargs = cell . kwargs , current_app = admin_site . name , ) , str ( cell . link_item ) , ) break break else : raise ValueError ( f"Cannot find '{func_name}' in ADMIN_DATA_VIEWS setting." ) context [ "headers" ] = list ( context [ "table" ] . keys ( ) ) context [ "rows" ] : List [ List [ Any ] ] = [ [ ] for _ in next ( iter ( context [ "table" ] . values ( ) ) ) ] for column in context [ "table" ] . values ( ) : for row_no , cell in enumerate ( column ) : context [ "rows" ] [ row_no ] . append ( cell ) context . update ( admin_site . each_context ( request ) ) context [ "app_label" ] = AdminConfig . verbose_name request . current_app = admin_site . name return TemplateResponse ( request , "admin_data_views/admin_data_table_page.html" , context ) return wrapper
short_docstring: Render returned context in a table view.
short_docstring_tokens: Render returned context in a table view .
comment: """Render returned context in a table view."""$SEP$# noqa
  $SEP$# pylint: disable=R1702:
  $SEP$# type: ignore
  $SEP$# Look for any item links in the rows.
  $SEP$# pragma: no cover
  $SEP$# type: ignore
  $SEP$# Only the first column
  $SEP$# Stop searching once view is found
  $SEP$# Transform the columns into a list of rows.
  $SEP$# This way the table is easier to render in the template.
  $SEP$# type: ignore
  $SEP$# type: ignore
  $SEP$# type: ignore
  $SEP$# type: ignore
  