web/views/autoform.py
changeset 10637 a8b33789b982
parent 10634 06a43f727601
child 10646 45671fb330f5
equal deleted inserted replaced
10636:a9e9daf77598 10637:a8b33789b982
   950                     rschema, role, tschema, ttype))
   950                     rschema, role, tschema, ttype))
   951 
   951 
   952     def check_inlined_rdef_permissions(self, rschema, role, tschema, ttype):
   952     def check_inlined_rdef_permissions(self, rschema, role, tschema, ttype):
   953         """return true if permissions are granted on the inlined object and
   953         """return true if permissions are granted on the inlined object and
   954         relation"""
   954         relation"""
       
   955         if not tschema.has_perm(self._cw, 'add'):
       
   956             return False
   955         entity = self.edited_entity
   957         entity = self.edited_entity
   956         rdef = entity.e_schema.rdef(rschema, role, ttype)
   958         rdef = entity.e_schema.rdef(rschema, role, ttype)
   957         if entity.has_eid():
   959         if entity.has_eid():
   958             if role == 'subject':
   960             if role == 'subject':
   959                 rdefkwargs = {'fromeid': entity.eid}
   961                 rdefkwargs = {'fromeid': entity.eid}
   960             else:
   962             else:
   961                 rdefkwargs = {'toeid': entity.eid}
   963                 rdefkwargs = {'toeid': entity.eid}
   962         else:
   964             return rdef.has_perm(self._cw, 'add', **rdefkwargs)
   963             rdefkwargs = {}
   965         return rdef.may_have_permission('add', self._cw)
   964         return (tschema.has_perm(self._cw, 'add')
       
   965                 and rdef.has_perm(self._cw, 'add', **rdefkwargs))
       
   966 
   966 
   967 
   967 
   968     def should_hide_add_new_relation_link(self, rschema, card):
   968     def should_hide_add_new_relation_link(self, rschema, card):
   969         """return true if once an inlined creation form is added, the 'add new'
   969         """return true if once an inlined creation form is added, the 'add new'
   970         link should be hidden
   970         link should be hidden