| CODENOTIFIER | HelpYou are not signed inSign in |
Project: Trac-trunk
Revision: 7499
Author: cmlenz
Date: 26 Aug 2008 12:18:17
Diff at Trac: http://trac.edgewall.org/changeset/7499
Changes: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.
Files:| ... | ...@@ -26,7 +26,7 @@ | |
| 26 | 26 | from genshi.builder import tag |
| 27 | 27 | |
| 28 | 28 | from trac.attachment import AttachmentModule |
| 29 | from trac.config import BoolOption, Option, IntOption, _TRUE_VALUES | |
| 29 | from trac.config import BoolOption, Option, IntOption, ListOption, _TRUE_VALUES | |
| 30 | 30 | from trac.core import * |
| 31 | 31 | from trac.mimeview.api import Mimeview, IContentConverter, Context |
| 32 | 32 | from trac.resource import Resource, get_resource_url, \ |
| ... | ...@@ -124,6 +124,10 @@ | |
| 124 | 124 | If set to 'default', this is equivalent to 'yes' for new environments |
| 125 | 125 | but keeps the old behavior for upgraded environments (i.e. 'no'). |
| 126 | 126 | (''since 0.11'').""") |
| 127 | ||
| 128 | unlinked_fields = ListOption('ticket', 'unlinked_fields', | |
| 129 | default=['estimatedhours', 'hours', 'totalhours'], | |
| 130 | doc="fields to exclude from AutoQuery markup") | |
| 127 | 131 | |
| 128 | 132 | # IContentConverter methods |
| 129 | 133 | |
| ... | ...@@ -1060,6 +1064,14 @@ | |
| 1060 | 1064 | for key in field_changes: |
| 1061 | 1065 | ticket[key] = field_changes[key]['new'] |
| 1062 | 1066 | |
| 1067 | def _query_link(self, req, name, value): | |
| 1068 | """return a link to /query with the appropriate name and value""" | |
| 1069 | query = req.href('query', **{name:value}) | |
| 1070 | args = self.env.config.get('query', 'default_anonymous_query') | |
| 1071 | if args: | |
| 1072 | query = '%s&%s' % (query, args) | |
| 1073 | return tag.a(value, href=query) | |
| 1074 | ||
| 1063 | 1075 | def _prepare_fields(self, req, ticket): |
| 1064 | 1076 | context = Context.from_request(req, ticket.resource) |
| 1065 | 1077 | fields = [] |
| ... | ...@@ -1067,6 +1079,10 @@ | |
| 1067 | 1079 | name = field['name'] |
| 1068 | 1080 | type_ = field['type'] |
| 1069 | 1081 | |
| 1082 | # enable a link to custom query for the field | |
| 1083 | if name not in self.unlinked_fields: | |
| 1084 | field['rendered'] = self._query_link(req, name, ticket[name]) | |
| 1085 | ||
| 1070 | 1086 | # per field settings |
| 1071 | 1087 | if name in ('summary', 'reporter', 'description', 'status', |
| 1072 | 1088 | 'resolution'): |
| ... | ...@@ -1261,7 +1277,9 @@ | |
| 1261 | 1277 | 'attachments': AttachmentModule(self.env).attachment_data(context), |
| 1262 | 1278 | 'action_controls': action_controls, |
| 1263 | 1279 | 'action': selected_action, |
| 1264 | 'change_preview': change_preview | |
| 1280 | 'change_preview': change_preview, | |
| 1281 | 'reporter_link': self._query_link(req, 'reporter', ticket['reporter']), | |
| 1282 | 'owner_link': self._query_link(req, 'owner', ticket['owner']) | |
| 1265 | 1283 | }) |
| 1266 | 1284 | |
| 1267 | 1285 | def rendered_changelog_entries(self, req, ticket, when=None): |
| ... | ...@@ -137,9 +137,9 @@ | |
| 137 | 137 | not in ('type', 'owner')]"> |
| 138 | 138 | <tr> |
| 139 | 139 | <th id="h_reporter">Reported by:</th> |
| 140 | <td headers="h_reporter" class="searchable">${authorinfo(ticket.reporter)}</td> | |
| 140 | <td headers="h_reporter" class="searchable">${reporter_link}</td> | |
| 141 | 141 | <th id="h_owner">Owned by:</th> |
| 142 | <td headers="h_owner">${ticket.owner and authorinfo(ticket.owner) or ''} | |
| 142 | <td headers="h_owner">${owner_link} | |
| 143 | 143 | </td> |
| 144 | 144 | </tr> |
| 145 | 145 | <tr py:for="row in group(fields, 2, lambda f: f.type != 'textarea')" |
| ... | ...@@ -26,6 +26,7 @@ | |
| 26 | 26 | * Chris Green cmgreen@uab.edu |
| 27 | 27 | * Gruffudd Prys cbs201@bangor.ac.uk |
| 28 | 28 | * Mikael Hallendal micke@imendio.com |
| 29 | * Jeff Hammel jhammel@openplans.org | |
| 29 | 30 | * Stephen Hansen shansen@advpubtech.com |
| 30 | 31 | * Laurie Harper zodiac@holoweb.net |
| 31 | 32 | * Francois Harvey fharvey@securiweb.net |
| ... | ...@@ -77,7 +78,7 @@ | |
| 77 | 78 | * Rayentray Tappa |
| 78 | 79 | * Alec Thomas alec@swapoff.org |
| 79 | 80 | * Jani Tiainen redetin@luukku.com |
| 80 | * Ghassem Tofighi tofighi@gmail.com | |
| 81 | * Ghassem Tofighi tofighi@gmail.com | |
| 81 | 82 | * Zilvinas Valinskas zilvinas@gemtek.lt |
| 82 | 83 | * Jason Vasquez jason@mugfu.com |
| 83 | 84 | * Leslie H. Watter |