merge and add missing import in schema.py stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 23 Jun 2009 13:46:18 +0200
branchstable
changeset 2147 476a75ede2cc
parent 2143 d4c2fb633062 (current diff)
parent 2146 6645e18e8c93 (diff)
child 2148 2b2b9626a98f
child 2150 746c5e6acd38
merge and add missing import in schema.py
schema.py
web/test/unittest_form.py
--- a/schema.py	Tue Jun 23 13:34:28 2009 +0200
+++ b/schema.py	Tue Jun 23 13:46:18 2009 +0200
@@ -9,6 +9,7 @@
 _ = unicode
 
 import re
+from os.path import join
 from logging import getLogger
 from warnings import warn
 
--- a/web/formfields.py	Tue Jun 23 13:34:28 2009 +0200
+++ b/web/formfields.py	Tue Jun 23 13:46:18 2009 +0200
@@ -406,6 +406,9 @@
             name=name, widget=HiddenInput, eidparam=True)
         self.visible_field = visible_field
 
+    def format_single_value(self, req, value):
+        return self.visible_field.format_single_value(req, value)
+
 
 class RelationField(Field):
     def __init__(self, **kwargs):
--- a/web/test/unittest_form.py	Tue Jun 23 13:34:28 2009 +0200
+++ b/web/test/unittest_form.py	Tue Jun 23 13:46:18 2009 +0200
@@ -6,6 +6,8 @@
 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
 """
 
+from xml.etree.ElementTree import fromstring
+
 from logilab.common.testlib import unittest_main, mock_object
 
 from cubicweb import Binary
@@ -13,7 +15,7 @@
 from cubicweb.web.formfields import (IntField, StringField, RichTextField,
                                      DateTimeField, DateTimePicker,
                                      FileField, EditableFileField)
-from cubicweb.web.formwidgets import PasswordInput
+from cubicweb.web.formwidgets import PasswordInput, Input
 from cubicweb.web.views.forms import EntityFieldsForm, FieldsForm
 from cubicweb.web.views.workflow import ChangeStateForm
 from cubicweb.web.views.formrenderers import FormRenderer
@@ -210,5 +212,13 @@
 <span class="emphasis">confirm password</span>''' % {'eid': self.entity.eid})
 
 
+    def test_datefield(self):
+        class DFForm(EntityFieldsForm):
+            creation_date = DateTimeField(widget=Input)
+        form = DFForm(self.req, entity=self.entity)
+        init, cur = (fromstring(self._render_entity_field(attr, form)).get('value')
+                     for attr in ('edits-creation_date', 'creation_date'))
+        self.assertEquals(init, cur)
+
 if __name__ == '__main__':
     unittest_main()