# HG changeset patch # User sylvain.thenault@logilab.fr # Date 1239126671 -7200 # Node ID 5db94912650b912103361ccbcc37bc7d744f4978 # Parent ea03cdbc9f2e5e9aebe9b1f8cb1fbfc789cc2670 get field's help in guess_field diff -r ea03cdbc9f2e -r 5db94912650b web/formfields.py --- a/web/formfields.py Tue Apr 07 17:19:22 2009 +0200 +++ b/web/formfields.py Tue Apr 07 19:51:11 2009 +0200 @@ -439,6 +439,7 @@ if role == 'subject': targetschema = rschema.objects(eschema)[0] card = rschema.rproperty(eschema, targetschema, 'cardinality')[0] + help = rschema.rproperty(eschema, targetschema, 'description') if rschema.is_final(): if rschema.rproperty(eschema, targetschema, 'internationalizable'): kwargs['internationalizable'] = True @@ -446,8 +447,10 @@ else: targetschema = rschema.subjects(eschema)[0] card = rschema.rproperty(targetschema, eschema, 'cardinality')[1] + help = rschema.rproperty(targetschema, eschema, 'description') kwargs['required'] = card in '1+' kwargs['name'] = rschema.type + kwargs['help'] = help if rschema.is_final(): if skip_meta_attr and rschema in eschema.meta_attributes(): return None diff -r ea03cdbc9f2e -r 5db94912650b web/test/unittest_formfields.py --- a/web/test/unittest_formfields.py Tue Apr 07 17:19:22 2009 +0200 +++ b/web/test/unittest_formfields.py Tue Apr 07 19:51:11 2009 +0200 @@ -28,6 +28,7 @@ synopsis_field = guess_field(Card, schema['synopsis']) self.assertIsInstance(synopsis_field, TextField) self.assertEquals(synopsis_field.required, False) + self.assertEquals(synopsis_field.help, 'an abstract for this card') content_field = guess_field(Card, schema['content']) self.assertIsInstance(content_field, RichTextField) @@ -61,12 +62,14 @@ self.assertIsInstance(in_group_field, RelationField) self.assertEquals(in_group_field.required, True) self.assertEquals(in_group_field.role, 'subject') + self.assertEquals(in_group_field.help, 'groups grant permissions to the user') owned_by_field = guess_field(EUser, schema['owned_by'], 'object') self.assertIsInstance(owned_by_field, RelationField) self.assertEquals(owned_by_field.required, False) self.assertEquals(owned_by_field.role, 'object') + def test_file_fields(self): data_format_field = guess_field(File, schema['data_format']) self.assertEquals(data_format_field, None)