Edgewall Software

Ticket #5806: 5806_fix.patch

File 5806_fix.patch, 6.3 KB (added by François Terrier <fterrier@…>, 3 years ago)
  • trac/ticket/report.py

     
    354354                'col': col, 
    355355                'title': col.strip('_').capitalize(), 
    356356                'hidden': False, 
    357                 'asc': False 
     357                'asc': False, 
     358                'type': col 
    358359            } 
    359360 
    360361            if col == sort_col: 
     
    404405        # Structure the rows and cells: 
    405406        #  - group rows according to __group__ value, if defined 
    406407        #  - group cells the same way headers are grouped 
     408        type_warnings = [] 
    407409        row_groups = [] 
    408410        prev_group_value = None 
    409411        for row_idx, result in enumerate(results): 
     
    438440                        email_cells.append(cell) 
    439441                    elif col == 'realm': 
    440442                        realm = value 
     443 
     444                    # Fix bug #5806, if results come from a db query, we must check 
     445                    # the types before sending to the template engine, for now  
     446                    # we just prefix the type with 'sql.' 
     447                    if (col == 'time'  
     448                        or col in ['date', 'created', 'modified']  
     449                        or col == 'datetime'): 
     450                        if not re.match(r"[0-9]*$", value): 
     451                            header['type'] = "sql." + header['type'] 
     452                            type_warnings.append(col) 
     453 
    441454                    cell_group.append(cell) 
    442455                cell_groups.append(cell_group) 
    443456            resource = Resource(realm, row.get('id')) 
     
    457470                row_groups = [(None, row_group)] 
    458471            row_group.append(row) 
    459472 
     473        for type_warning in set(type_warnings): 
     474            add_warning(req,  
     475                        _("Using a reserved column name (%s) with " 
     476                          "an incompatible type" % type_warning)) 
     477 
    460478        # Get the email addresses of all known users 
    461479        email_map = {} 
    462480        if Chrome(self.env).show_email_addresses: 
  • trac/ticket/templates/report_view.html

     
    119119 
    120120                <py:for each="cell in cell_group"> 
    121121                  <py:if test="not cell.header.hidden"> 
    122                     <py:with vars="col = cell.header.col.strip('_')"> 
     122                    <py:with vars="col = cell.header.col.strip('_'); type = cell.header.type"> 
    123123                      <py:choose> 
    124124 
    125125                        <!--! for the report listing --> 
    126                         <py:when test="col == 'report'"> 
     126                        <py:when test="type == 'report'"> 
    127127                          <td class="$col" py:attrs="td_attrs"> 
    128128                            <a title="View report" href="${href.report(cell.value)}">{$cell.value}</a> 
    129129                            <hr py:if="fullrow"/> 
    130130                          </td> 
    131131                        </py:when> 
    132132 
    133                         <py:when test="col == 'title' and report.id == -1"> 
     133                        <py:when test="type == 'title' and report.id == -1"> 
    134134                          <td class="$col" py:attrs="td_attrs"> 
    135135                            <a title="View report" href="${href.report(row.id)}">$cell.value</a> 
    136136                            <hr py:if="fullrow"/> 
     
    138138                        </py:when> 
    139139 
    140140                        <!--! for the ticket listing --> 
    141                         <py:when test="col in ('ticket', 'id')"> 
     141                        <py:when test="type in ('ticket', 'id')"> 
    142142                          <td class="ticket" py:attrs="td_attrs"> 
    143143                            <a title="View ${row.resource.realm}" href="${url_of(row.resource)}">#$cell.value</a> 
    144144                            <hr py:if="fullrow"/> 
    145145                          </td> 
    146146                        </py:when> 
    147147 
    148                         <py:when test="col == 'summary' and row.id"> 
     148                        <py:when test="type == 'summary' and row.id"> 
    149149                          <td class="$col" py:attrs="td_attrs"> 
    150150                            <a title="View ${row.resource.realm}" href="${url_of(row.resource)}">$cell.value</a> 
    151151                            <hr py:if="fullrow"/> 
     
    153153                        </py:when> 
    154154 
    155155                        <!--! generic fields --> 
    156                         <py:when test="col == 'time'"> 
     156                        <py:when test="type == 'time'"> 
    157157                          <td class="date" py:attrs="td_attrs">${cell.value != '' and format_time(int(cell.value)) or '--'} 
    158158                            <hr py:if="fullrow"/> 
    159159                          </td> 
    160160                        </py:when> 
    161  
    162                         <py:when test="col in ('date', 'created', 'modified')"> 
     161                         
     162                        <py:when test="type in ('date', 'created', 'modified')"> 
    163163                          <td class="date" py:attrs="td_attrs">${cell.value != '' and format_date(int(cell.value)) or '--'} 
    164164                            <hr py:if="fullrow"/> 
    165165                          </td> 
    166166                        </py:when> 
    167167 
    168                         <py:when test="col == 'datetime'"> 
     168                        <py:when test="type == 'datetime'"> 
    169169                          <td class="date" py:attrs="td_attrs">${cell.value != '' and format_datetime(int(cell.value)) or '--'} 
    170170                            <hr py:if="fullrow"/> 
    171171                          </td> 
    172172                        </py:when> 
    173173 
    174                         <py:when test="col == 'description'"> 
     174                        <py:when test="type == 'description'"> 
    175175                          <td class="$col" py:attrs="td_attrs" xml:space="preserve"> 
    176176                            ${wiki_to_html(context(row.resource), cell.value)} 
    177177                            <hr py:if="fullrow"/> 
    178178                          </td> 
    179179                        </py:when> 
    180180 
    181                         <py:when test="col == 'milestone'"> 
     181                        <py:when test="type == 'milestone'"> 
    182182                          <td class="$col" py:attrs="td_attrs"> 
    183183                            <a title="View milestone" href="${href.milestone(cell.value)}">$cell.value</a> 
    184184                            <hr py:if="fullrow"/>