equal
deleted
inserted
replaced
80 |
80 |
81 :attr:`show_rel_label` |
81 :attr:`show_rel_label` |
82 Renders the relation label next to the relation value if set to `True`. |
82 Renders the relation label next to the relation value if set to `True`. |
83 Otherwise, does only display the relation value. |
83 Otherwise, does only display the relation value. |
84 |
84 |
85 :attr:`skip_none` |
|
86 Does not render an attribute value that is None if set to `True`. |
|
87 |
|
88 :attr:`main_related_section` |
85 :attr:`main_related_section` |
89 Renders the relations of the entity if set to `True`. |
86 Renders the relations of the entity if set to `True`. |
90 |
87 |
91 A good practice is for you to identify the content of your entity type for |
88 A good practice is for you to identify the content of your entity type for |
92 which the default rendering does not answer your need so that you can focus |
89 which the default rendering does not answer your need so that you can focus |
97 |
94 |
98 __regid__ = 'primary' |
95 __regid__ = 'primary' |
99 title = _('primary') |
96 title = _('primary') |
100 show_attr_label = True |
97 show_attr_label = True |
101 show_rel_label = True |
98 show_rel_label = True |
102 skip_none = True |
|
103 rsection = uicfg.primaryview_section |
99 rsection = uicfg.primaryview_section |
104 display_ctrl = uicfg.primaryview_display_ctrl |
100 display_ctrl = uicfg.primaryview_display_ctrl |
105 main_related_section = True |
101 main_related_section = True |
106 |
102 |
107 def html_headers(self): |
103 def html_headers(self): |
192 def summary(self, entity): |
188 def summary(self, entity): |
193 """default implementation return an empty string""" |
189 """default implementation return an empty string""" |
194 return u'' |
190 return u'' |
195 |
191 |
196 def render_entity_attributes(self, entity): |
192 def render_entity_attributes(self, entity): |
197 """Renders all attributes and relations in the 'attributes' section. The |
193 """Renders all attributes and relations in the 'attributes' section. |
198 :attr:`skip_none` attribute controls the display of `None` valued |
|
199 attributes. |
|
200 """ |
194 """ |
201 display_attributes = [] |
195 display_attributes = [] |
202 for rschema, _, role, dispctrl in self._section_def(entity, 'attributes'): |
196 for rschema, _, role, dispctrl in self._section_def(entity, 'attributes'): |
203 vid = dispctrl.get('vid', 'reledit') |
197 vid = dispctrl.get('vid', 'reledit') |
204 if rschema.final or vid == 'reledit' or dispctrl.get('rtypevid'): |
198 if rschema.final or vid == 'reledit' or dispctrl.get('rtypevid'): |
208 rset = self._relation_rset(entity, rschema, role, dispctrl) |
202 rset = self._relation_rset(entity, rschema, role, dispctrl) |
209 if rset: |
203 if rset: |
210 value = self._cw.view(vid, rset) |
204 value = self._cw.view(vid, rset) |
211 else: |
205 else: |
212 value = None |
206 value = None |
213 if not self.skip_none or (value is not None and value != ''): |
207 if value is not None and value != '': |
214 display_attributes.append( (rschema, role, dispctrl, value) ) |
208 display_attributes.append( (rschema, role, dispctrl, value) ) |
215 if display_attributes: |
209 if display_attributes: |
216 self.w(u'<table>') |
210 self.w(u'<table>') |
217 for rschema, role, dispctrl, value in display_attributes: |
211 for rschema, role, dispctrl, value in display_attributes: |
218 # pylint: disable=E1101 |
212 # pylint: disable=E1101 |