web/box.py
branchtls-sprint
changeset 1696 ee0bea49e0e1
parent 1695 9a9822f3cb6c
child 1885 c2011d238e98
equal deleted inserted replaced
1695:9a9822f3cb6c 1696:ee0bea49e0e1
   171         entity = self.entity(row, col)
   171         entity = self.entity(row, col)
   172         box = SideBoxWidget(display_name(self.req, self.rtype), self.id)
   172         box = SideBoxWidget(display_name(self.req, self.rtype), self.id)
   173         count = self.w_related(box, entity)
   173         count = self.w_related(box, entity)
   174         if count:
   174         if count:
   175             box.append(BoxSeparator())
   175             box.append(BoxSeparator())
   176         self.w_unrelated(box, entity)
   176         if not self.w_unrelated(box, entity):
       
   177             del box.items[-1] # remove useless separator
   177         box.render(self.w)
   178         box.render(self.w)
   178 
   179 
   179     def div_id(self):
   180     def div_id(self):
   180         return self.id
   181         return self.id
   181 
   182 
   199         return len(related)
   200         return len(related)
   200 
   201 
   201     def w_unrelated(self, box, entity):
   202     def w_unrelated(self, box, entity):
   202         """appends unrelated entities to the `box`"""
   203         """appends unrelated entities to the `box`"""
   203         rql = 'SET S %s O WHERE S eid %%(s)s, O eid %%(o)s' % self.rtype
   204         rql = 'SET S %s O WHERE S eid %%(s)s, O eid %%(o)s' % self.rtype
       
   205         i = 0
   204         for etarget in self.unrelated_entities(entity):
   206         for etarget in self.unrelated_entities(entity):
   205             box.append(self.box_item(entity, etarget, rql, u'+'))
   207             box.append(self.box_item(entity, etarget, rql, u'+'))
       
   208             i += 1
       
   209         return i
   206 
   210 
   207     def unrelated_entities(self, entity):
   211     def unrelated_entities(self, entity):
   208         """returns the list of unrelated entities
   212         """returns the list of unrelated entities
   209 
   213 
   210         if etype is not defined on the Box's class, the default
   214         if etype is not defined on the Box's class, the default