Edgewall Software

Opened 8 years ago

Closed 8 years ago

Last modified 8 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:
Release Notes:

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

API Changes:


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


Attachments (2)

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

Download all attachments as: .zip

Change History (9)

Changed 8 years ago by Thijs Triemstra <lists@…>

Attachment: color-csv.patch added

remove color property

comment:1 Changed 8 years ago by Remy Blank

Owner: set to Remy Blank

I'll apply that, thanks.

comment:2 Changed 8 years ago by Thijs Triemstra <lists@…>

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})
     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
    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 Changed 8 years ago by Thijs Triemstra <lists@…>

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

Changed 8 years ago by Remy Blank

Different fix, directly in _send_csv().

comment:4 Changed 8 years ago by Remy Blank

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 Changed 8 years ago by Thijs Triemstra <lists@…>

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 Changed 8 years ago by Remy Blank

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 Changed 8 years ago by Remy Blank

Release Notes: modified (diff)

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Remy Blank.
The resolution will be deleted.
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.