Edgewall Software
Modify

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#9667 closed defect (fixed)

[PATCH] __color__ column in csv reports

Reported by: Thijs Triemstra <lists@…> Owned by: Remy Blank
Priority: normal Milestone: 0.12.2
Component: report system Version: 0.12-stable
Severity: normal Keywords:
Cc: Branch:
Release Notes:

In reports, strip special columns like __color__ from CSV exports.

API Changes:
Internal Changes:

Description

On a new Trac instance http://localhost:8080/report/1?asc=1&format=csv returns a __color__ column for csv reports:

__color__,ticket,summary,component,version,milestone,type,owner,status,created,_changetime,_description,_reporter
3,1,sdsad,component1,,,defect,somebody,new,2010-09-29T00:10:30+02:00,2010-09-29T00:48:11+02:00,[[TracAdminHelp(upgrade)]],admin
3,2,sdsadsa,component1,,,defect,somebody,new,2010-09-29T00:10:36+02:00,2010-09-29T00:10:36+02:00,dsadsdsadasdas,admin
3,3,sadsadsdasdas,component1,,,defect,somebody,new,2010-09-29T00:10:43+02:00,2010-09-29T00:10:43+02:00,sadsadasd,admin

Attachments (2)

color-csv.patch (527 bytes ) - added by Thijs Triemstra <lists@…> 14 years ago.
remove color property
9667-special-cols-r10233.patch (2.5 KB ) - added by Remy Blank 14 years ago.
Different fix, directly in _send_csv().

Download all attachments as: .zip

Change History (9)

by Thijs Triemstra <lists@…>, 14 years ago

Attachment: color-csv.patch added

remove color property

comment:1 by Remy Blank, 14 years ago

Owner: set to Remy Blank

I'll apply that, thanks.

comment:2 by Thijs Triemstra <lists@…>, 14 years ago

The previous patch didn't remove the row's first cell, only the column header, this patch should fix that (and also exclude other style-related rows):

  • trac/ticket/report.py

     
    478478        #  - group rows according to __group__ value, if defined
    479479        #  - group cells the same way headers are grouped
    480480        row_groups = []
    481         authorized_results = []
     481        authorized_results = []
     482        extra_row_props = ['__style__', '__color__', '__fgcolor__',
     483                           '__bgcolor__', '__grouplink__']
    482484        prev_group_value = None
    483485        for row_idx, result in enumerate(results):
    484486            col_idx = 0
     
    501503                            (Chrome(self.env).format_author(req, value), []) )
    502504                    # Other row properties
    503505                    row['__idx__'] = row_idx
    504                     if col in ('__style__', '__color__',
    505                                '__fgcolor__', '__bgcolor__',
    506                                '__grouplink__'):
     506                    if col in extra_row_props:
    507507                        row[col] = value
    508508                    if col in ('report', 'ticket', 'id', '_id'):
    509509                        row['id'] = value
     
    539539                     'numrows': numrows,
    540540                     'sorting_enabled': len(row_groups) == 1})
    541541
     542        if format == 'csv' or format == 'tab':
     543            for exclude in extra_row_props:
     544                try:
     545                    clr = cols.index(exclude)
     546                    cols.pop(clr)
     547                    for row in authorized_results:
     548                        row.pop(clr)
     549                except ValueError:
     550                    pass
     551
    542552        if format == 'rss':
    543553            data['email_map'] = Chrome(self.env).get_email_map()
    544554            data['context'] = Context.from_request(req, report_resource,

comment:3 by Thijs Triemstra <lists@…>, 14 years ago

Keywords: review added
Summary: __color__ column in csv reports[PATCH] __color__ column in csv reports

by Remy Blank, 14 years ago

Different fix, directly in _send_csv().

comment:4 by Remy Blank, 14 years ago

Could you please test 9667-special-cols-r10233.patch? It solves the issue slightly differently, by filtering the columns in _send_csv(), so it doesn't have to mutate all results.

comment:5 by Thijs Triemstra <lists@…>, 14 years ago

Keywords: review removed

Thanks, that patch is much cleaner and works properly on http://localhost:8000/trac-test-instance/report/1?asc=1&format=csv. If I check the 'My Tickets' link on http://localhost:8000/trac-test-instance/report/7 it contains a __group__ column. Even though it it's not part of this ticket description, would be nice to get rid of that one as well.

comment:6 by Remy Blank, 14 years ago

Resolution: fixed
Status: newclosed

Thanks for testing. About the __group__ column, it could be removed easily by adding it to the _special_cols set, but I'm not sure this is desired.

All other special columns only have meaning when rendered as HTML. The __group__ column, however, represents the grouping information for the report, and removing it changes the meaning of the report. So I would rather leave it in.

Patch above (with a small change in name to better identify the removed special columns) applied in [10247].

comment:7 by Remy Blank, 14 years ago

Release Notes: modified (diff)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Remy Blank.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Remy Blank to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.