web/views/editforms.py
changeset 4083 3b285889b8e9
parent 4082 c7117119e215
child 4160 3fbdeef9a610
equal deleted inserted replaced
4082:c7117119e215 4083:3b285889b8e9
   212 
   212 
   213     def _compute_best_vid(self, eschema, rschema, role):
   213     def _compute_best_vid(self, eschema, rschema, role):
   214         dispctrl = _pvdc.etype_get(eschema, rschema, role)
   214         dispctrl = _pvdc.etype_get(eschema, rschema, role)
   215         if dispctrl.get('rvid'):
   215         if dispctrl.get('rvid'):
   216             return dispctrl['rvid']
   216             return dispctrl['rvid']
   217         if eschema.cardinality(rschema, role) in '+*':
   217         if eschema.rdef(rschema, role).role_cardinality(role) in '+*':
   218             return self._many_rvid
   218             return self._many_rvid
   219         return self._one_rvid
   219         return self._one_rvid
   220 
   220 
   221     def _build_landing_zone(self, lzone):
   221     def _build_landing_zone(self, lzone):
   222         return lzone or self._defaultlandingzone % {
   222         return lzone or self._defaultlandingzone % {
   278         # XXX check autoform_section. what if 'generic'?
   278         # XXX check autoform_section. what if 'generic'?
   279         dispctrl = _pvdc.etype_get(eschema, rtype, role)
   279         dispctrl = _pvdc.etype_get(eschema, rtype, role)
   280         vid = dispctrl.get('vid', 'reledit')
   280         vid = dispctrl.get('vid', 'reledit')
   281         if vid != 'reledit': # reledit explicitly disabled
   281         if vid != 'reledit': # reledit explicitly disabled
   282             return False
   282             return False
   283         if eschema.role_rproperty(role, rschema, 'composite') == role:
   283         if eschema.rdef(rschema, role).composite == role:
   284             return False
   284             return False
   285         return super(AutoClickAndEditFormView, self).should_edit_relation(
   285         return super(AutoClickAndEditFormView, self).should_edit_relation(
   286             entity, rschema, role, rvid)
   286             entity, rschema, role, rvid)
   287 
   287 
   288     def _build_form(self, entity, rtype, role, formid, default, reload, lzone,
   288     def _build_form(self, entity, rtype, role, formid, default, reload, lzone,
   558     _select_attrs = InlineEntityEditionFormView._select_attrs + ('etype',)
   558     _select_attrs = InlineEntityEditionFormView._select_attrs + ('etype',)
   559 
   559 
   560     @property
   560     @property
   561     def removejs(self):
   561     def removejs(self):
   562         entity = self._entity()
   562         entity = self._entity()
   563         card = entity.e_schema.role_rproperty(neg_role(self.role), self.rtype, 'cardinality')
   563         card = entity.e_schema.rdef(self.rtype, neg_role(self.role)).role_cardinality(self.role)
   564         card = card[self.role == 'object']
       
   565         # when one is adding an inline entity for a relation of a single card,
   564         # when one is adding an inline entity for a relation of a single card,
   566         # the 'add a new xxx' link disappears. If the user then cancel the addition,
   565         # the 'add a new xxx' link disappears. If the user then cancel the addition,
   567         # we have to make this link appears back. This is done by giving add new link
   566         # we have to make this link appears back. This is done by giving add new link
   568         # id to removeInlineForm.
   567         # id to removeInlineForm.
   569         if card not in '?1':
   568         if card not in '?1':