web/uicfg.py
branchtls-sprint
changeset 1745 7e7f04d19a98
parent 1742 25a765e756c4
child 1746 67a9b86fd479
equal deleted inserted replaced
1744:056ed8fca8d3 1745:7e7f04d19a98
    69 from cubicweb.rtags import RelationTags, RelationTagsBool, RelationTagsSet
    69 from cubicweb.rtags import RelationTags, RelationTagsBool, RelationTagsSet
    70 from cubicweb.web import formwidgets
    70 from cubicweb.web import formwidgets
    71 
    71 
    72 # primary view configuration ##################################################
    72 # primary view configuration ##################################################
    73 
    73 
       
    74 def dual_role(role):
       
    75     return 'object' if role == 'subject' else 'subject'
       
    76 
    74 def init_primaryview_section(rtag, sschema, rschema, oschema, role):
    77 def init_primaryview_section(rtag, sschema, rschema, oschema, role):
    75     if rtag.get(sschema, rschema, oschema, role) is None:
    78     if rtag.get(sschema, rschema, oschema, role) is None:
       
    79         card = rschema.rproperty(sschema, oschema, 'cardinality')
       
    80         card = card[0] if role == 'subject' else card[1]
       
    81         composed = rschema.rproperty(sschema, oschema, 'composite') == dual_role(role)
    76         if rschema.is_final():
    82         if rschema.is_final():
    77             if rschema.meta or tschema.type in ('Password', 'Bytes'):
    83             if rschema.meta or oschema.type in ('Password', 'Bytes'):
    78                 section = 'hidden'
    84                 section = 'hidden'
    79             else:
    85             else:
    80                 section = 'attributes'
    86                 section = 'attributes'
    81         elif card in '1+':
    87         elif card in '1+':
    82             section = 'attributes'
    88             section = 'attributes'
   109         super(DisplayCtrlRelationTags, self).__init__(*args, **kwargs)
   115         super(DisplayCtrlRelationTags, self).__init__(*args, **kwargs)
   110         self._counter = 0
   116         self._counter = 0
   111 
   117 
   112     def tag_relation(self, key, tag):
   118     def tag_relation(self, key, tag):
   113         assert isinstance(tag, dict)
   119         assert isinstance(tag, dict)
   114         super(RDisplayRelationTags, self).tag_relation(key, tag)
   120         super(DisplayCtrlRelationTags, self).tag_relation(key, tag)
   115         self._counter += 1
   121         self._counter += 1
   116         tag.setdefault('order', self._counter)
   122         tag.setdefault('order', self._counter)
   117 
   123 
   118 
   124 
   119 def init_primaryview_display_ctrl(rtag, sschema, rschema, oschema, role):
   125 def init_primaryview_display_ctrl(rtag, sschema, rschema, oschema, role):