Skip to content

Commit

Permalink
Merge pull request #13 from 4teamwork/jin_accessibility
Browse files Browse the repository at this point in the history
Accessibility cleanup
  • Loading branch information
maethu committed Feb 22, 2013
2 parents f2a75b0 + f4cf23e commit 33675af
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
7 changes: 6 additions & 1 deletion ftw/table/helper.py
Expand Up @@ -185,7 +185,12 @@ def linked(item, value, show_icon=True, attrs=None, icon_only=False):
if callable(icon):
icon = icon()

img = u'<img src="%s/%s"/>' % (portal_url(), icon)
title = item.Title
if callable(title):
title = title()

img = u'<img src="%s/%s" alt="%s"/>' % (
portal_url(), icon, title.decode('utf8'))
if not icon:
attrs['class'].append(
'contenttype-%s' %
Expand Down
9 changes: 5 additions & 4 deletions ftw/table/tests/test_helper.py
Expand Up @@ -90,8 +90,8 @@ def test_link_with_icon(self):
self.assertEqual(
wrapped(self.item, self.item.Title),
u'<span class="linkWrapper"><a href="http://path/to/portal">'
u'<img src="/path/to/portal/icon.gif"/>the &lt;&quot;escaped'
u'&quot;&gt; Title</a></span>')
u'<img src="/path/to/portal/icon.gif" alt="the <"escaped"> Title"/>'
u'the &lt;&quot;escaped&quot;&gt; Title</a></span>')

self.assertEqual(wrapped(self.item, self.item.Title),
wrapped(self.obj, self.obj.Title()))
Expand Down Expand Up @@ -155,7 +155,7 @@ def test_link_icon_only(self):
self.assertEqual(
wrapped(self.item, self.item.Title),
u'<span class="linkWrapper"><a href="http://path/to/portal">'
u'<img src="/path/to/portal/icon.gif"/>'
u'<img src="/path/to/portal/icon.gif" alt="the <"escaped"> Title"/>'
u'</a></span>')

self.assertEqual(wrapped(self.item, self.item.Title),
Expand Down Expand Up @@ -341,7 +341,8 @@ def test_linked(self):
self.assertEqual(
linked(self.item, self.item.Title),
u'<span class="linkWrapper"><a href="http://path/to/portal">'
'<img src="/path/to/portal/icon.gif"/>the &lt;&quot;escaped&quot;&gt; Title</a></span>')
u'<img src="/path/to/portal/icon.gif" alt="the <"escaped"> Title"/>'
u'the &lt;&quot;escaped&quot;&gt; Title</a></span>')

# With a brain and without icon
self.assertEqual(
Expand Down

0 comments on commit 33675af

Please sign in to comment.