bloodhound-trac / trac / ticket / templates / query_results.html

Full commit
       groups    - a dict, where:
                     key       - is the value shared by all results in this group
                     value     - is the list of corresponding tickets

       headers   - a sequence of header structure:
                     .name     - field name for this header
                     .label    - what to display for this header

       fields    - dict of field name to field structure:
                     .label    - field label

       query     - the actual Query instance used to perform the query

<div xmlns=""
  <h2 class="report-result" py:if="paginator.has_more_pages">
    Results <span class="numresults">(${paginator.displayed_items()})</span>
  <xi:include py:if="paginator.show_index" href="page_index.html" />
  <py:def function="group_heading(groupname, results)">
    <h2 class="report-result" py:if="groupname is not None"
        i18n:msg="grouplabel, groupname, count"
        py:with="grouplabel = fields[].label;
                 groupname = authorinfo(groupname) if in ['owner', 'reporter'] else (groupname or _('None'));
                 count = ngettext('%(num)s match', '%(num)s matches', len(results))">
      ${grouplabel}: ${groupname} <span class="numrows">(${count})</span>
  <py:def function="column_headers()">
    <tr class="trac-columns">
      <th py:for="header in headers"
          class="$${(' desc' if query.desc else ' asc') if query.order == else ''}">
        <?python asc = _('(ascending)'); desc = _('(descending)') ?>
        <a title="${_('Sort by %(col)s %(direction)s', col=header.label,
                      direction=(desc if query.order == and not query.desc else asc))}"
  ${group_heading(*groups[0]) if groups else None}
  <table class="listing tickets"
         py:with="num_cols = len(headers) + int(batch_modify or 0)">
    <thead py:strip="group_index">
    <py:for each="group_index, (groupname, results) in enumerate(groups)">
      <tbody py:if="group_index">
        <tr py:if="groupname is not None" class="trac-group">
          <th colspan="$num_cols">
            ${group_heading(groupname, results)}
        <tr py:if="not results" class="even">
          <td colspan="$num_cols">
            No tickets found
        <py:for each="idx, result in enumerate(results)">
          <py:with vars="ticket_context = context.child('ticket',">
            <py:if test="'TICKET_VIEW' in perm(ticket_context.resource)">

              <tr class="${'odd' if idx % 2 else 'even'} prio${result.priority_value}${
                ' added' if 'added' in result else ''}${
                ' changed' if 'changed' in result else ''}${
                ' removed' if 'removed' in result else ''}">
                <py:for each="idx, header in enumerate(headers)" py:choose="">
                  <py:with vars="name =; value = result[name]">
                    <td py:when="name == 'id'" class="id"><a href="$result.href" title="View ticket"
                        class="${classes(closed=result.status == 'closed')}">#$</a></td>
                    <td py:otherwise="" class="$name" py:choose="">
                      <a py:when="name == 'summary'" href="$result.href" title="View ticket">$value</a>
                      <py:when test="isinstance(value, datetime)">${pretty_dateinfo(value, dateonly=True)}</py:when>
                      <py:when test="name == 'reporter'">${authorinfo(value)}</py:when>
                      <py:when test="name == 'cc'">${format_emails(ticket_context, value)}</py:when>
                      <py:when test="name == 'owner' and value">${authorinfo(value)}</py:when>
                      <py:when test="name == 'milestone'"><a py:if="value" title="View milestone" href="${href.milestone(value)}">${value}</a></py:when>
                      <py:when test="header.wikify">${wiki_to_oneliner(ticket_context, value)}</py:when>

              <py:with vars="result_rows = [t for t in row if result[t]]">
                  <tr py:when="ticket_context.resource in context" class="fullrow">
                    <td colspan="$num_cols">
                      <p class="meta"><em>(this ticket)</em></p>
                  <tr py:otherwise="" py:for="r in result_rows" class="fullrow">
                    <th class="meta">${fields.get(r, {'label': r or 'none'}).label}</th>
                    <td colspan="${num_cols - 1}" xml:space="preserve">
                      ${wiki_to_html(ticket_context, result[r])}
        <tr py:if="group_index == len(groups)-1 and last_group_is_partial">
          <td colspan="$num_cols">
            <i>(more results for this group on next page)</i>
  <xi:include py:if="paginator.show_index" href="page_index.html" />