--- a/web/widgets.py Fri Feb 20 15:06:59 2009 +0100
+++ b/web/widgets.py Fri Feb 20 15:28:55 2009 +0100
@@ -659,6 +659,7 @@
res.append(u'<a href="javascript:noop()" id="add_newopt"> </a></div>')
return '\n'.join(res)
+
class IntegerWidget(StringWidget):
def __init__(self, vreg, subjschema, rschema, objschema, **kwattrs):
kwattrs['size'] = 5
@@ -668,7 +669,6 @@
def render_example(self, req):
return '23'
-
class FloatWidget(StringWidget):
def __init__(self, vreg, subjschema, rschema, objschema, **kwattrs):
@@ -692,6 +692,7 @@
return [formatstr % value]
return ()
+
class DecimalWidget(StringWidget):
def __init__(self, vreg, subjschema, rschema, objschema, **kwattrs):
kwattrs['size'] = 5
@@ -700,17 +701,25 @@
def render_example(self, req):
return '345.0300'
-
class DateWidget(StringWidget):
format_key = 'ui.date-format'
- monthnames = ("january", "february", "march", "april",
- "may", "june", "july", "august",
- "september", "october", "november", "december")
-
- daynames = ("monday", "tuesday", "wednesday", "thursday",
- "friday", "saturday", "sunday")
+ monthnames = ('january', 'february', 'march', 'april',
+ 'may', 'june', 'july', 'august',
+ 'september', 'october', 'november', 'december')
+ daynames = ('monday', 'tuesday', 'wednesday', 'thursday',
+ 'friday', 'saturday', 'sunday')
+
+ @classmethod
+ def add_localized_infos(cls, req):
+ """inserts JS variables defining localized months and days"""
+ # import here to avoid dependancy from cubicweb-common to simplejson
+ _ = req._
+ monthnames = [_(mname) for mname in cls.monthnames]
+ daynames = [_(dname) for dname in cls.daynames]
+ req.html_headers.define_var('MONTHNAMES', monthnames)
+ req.html_headers.define_var('DAYNAMES', daynames)
def __init__(self, vreg, subjschema, rschema, objschema, **kwattrs):
kwattrs.setdefault('size', 10)
@@ -728,16 +737,6 @@
formatstr = req.property_value(self.format_key)
return now().strftime(formatstr)
- @classmethod
- def add_localized_infos(cls, req):
- """inserts JS variables defining localized months and days"""
- # import here to avoid dependancy from cubicweb-common to simplejson
- _ = req._
- monthnames = [_(mname) for mname in cls.monthnames]
- daynames = [_(dname) for dname in cls.daynames]
- req.html_headers.define_var('MONTHNAMES', monthnames)
- req.html_headers.define_var('DAYNAMES', daynames)
-
def _edit_render(self, entity):
wdg = super(DateWidget, self)._edit_render(entity)
@@ -776,6 +775,11 @@
class DateTimeWidget(DateWidget):
format_key = 'ui.datetime-format'
+
+ def __init__(self, vreg, subjschema, rschema, objschema, **kwattrs):
+ kwattrs['size'] = 16
+ kwattrs['maxlength'] = 16
+ DateWidget.__init__(self, vreg, subjschema, rschema, objschema, **kwattrs)
def render_example(self, req):
formatstr1 = req.property_value('ui.datetime-format')
@@ -786,14 +790,6 @@
}
-
-
- def __init__(self, vreg, subjschema, rschema, objschema, **kwattrs):
- kwattrs['size'] = 16
- kwattrs['maxlength'] = 16
- DateWidget.__init__(self, vreg, subjschema, rschema, objschema, **kwattrs)
-
-
class TimeWidget(StringWidget):
format_key = 'ui.time-format'
def __init__(self, vreg, subjschema, rschema, objschema, **kwattrs):