# HG changeset patch # User Katia Saurfelt # Date 1240480046 -7200 # Node ID 998ff29c33900a2bddbba1f1232d511c3c1b0b5b # Parent d3c9b075ceb770ab3b1ceefb58be2b0536fb4715 related entitied must be computed in _preinit_side_related diff -r d3c9b075ceb7 -r 998ff29c3390 web/views/baseviews.py --- a/web/views/baseviews.py Thu Apr 23 08:05:51 2009 +0200 +++ b/web/views/baseviews.py Thu Apr 23 11:47:26 2009 +0200 @@ -158,7 +158,7 @@ self.render_entity_metadata(entity) # entity's attributes and relations, excluding meta data # if the entity isn't meta itself - boxes = self._preinit_side_related(entity) or siderelations + boxes = self._preinit_side_related(entity, siderelations) if boxes: self.w(u'
') self.w(u'
') @@ -168,7 +168,7 @@ self.content_navigation_components('navcontenttop') if self.main_related_section: self.render_entity_relations(entity, siderelations) - self.w(u'
') + self.w(u'') if boxes: self.w(u'
') # side boxes @@ -244,34 +244,37 @@ continue self._render_related_entities(entity, rschema, value) - def render_entity_relations(self, entity, siderelations): - if hasattr(self, 'get_side_boxes_defs'): - return - eschema = entity.e_schema - maxrelated = self.req.property_value('navigation.related-limit') - for rschema, targetschemas, x in self.iter_relations(entity): - try: - related = entity.related(rschema.type, x, limit=maxrelated+1) - except Unauthorized: - continue - if not related: - continue - if self.is_side_related(rschema, eschema): - siderelations.append((rschema, related, x)) - continue - self._render_related_entities(entity, rschema, related, x) - - def _preinit_side_related(self, entity): + def _preinit_side_related(self, entity, siderelations): self._sideboxes = None + self._related_entities = [] if hasattr(self, 'get_side_boxes_defs'): self._sideboxes = [(label, rset) for label, rset in self.get_side_boxes_defs(entity) if rset] + else: + eschema = entity.e_schema + maxrelated = self.req.property_value('navigation.related-limit') + for rschema, targetschemas, x in self.iter_relations(entity): + try: + related = entity.related(rschema.type, x, limit=maxrelated+1) + except Unauthorized: + continue + if not related: + continue + if self.is_side_related(rschema, eschema): + siderelations.append((rschema, related, x)) + continue + self._related_entities.append((rschema, related, x)) self._boxes_in_context = list(self.vreg.possible_vobjects('boxes', self.req, self.rset, row=self.row, view=self, context='incontext')) - return self._sideboxes or self._boxes_in_context + return self._sideboxes or self._boxes_in_context or self._related_entities or siderelations - + def render_entity_relations(self, entity, siderelations): + if self._related_entities: + for rschema, related, x in self._related_entities: + self._render_related_entities(entity, rschema, related, x) + + def render_side_related(self, entity, siderelations): """display side related relations: non-meta in a first step, meta in a second step @@ -330,8 +333,8 @@ value += '' label = display_name(self.req, rschema.type, role) self.field(label, value, show_label=show_label, w=self.w, tr=False) - - + print '_render', entity + class SideBoxView(EntityView): """side box usually displaying some related entities in a primary view""" id = 'sidebox' @@ -427,7 +430,7 @@ self.w(u'#%s - ' % entity.eid) if entity.modification_date != entity.creation_date: self.w(u'%s ' % _('latest update on')) - self.w(u'%s, ' + self.w(u'%s, ;' % self.format_date(entity.modification_date)) # entities from external source may not have a creation date (eg ldap) if entity.creation_date: @@ -435,7 +438,7 @@ self.w(u'%s' % self.format_date(entity.creation_date)) if entity.creator: - self.w(u' %s ' % _('by')) + self.w(u' %s ' % _('by')) self.w(u'%s' % entity.creator.name()) self.w(u'')