[forms] simplify this test
authorAurelien Campeas <aurelien.campeas@logilab.fr>
Wed, 11 Feb 2009 14:43:55 +0100
changeset 579 77779cca6be6
parent 578 86628c564144
child 580 b453a6a1c3d1
[forms] simplify this test
web/views/baseforms.py
--- a/web/views/baseforms.py	Wed Feb 11 14:37:06 2009 +0100
+++ b/web/views/baseforms.py	Wed Feb 11 14:43:55 2009 +0100
@@ -392,10 +392,8 @@
                 if rschema != 'eid']
     
     def relations_form(self, entity, kwargs):
-        pendings = list(self.restore_pending_inserts(entity))
-        relations_table = list(self.relations_table(entity))
         srels_by_cat = entity.srelations_by_category(('generic', 'metadata'), 'add')
-        if not pendings and not relations_table and not srels_by_cat:
+        if not srels_by_cat:
             return u''
         req = self.req
         _ = self.req._
@@ -406,7 +404,7 @@
         w(u'<fieldset class="subentity">')
         w(u'<legend class="iformTitle">%s</legend>' % label)
         w(u'<table id="relatedEntities">')
-        for row in relations_table:
+        for row in self.relations_table(entity):
             # already linked entities
             if row[2]:
                 w(u'<tr><th class="labelCol">%s</th>' % row[0].display_name(req, row[1]))
@@ -420,6 +418,7 @@
                 w(u'</ul>')
                 w(u'</td>')
                 w(u'</tr>')
+        pendings = list(self.restore_pending_inserts(entity))
         if not pendings:
             w(u'<tr><th>&nbsp;</th><td>&nbsp;</td></tr>')
         else: