get field's help in guess_field tls-sprint
authorsylvain.thenault@logilab.fr
Tue, 07 Apr 2009 19:51:11 +0200
branchtls-sprint
changeset 1268 5db94912650b
parent 1267 ea03cdbc9f2e
child 1269 94a5c30575c0
get field's help in guess_field
web/formfields.py
web/test/unittest_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
--- 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)