launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #02988
[Merge] lp:~thumper/launchpad/bugtask-tales-addition into lp:launchpad
Tim Penhey has proposed merging lp:~thumper/launchpad/bugtask-tales-addition into lp:launchpad with lp:~thumper/launchpad/bugtask-repr as a prerequisite.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~thumper/launchpad/bugtask-tales-addition/+merge/53732
In order to specify a title for the fmt:link of a bug task,
the generic base class had to be tweaked.
This is then used to provide a title for the anchor of a bug task.
--
https://code.launchpad.net/~thumper/launchpad/bugtask-tales-addition/+merge/53732
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~thumper/launchpad/bugtask-tales-addition into lp:launchpad.
=== modified file 'lib/lp/app/browser/tales.py'
--- lib/lp/app/browser/tales.py 2011-03-09 20:39:15 +0000
+++ lib/lp/app/browser/tales.py 2011-03-17 02:54:33 +0000
@@ -1312,6 +1312,31 @@
values[key] = cgi.escape(value)
return self._link_summary_template % values
+ def _title_values(self):
+ """Return a dict of values to use for template substitution.
+
+ These values should not be escaped, as this will be performed later.
+ For this reason, only string values should be supplied.
+ """
+ raise NotImplementedError(self._title_values)
+
+ def _make_title(self):
+ """Create a title from _title_template and _title_values().
+
+ This title is for use in fmt:link, which is meant to be used in
+ contexts like lists of items.
+ """
+ title_template = getattr(self, '_title_template', None)
+ if title_template is None:
+ return None
+ values = {}
+ for key, value in self._title_values().iteritems():
+ if value is None:
+ values[key] = ''
+ else:
+ values[key] = cgi.escape(value)
+ return title_template % values
+
def sprite_css(self):
"""Retrieve the icon for the _context, if any.
@@ -1334,12 +1359,18 @@
css = ' class="' + sprite + '"'
summary = self._make_link_summary()
+ title = self._make_title()
+ if title is None:
+ title = ''
+ else:
+ title = ' title="%s"' % title
+
if check_permission(self._link_permission, self._context):
url = self.url(view_name, rootsite)
else:
url = ''
if url:
- return '<a href="%s"%s>%s</a>' % (url, css, summary)
+ return '<a href="%s"%s%s>%s</a>' % (url, css, title, summary)
else:
return summary
@@ -1563,6 +1594,12 @@
class BugTaskFormatterAPI(CustomizableFormatter):
"""Adapter for IBugTask objects to a formatted string."""
+ _title_template = '%(importance)s - %(status)s'
+
+ def _title_values(self):
+ return {'importance': self._context.importance.title,
+ 'status': self._context.status.title}
+
def _make_link_summary(self):
return BugFormatterAPI(self._context.bug)._make_link_summary()
=== modified file 'lib/lp/app/doc/tales.txt'
--- lib/lp/app/doc/tales.txt 2011-03-03 01:13:47 +0000
+++ lib/lp/app/doc/tales.txt 2011-03-17 02:54:33 +0000
@@ -519,8 +519,8 @@
>>> bugtask = bug.bugtasks[0]
>>> test_tales("bugtask/fmt:link", bugtask=bugtask)
- u'<a href=".../firefox/+bug/1" class="sprite bug-low">Bug #1:
- Firefox does not support SVG</a>'
+ u'<a href=".../firefox/+bug/1" class="sprite bug-low"
+ title="Low - New">Bug #1: Firefox does not support SVG</a>'
Bug titles may contain markup (when describing issue regarding markup).
Their titles are escaped so that they display correctly. This also
@@ -530,11 +530,11 @@
>>> login('test@xxxxxxxxxxxxx')
>>> bug.title = "Opps<br/><script>alert('XSS')</script>"
>>> test_tales("bug/fmt:link", bug=getUtility(IBugSet).get(1))
- u'<a href=".../bugs/1" class="sprite bug">Bug #1:
+ u'<a href=".../bugs/1" ...>Bug #1:
Opps<br/><script>alert(\'XSS\')</script></a>'
>>> test_tales("bugtask/fmt:link", bugtask=bugtask)
- u'<a href=".../firefox/+bug/1" class="sprite bug-low">Bug #1:
+ u'<a href=".../firefox/+bug/1" ...>Bug #1:
Opps<br/><script>alert(\'XSS\')</script></a>'
=== modified file 'lib/lp/code/stories/branches/xx-bug-branch-links.txt'
--- lib/lp/code/stories/branches/xx-bug-branch-links.txt 2011-02-27 21:00:44 +0000
+++ lib/lp/code/stories/branches/xx-bug-branch-links.txt 2011-03-17 02:54:33 +0000
@@ -215,6 +215,5 @@
>>> print find_tag_by_id(admin_browser.contents, 'deletion-items')
<ul ...
- <a href="http://bugs.launchpad.dev/product-name.../+bug/..."
- class="sprite bug-undecided">Bug #...: generic-string...</a>...
+ <a href...>Bug #...: generic-string...</a>...