equal
deleted
inserted
replaced
138 called. |
138 called. |
139 """ |
139 """ |
140 try: |
140 try: |
141 return super(AutomaticEntityForm, cls_or_self).field_by_name(name, role) |
141 return super(AutomaticEntityForm, cls_or_self).field_by_name(name, role) |
142 except form.FieldNotFound: |
142 except form.FieldNotFound: |
143 if eschema is None or not name in cls_or_self.schema: |
143 if eschema is None or not name in cls_or_self._cw.schema: |
144 raise |
144 raise |
145 rschema = cls_or_self.schema.rschema(name) |
145 rschema = cls_or_self._cw.schema.rschema(name) |
146 # XXX use a sample target type. Document this. |
146 # XXX use a sample target type. Document this. |
147 tschemas = rschema.targets(eschema, role) |
147 tschemas = rschema.targets(eschema, role) |
148 fieldcls = cls_or_self.rfields.etype_get(eschema, rschema, role, |
148 fieldcls = cls_or_self.rfields.etype_get(eschema, rschema, role, |
149 tschemas[0]) |
149 tschemas[0]) |
150 kwargs = cls_or_self.rfields_kwargs.etype_get(eschema, rschema, |
150 kwargs = cls_or_self.rfields_kwargs.etype_get(eschema, rschema, |
209 # inlined forms don't handle multiple target types |
209 # inlined forms don't handle multiple target types |
210 if len(targettypes) != 1: |
210 if len(targettypes) != 1: |
211 continue |
211 continue |
212 targettype = targettypes[0] |
212 targettype = targettypes[0] |
213 if self.should_inline_relation_form(rschema, targettype, role): |
213 if self.should_inline_relation_form(rschema, targettype, role): |
214 entity = self.vreg['etypes'].etype_class(targettype)(self._cw) |
214 entity = self._cw.vreg['etypes'].etype_class(targettype)(self._cw) |
215 subform = self.vreg['forms'].select('edition', self._cw, entity=entity) |
215 subform = self._cw.vreg['forms'].select('edition', self._cw, entity=entity) |
216 if subform.form_needs_multipart: |
216 if subform.form_needs_multipart: |
217 return True |
217 return True |
218 return False |
218 return False |
219 |
219 |
220 def action(self): |
220 def action(self): |
243 |
243 |
244 def inlined_relations(self): |
244 def inlined_relations(self): |
245 """return a list of (relation schema, target schemas, role) matching |
245 """return a list of (relation schema, target schemas, role) matching |
246 given category(ies) and permission |
246 given category(ies) and permission |
247 """ |
247 """ |
248 # we'll need an initialized varmaker if there are some inlined relation |
|
249 self.initialize_varmaker() |
|
250 return self.erelations_by_category(self.edited_entity, True, 'add', |
248 return self.erelations_by_category(self.edited_entity, True, 'add', |
251 self.rinlined) |
249 self.rinlined) |
252 |
250 |
253 def srelations_by_category(self, categories=None, permission=None, |
251 def srelations_by_category(self, categories=None, permission=None, |
254 strict=False): |
252 strict=False): |
327 |
325 |
328 def should_inline_relation_form(self, rschema, targettype, role): |
326 def should_inline_relation_form(self, rschema, targettype, role): |
329 """return true if the given relation with entity has role and a |
327 """return true if the given relation with entity has role and a |
330 targettype target should be inlined |
328 targettype target should be inlined |
331 """ |
329 """ |
332 return self.rinlined.etype_get(self.edited_entity.id, rschema, role, |
330 return self.rinlined.etype_get(self.edited_entity.__regid__, rschema, role, |
333 targettype) |
331 targettype) |
334 |
332 |
335 def display_inline_edition_form(self, w, rschema, targettype, role, |
333 def display_inline_edition_form(self, w, rschema, targettype, role, |
336 i18nctx): |
334 i18nctx): |
337 """display inline forms for already related entities. |
335 """display inline forms for already related entities. |