cmlenz  committed 740e68a

The values of ticket fields on the ticket page now link to queries using that field/value as a filter. MAny thanks to Jeff Hammel for the patch. Closes #7562.

  • Participants
  • Parent commits 8f4eac9
  • Branches trunk

Comments (0)

Files changed (3)

  * Chris Green          
  * Gruffudd Prys        
  * Mikael Hallendal     
+ * Jeff Hammel          
  * Stephen Hansen       
  * Laurie Harper        
  * Francois Harvey      
  * Rayentray Tappa
  * Alec Thomas          
  * Jani Tiainen         
- * Ghassem Tofighi
+ * Ghassem Tofighi      
  * Zilvinas Valinskas   
  * Jason Vasquez        
  * Leslie H. Watter

File trac/ticket/templates/ticket.html

                                     not in ('type', 'owner')]">
               <th id="h_reporter">Reported by:</th>
-              <td headers="h_reporter" class="searchable">${authorinfo(ticket.reporter)}</td>
+              <td headers="h_reporter" class="searchable">${reporter_link}</td>
               <th id="h_owner">Owned by:</th>
-              <td headers="h_owner">${ticket.owner and authorinfo(ticket.owner) or ''}
+              <td headers="h_owner">${owner_link}
             <tr py:for="row in group(fields, 2, lambda f: f.type != 'textarea')"

File trac/ticket/

 from genshi.builder import tag
 from trac.attachment import AttachmentModule
-from trac.config import BoolOption, Option, IntOption, _TRUE_VALUES
+from trac.config import BoolOption, Option, IntOption, ListOption, _TRUE_VALUES
 from trac.core import *
 from trac.mimeview.api import Mimeview, IContentConverter, Context
 from trac.resource import Resource, get_resource_url, \
         If set to 'default', this is equivalent to 'yes' for new environments
         but keeps the old behavior for upgraded environments (i.e. 'no').
         (''since 0.11'').""")
+    unlinked_fields = ListOption('ticket', 'unlinked_fields', 
+                                 default=['estimatedhours', 'hours', 'totalhours'],
+                                 doc="fields to exclude from AutoQuery markup")
     # IContentConverter methods
         for key in field_changes:
             ticket[key] = field_changes[key]['new']
+    def _query_link(self, req, name, value):
+        """return a link to /query with the appropriate name and value"""
+        query = req.href('query', **{name:value})
+        args = self.env.config.get('query', 'default_anonymous_query')
+        if args:
+            query = '%s&%s' % (query, args)
+        return tag.a(value, href=query)
     def _prepare_fields(self, req, ticket):
         context = Context.from_request(req, ticket.resource)
         fields = []
             name = field['name']
             type_ = field['type']
+            # enable a link to custom query for the field
+            if name not in self.unlinked_fields:
+                field['rendered'] = self._query_link(req, name, ticket[name])
             # per field settings
             if name in ('summary', 'reporter', 'description', 'status',
             'attachments': AttachmentModule(self.env).attachment_data(context),
             'action_controls': action_controls,
             'action': selected_action,
-            'change_preview': change_preview
+            'change_preview': change_preview,
+            'reporter_link': self._query_link(req, 'reporter', ticket['reporter']),
+            'owner_link': self._query_link(req, 'owner', ticket['owner'])
     def rendered_changelog_entries(self, req, ticket, when=None):