[web/views] fix bad html in deleteconf with show_composite=True
On an entity with no composite an additional item "None" was displayed.
--- a/cubicweb/web/test/unittest_views_editforms.py Thu Mar 23 12:09:59 2017 +0100
+++ b/cubicweb/web/test/unittest_views_editforms.py Tue Mar 07 13:13:23 2017 +0100
@@ -294,6 +294,14 @@
req.find('Directory', name='child1').one().eid)
self.assertIn(expected, source)
+ # No composite entities
+ rset = req.execute('Directory X WHERE X name "dtest4"')
+ source = self.view('deleteconf', rset,
+ template=None, req=req).source.decode('utf-8')
+ expected = ('<li><a href="http://testing.fr/cubicweb/directory/%s">'
+ 'dtest4</a></li>') % (d4.eid,)
+ self.assertIn(expected, source)
+
def test_automatic_edition_formview(self):
with self.admin_access.web_request() as req:
rset = req.execute('CWUser X')
--- a/cubicweb/web/views/editforms.py Thu Mar 23 12:09:59 2017 +0100
+++ b/cubicweb/web/views/editforms.py Tue Mar 07 13:13:23 2017 +0100
@@ -123,7 +123,8 @@
content = tags.a(centity.view('textoutofcontext'),
href=centity.absolute_url())
else:
- w(u'<li class="last">%s</li></ul>' % content)
+ if content is not None:
+ w(u'<li class="last">%s</li></ul>' % content)
w(u'</li>\n')
w(u'</ul>\n')
form.render(w=self.w)