185 |
185 |
186 def _render_relation(self, rset, dispctrl, defaultvid, showlabel): |
186 def _render_relation(self, rset, dispctrl, defaultvid, showlabel): |
187 self.w(u'<div class="section">') |
187 self.w(u'<div class="section">') |
188 if showlabel: |
188 if showlabel: |
189 self.w(u'<h4>%s</h4>' % self.req._(dispctrl['label'])) |
189 self.w(u'<h4>%s</h4>' % self.req._(dispctrl['label'])) |
190 self.wview(dispctrl.get('vid', defaultvid), rset, dispctrl=dispctrl) |
190 self.wview(dispctrl.get('vid', defaultvid), rset, |
|
191 initargs={'dispctrl': dispctrl}) |
191 self.w(u'</div>') |
192 self.w(u'</div>') |
192 |
193 |
193 def _render_attribute(self, rschema, value, role='subject'): |
194 def _render_attribute(self, rschema, value, role='subject'): |
194 if rschema.final: |
195 if rschema.final: |
195 show_label = self.show_attr_label |
196 show_label = self.show_attr_label |
200 |
201 |
201 |
202 |
202 class RelatedView(EntityView): |
203 class RelatedView(EntityView): |
203 id = 'autolimited' |
204 id = 'autolimited' |
204 |
205 |
205 def call(self, dispctrl=None, **kwargs): |
206 def call(self, **kwargs): |
206 # nb: rset retreived using entity.related with limit + 1 if any |
207 # nb: rset retreived using entity.related with limit + 1 if any |
207 # because of that, we known that rset.printable_rql() will return |
208 # because of that, we known that rset.printable_rql() will return |
208 # rql with no limit set anyway (since it's handled manually) |
209 # rql with no limit set anyway (since it's handled manually) |
209 if dispctrl is not None: |
210 if 'dispctrl' in self.extra_kwargs: |
210 limit = dispctrl.get('limit') |
211 limit = self.extra_kwargs['dispctrl'].get('limit') |
|
212 else: |
|
213 limit = None |
211 # if not too many entities, show them all in a list |
214 # if not too many entities, show them all in a list |
212 if limit is None or self.rset.rowcount <= limit: |
215 if limit is None or self.rset.rowcount <= limit: |
213 if self.rset.rowcount == 1: |
216 if self.rset.rowcount == 1: |
214 self.wview('incontext', self.rset, row=0) |
217 self.wview('incontext', self.rset, row=0) |
215 elif 1 < self.rset.rowcount <= 5: |
218 elif 1 < self.rset.rowcount <= 5: |