# HG changeset patch # User Sylvain Thénault # Date 1252481834 -7200 # Node ID 52b6b8c2ccc57334caa4a72a43f9c2a7daba6209 # Parent 5ce118f809364aa284d6c494c71e1f85a2edc42a [uicfg, autoform] when a relation is inlined, put it in the generated section by default diff -r 5ce118f80936 -r 52b6b8c2ccc5 web/test/unittest_uicfg.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/test/unittest_uicfg.py Wed Sep 09 09:37:14 2009 +0200 @@ -0,0 +1,14 @@ +from cubicweb.devtools.apptest import EnvBasedTC +from cubicweb.web import uicfg + +class UICFGTC(EnvBasedTC): + + def test_autoform_section_inlined(self): + self.assertEquals(uicfg.autoform_is_inlined.etype_get('CWUser', 'use_email', 'subject', 'EmailAddress'), + True) + self.assertEquals(uicfg.autoform_section.etype_get('CWUser', 'use_email', 'subject', 'EmailAddress'), + 'generated') + +if __name__ == '__main__': + from logilab.common.testlib import unittest_main + unittest_main() diff -r 5ce118f80936 -r 52b6b8c2ccc5 web/uicfg.py --- a/web/uicfg.py Tue Sep 08 20:08:10 2009 +0200 +++ b/web/uicfg.py Wed Sep 09 09:37:14 2009 +0200 @@ -166,23 +166,28 @@ def init_autoform_section(rtag, sschema, rschema, oschema, role): if rtag.get(sschema, rschema, oschema, role) is None: - if role == 'subject': - card = rschema.rproperty(sschema, oschema, 'cardinality')[0] - composed = rschema.rproperty(sschema, oschema, 'composite') == 'object' - else: - card = rschema.rproperty(sschema, oschema, 'cardinality')[1] - composed = rschema.rproperty(sschema, oschema, 'composite') == 'subject' - if sschema.is_metadata(rschema): + if autoform_is_inlined.get(sschema, rschema, oschema, role): + section = 'generated' + elif sschema.is_metadata(rschema): section = 'metadata' - elif card in '1+': - if not rschema.is_final() and composed: - section = 'generated' + else: + if role == 'subject': + card = rschema.rproperty(sschema, oschema, 'cardinality')[0] + composed = rschema.rproperty(sschema, oschema, 'composite') == 'object' else: - section = 'primary' - elif rschema.is_final(): - section = 'secondary' - else: - section = 'generic' + card = rschema.rproperty(sschema, oschema, 'cardinality')[1] + composed = rschema.rproperty(sschema, oschema, 'composite') == 'subject' + if card in '1+': + if not rschema.is_final() and composed: + # XXX why? probably because we want it unlined, though this + # is not the case by default + section = 'generated' + else: + section = 'primary' + elif rschema.is_final(): + section = 'secondary' + else: + section = 'generic' rtag.tag_relation((sschema, rschema, oschema, role), section) autoform_section = RelationTags('autoform_section', init_autoform_section, diff -r 5ce118f80936 -r 52b6b8c2ccc5 web/views/autoform.py --- a/web/views/autoform.py Tue Sep 08 20:08:10 2009 +0200 +++ b/web/views/autoform.py Wed Sep 09 09:37:14 2009 +0200 @@ -348,7 +348,6 @@ uicfg.autoform_section.tag_object_of(('*', 'created_by', 'CWUser'), 'generated') uicfg.autoform_section.tag_object_of(('*', 'bookmarked_by', 'CWUser'), 'metadata') uicfg.autoform_section.tag_attribute(('Bookmark', 'path'), 'primary') -uicfg.autoform_section.tag_subject_of(('*', 'use_email', '*'), 'generated') # inlined actually uicfg.autoform_section.tag_subject_of(('*', 'primary_email', '*'), 'generic') uicfg.autoform_field_kwargs.tag_attribute(('RQLExpression', 'expression'),