Commits

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                    cmgreen@uab.edu
  * Gruffudd Prys                  cbs201@bangor.ac.uk
  * Mikael Hallendal               micke@imendio.com
+ * Jeff Hammel                    jhammel@openplans.org
  * Stephen Hansen                 shansen@advpubtech.com
  * Laurie Harper                  zodiac@holoweb.net
  * Francois Harvey                fharvey@securiweb.net
  * Rayentray Tappa
  * Alec Thomas                    alec@swapoff.org
  * Jani Tiainen                   redetin@luukku.com
- * Ghassem Tofighi		  tofighi@gmail.com
+ * Ghassem Tofighi                tofighi@gmail.com
  * Zilvinas Valinskas             zilvinas@gemtek.lt
  * Jason Vasquez                  jason@mugfu.com
  * Leslie H. Watter

File trac/ticket/templates/ticket.html

                                     not in ('type', 'owner')]">
             <tr>
               <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}
               </td>
             </tr>
             <tr py:for="row in group(fields, 2, lambda f: f.type != 'textarea')"

File trac/ticket/web_ui.py

 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',
                         'resolution'):
             '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):