web/uicfg.py
changeset 4003 b9436fe77c9e
parent 3890 d7a270f50f54
child 4007 91d11fda4aa0
equal deleted inserted replaced
3998:94cc7cad3d2d 4003:b9436fe77c9e
   231         formtype, section = formsection.split('_', 1)
   231         formtype, section = formsection.split('_', 1)
   232         result[formtype] = section
   232         result[formtype] = section
   233     return result
   233     return result
   234 
   234 
   235 def _card_and_comp(sschema, rschema, oschema, role):
   235 def _card_and_comp(sschema, rschema, oschema, role):
       
   236     rdef = rschema.rdef(sschema, oschema)
   236     if role == 'subject':
   237     if role == 'subject':
   237         card = rschema.rproperty(sschema, oschema, 'cardinality')[0]
   238         card = rdef.cardinality[0]
   238         composed = rschema.rproperty(sschema, oschema, 'composite') == 'object'
   239         composed = not rschema.final and rdef.composite == 'object'
   239     else:
   240     else:
   240         card = rschema.rproperty(sschema, oschema, 'cardinality')[1]
   241         card = rdef.cardinality[1]
   241         composed = rschema.rproperty(sschema, oschema, 'composite') == 'subject'
   242         composed = not rschema.final and rdef.composite == 'subject'
   242     return card, composed
   243     return card, composed
   243 
   244 
   244 class AutoformSectionRelationTags(RelationTagsSet):
   245 class AutoformSectionRelationTags(RelationTagsSet):
   245     """autoform relations'section"""
   246     """autoform relations'section"""
   246 
   247 
   354             # check category first, potentially lower cost than checking
   355             # check category first, potentially lower cost than checking
   355             # permission which may imply rql queries
   356             # permission which may imply rql queries
   356             _targetschemas = []
   357             _targetschemas = []
   357             for tschema in targetschemas:
   358             for tschema in targetschemas:
   358                 if not rtags.etype_get(eschema, rschema, role, tschema) in categories:
   359                 if not rtags.etype_get(eschema, rschema, role, tschema) in categories:
   359                         continue
   360                     continue
   360                     rdef = rschema.role_rdef(eschema, tschema, role)
   361                 rdef = rschema.role_rdef(eschema, tschema, role)
   361                     if not ((not strict and rdef.has_local_role(permission)) or
   362                 if not ((not strict and rdef.has_local_role(permission)) or
   362                             rdef.has_perm(entity.req, permission, fromeid=eid)):
   363                         rdef.has_perm(entity.req, permission, fromeid=eid)):
   363                         continue
   364                     continue
   364                     _targetschemas.append(tschema)
   365                 _targetschemas.append(tschema)
   365             if not _targetschemas:
   366             if not _targetschemas:
   366                 continue
   367                 continue
   367             targetschemas = _targetschemas
   368             targetschemas = _targetschemas
   368             if permission is not None:
   369             if permission is not None:
   369                 # tag allowing to hijack the permission machinery when
   370                 # tag allowing to hijack the permission machinery when