web/views/autoform.py
branchtls-sprint
changeset 1540 996355824825
parent 1539 b0d583d30508
child 1560 7dd2a81b8bc8
equal deleted inserted replaced
1539:b0d583d30508 1540:996355824825
    93         for rschema, targetschemas, role in eschema.relation_definitions(True):
    93         for rschema, targetschemas, role in eschema.relation_definitions(True):
    94             # check category first, potentially lower cost than checking
    94             # check category first, potentially lower cost than checking
    95             # permission which may imply rql queries
    95             # permission which may imply rql queries
    96             if categories is not None:
    96             if categories is not None:
    97                 targetschemas = [tschema for tschema in targetschemas
    97                 targetschemas = [tschema for tschema in targetschemas
    98                                  if rtags.etype_rtag(eschema, rschema, role, tschema) in categories]
    98                                  if rtags.etype_get(eschema, rschema, role, tschema) in categories]
    99                 if not targetschemas:
    99                 if not targetschemas:
   100                     continue
   100                     continue
   101             if permission is not None:
   101             if permission is not None:
   102                 # tag allowing to hijack the permission machinery when
   102                 # tag allowing to hijack the permission machinery when
   103                 # permission is not verifiable until the entity is actually
   103                 # permission is not verifiable until the entity is actually
   104                 # created...
   104                 # created...
   105                 if eid is None and '%s_on_new' % permission in permsoverrides.etype_rtags(eschema, rschema, role):
   105                 if eid is None and '%s_on_new' % permission in permsoverrides.etype_get(eschema, rschema, role):
   106                     yield (rschema, targetschemas, role)
   106                     yield (rschema, targetschemas, role)
   107                     continue
   107                     continue
   108                 if rschema.is_final():
   108                 if rschema.is_final():
   109                     if not rschema.has_perm(entity.req, permission, eid):
   109                     if not rschema.has_perm(entity.req, permission, eid):
   110                         continue
   110                         continue
   159             return super(AutomaticEntityForm, cls_or_self).field_by_name(name, role)
   159             return super(AutomaticEntityForm, cls_or_self).field_by_name(name, role)
   160         except FieldNotFound: # XXX should raise more explicit exception
   160         except FieldNotFound: # XXX should raise more explicit exception
   161             if eschema is None or not name in cls_or_self.schema:
   161             if eschema is None or not name in cls_or_self.schema:
   162                 raise
   162                 raise
   163             rschema = cls_or_self.schema.rschema(name)
   163             rschema = cls_or_self.schema.rschema(name)
   164             fieldcls = cls_or_self.rfields.etype_rtag(eschema, rschema, role)
   164             fieldcls = cls_or_self.rfields.etype_get(eschema, rschema, role)
   165             if fieldcls:
   165             if fieldcls:
   166                 return fieldcls(name=name, role=role, eidparam=True)
   166                 return fieldcls(name=name, role=role, eidparam=True)
   167             widget = cls_or_self.rwidgets.etype_rtag(eschema, rschema, role)
   167             widget = cls_or_self.rwidgets.etype_get(eschema, rschema, role)
   168             if widget:
   168             if widget:
   169                 field = guess_field(eschema, rschema, role,
   169                 field = guess_field(eschema, rschema, role,
   170                                     eidparam=True, widget=widget)
   170                                     eidparam=True, widget=widget)
   171             else:
   171             else:
   172                 field = guess_field(eschema, rschema, role, eidparam=True)
   172                 field = guess_field(eschema, rschema, role, eidparam=True)
   304 
   304 
   305     def should_inline_relation_form(self, rschema, targettype, role):
   305     def should_inline_relation_form(self, rschema, targettype, role):
   306         """return true if the given relation with entity has role and a
   306         """return true if the given relation with entity has role and a
   307         targettype target should be inlined
   307         targettype target should be inlined
   308         """
   308         """
   309         return self.rinlined.etype_rtag(self.edited_entity.id, rschema, role, targettype)
   309         return self.rinlined.etype_get(self.edited_entity.id, rschema, role, targettype)
   310 
   310 
   311     def should_display_inline_creation_form(self, rschema, existant, card):
   311     def should_display_inline_creation_form(self, rschema, existant, card):
   312         """return true if a creation form should be inlined
   312         """return true if a creation form should be inlined
   313 
   313 
   314         by default true if there is no related entity and we need at least one
   314         by default true if there is no related entity and we need at least one