fix tests: has_creator is not mandatory, and img tag requires alt attribute for xhtml compliance
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 05 Oct 2010 14:27:16 +0200
changeset 239 607876043cd6
parent 238 48dd5b221f71
child 240 6a74a6011af7
fix tests: has_creator is not mandatory, and img tag requires alt attribute for xhtml compliance
views/primary.py
--- a/views/primary.py	Fri Oct 01 13:57:39 2010 +0200
+++ b/views/primary.py	Tue Oct 05 14:27:16 2010 +0200
@@ -114,13 +114,16 @@
         pass
 
 def format_microblog(entity):
-    author = entity.has_creator[0]
-    if author.has_avatar:
-        imgurl = author.has_avatar[0].uri
-        ablock = u'<a href="%s"><img src="%s" /></a>' % (author.absolute_url(),
-                                                         xml_escape(imgurl))
+    if entity.has_creator:
+        author = entity.has_creator[0]
+        if author.has_avatar:
+            imgurl = author.has_avatar[0].uri
+            ablock = u'<a href="%s"><img src="%s" alt="avatar"/></a>' % (
+                author.absolute_url(), xml_escape(imgurl))
+        else:
+            ablock = entity.has_creator[0].view('outofcontext')
     else:
-        ablock = entity.has_creator[0].view('outofcontext')
+        ablock = entity.dc_creator()
     if entity.content_format == 'text/html':
         content = entity.content
     else: