web/uicfg.py
changeset 2803 870fa705dfde
parent 2705 30bcdbd92820
child 2806 9d7173656a1a
equal deleted inserted replaced
2802:2251b4aee54a 2803:870fa705dfde
    67 """
    67 """
    68 __docformat__ = "restructuredtext en"
    68 __docformat__ = "restructuredtext en"
    69 
    69 
    70 from cubicweb import neg_role, onevent
    70 from cubicweb import neg_role, onevent
    71 from cubicweb.rtags import (RelationTags, RelationTagsBool,
    71 from cubicweb.rtags import (RelationTags, RelationTagsBool,
    72                             RelationTagsSet, RelationTagsDict)
    72                             RelationTagsSet, RelationTagsDict, register_rtag)
    73 from cubicweb.web import formwidgets
    73 from cubicweb.web import formwidgets
    74 
    74 
    75 
    75 
    76 def card_from_role(card, role):
    76 def card_from_role(card, role):
    77     if role == 'subject':
    77     if role == 'subject':
   149 # * 'application'
   149 # * 'application'
   150 # * 'system'
   150 # * 'system'
   151 # * 'schema'
   151 # * 'schema'
   152 # * 'subobject' (not displayed by default)
   152 # * 'subobject' (not displayed by default)
   153 
   153 
   154 indexview_etype_section = {'EmailAddress': 'subobject',
   154 class InitializableDict(dict):
   155                            'CWUser': 'system',
   155     def __init__(self, *args, **kwargs):
   156                            'CWGroup': 'system',
   156         super(InitializableDict, self).__init__(*args, **kwargs)
   157                            'CWPermission': 'system',
   157         register_rtag(self)
   158                            }
   158 
   159 
   159     def init(schema, check=True):
       
   160         for eschema in schema.entities():
       
   161             if eschema.schema_entity():
       
   162                 uicfg.indexview_etype_section.setdefault(eschema, 'schema')
       
   163             elif eschema.is_subobject(strict=True):
       
   164                 uicfg.indexview_etype_section.setdefault(eschema, 'subobject')
       
   165             else:
       
   166                 uicfg.indexview_etype_section.setdefault(eschema, 'application')
       
   167 
       
   168 indexview_etype_section = InitializableDict(EmailAddress='subobject',
       
   169                                             CWUser='system',
       
   170                                             CWGroup='system',
       
   171                                             CWPermission='system',
       
   172                                             )
   160 
   173 
   161 # autoform.AutomaticEntityForm configuration ##################################
   174 # autoform.AutomaticEntityForm configuration ##################################
   162 
   175 
   163 # relations'section (eg primary/secondary/generic/metadata/generated)
   176 # relations'section (eg primary/secondary/generic/metadata/generated)
   164 
   177