Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make child ticket table columns configurable #9

Open
ChrisNelsonPE opened this issue Nov 2, 2010 · 3 comments
Open

Make child ticket table columns configurable #9

ChrisNelsonPE opened this issue Nov 2, 2010 · 3 comments

Comments

@ChrisNelsonPE
Copy link

If <parenttype>.table_columns exists in the [subtickets] section of trac.ini, it lists columns to show. If missing, the old default behavior is preserved.


diff --git a/tracsubtickets/web_ui.py b/tracsubtickets/web_ui.py
index c619e90..57f2b41 100644
--- a/tracsubtickets/web_ui.py
+++ b/tracsubtickets/web_ui.py
@@ -149,28 +149,37 @@ class SubTicketsModule(Component):
                 tbody = tag.tbody()
                 div.append(tag.table(tbody, class_='subtickets'))
 
+                columns = self.config.getlist('subtickets', '%s.table_columns' %
+
                 # tickets
                 def _func(children, depth=0):
                     for id in sorted(children, key=lambda x: int(x)):
                         ticket = Ticket(self.env, id)
 
-                        # 1st column
+                        # The row
+                        r=[]
+
+                        # Always show the ID and summary
                         attrs = {'href': req.href.ticket(id)}
                         if ticket['status'] == 'closed':
                             attrs['class_'] = 'closed'
                         link = tag.a('#%s' % id, **attrs)
                         summary = tag.td(link, ': %s' % ticket['summary'],
                             style='padding-left: %dpx;' % (depth * 15))
-                        # 2nd column
-                        type = tag.td(ticket['type'])
-                        # 3rd column
-                        status = tag.td(ticket['status'])
-                        # 4th column
-                        href = req.href.query(status='!closed',
+                        r.append(summary)
+
+                        # Add other columns as configured.
+                        for column in columns:
+                            if column == 'owner':
+                                href = req.href.query(status='!closed',
                                               owner=ticket['owner'])
-                        owner = tag.td(tag.a(ticket['owner'], href=href))
+                                e = tag.td(tag.a(ticket['owner'], href=href))
+                            else:
+                                e = tag.td(ticket[column])
+
+                            r.append(e)
 
-                        tbody.append(tag.tr(summary, type, status, owner))
+                        tbody.append(tag.tr(*r))
                         _func(children[id], depth + 1)
 
                 _func(data['subtickets'])
@tlast
Copy link

tlast commented Mar 14, 2011

Good day!

I could really use this and understand most of what is going on here - but I believe something is missing at

  • columns = self.config.getlist('subtickets', '%s.table_columns' %

How are you setting the default columns if there is nothing configured?

@ChrisNelsonPE
Copy link
Author

Sorry, the diff got clipped. Here's the whole statement:

  columns = self.config.getlist('subtickets', '%s.table_columns' \
  % ticket['type'], default=['type','status','owner'])

@tlast
Copy link

tlast commented Mar 14, 2011

Ahhh, I see. Perfect, thank you so much for the quick reply!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants