web/views/primary.py
changeset 2234 1fbcf202882d
parent 2181 94ca417b9b07
parent 2217 3a8cee8f8778
child 2293 7ded2a1416e4
equal deleted inserted replaced
2209:2b91abd9f5a4 2234:1fbcf202882d
    12 
    12 
    13 from logilab.mtconverter import html_escape
    13 from logilab.mtconverter import html_escape
    14 
    14 
    15 from cubicweb import Unauthorized
    15 from cubicweb import Unauthorized
    16 from cubicweb.view import EntityView
    16 from cubicweb.view import EntityView
       
    17 from cubicweb.schema import display_name
    17 from cubicweb.web import uicfg
    18 from cubicweb.web import uicfg
    18 
       
    19 
    19 
    20 
    20 
    21 class PrimaryView(EntityView):
    21 class PrimaryView(EntityView):
    22     """the full view of an non final entity"""
    22     """the full view of an non final entity"""
    23     id = 'primary'
    23     id = 'primary'
   117         """default implementation return an empty string"""
   117         """default implementation return an empty string"""
   118         return u''
   118         return u''
   119 
   119 
   120     def render_entity_attributes(self, entity, siderelations=None):
   120     def render_entity_attributes(self, entity, siderelations=None):
   121         for rschema, tschemas, role, dispctrl in self._section_def(entity, 'attributes'):
   121         for rschema, tschemas, role, dispctrl in self._section_def(entity, 'attributes'):
   122             vid =  dispctrl.get('vid', 'reledit')
   122             # don't use reledit as default vid for composite relation
       
   123             if rschema.is_final():
       
   124                 defaultvid = 'reledit'
       
   125             # XXX use entity.e_schema.role_rproperty(role, rschema, 'composite', tschemas[0]) once yams > 0.23.0 is out
       
   126             elif role == 'subject' and \
       
   127                  rschema.rproperty(entity.e_schema, tschemas[0], 'composite'):
       
   128                 defaultvid = 'csv'
       
   129             elif role == 'object' and \
       
   130                  rschema.rproperty(tschemas[0], entity.e_schema, 'composite'):
       
   131                 defaultvid = 'csv'
       
   132             else:
       
   133                 defaultvid = 'reledit'
       
   134             vid =  dispctrl.get('vid', defaultvid)
   123             if rschema.is_final() or vid == 'reledit':
   135             if rschema.is_final() or vid == 'reledit':
   124                 value = entity.view(vid, rtype=rschema.type, role=role)
   136                 value = entity.view(vid, rtype=rschema.type, role=role)
   125             else:
   137             else:
   126                 rset = self._relation_rset(entity, rschema, role, dispctrl)
   138                 rset = self._relation_rset(entity, rschema, role, dispctrl)
   127                 if rset:
   139                 if rset: