equal
deleted
inserted
replaced
5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
6 """ |
6 """ |
7 __docformat__ = "restructuredtext en" |
7 __docformat__ = "restructuredtext en" |
8 |
8 |
9 from warnings import warn |
9 from warnings import warn |
|
10 from datetime import date, datetime |
|
11 |
10 from simplejson import dumps |
12 from simplejson import dumps |
11 from mx.DateTime import today, now |
|
12 |
13 |
13 from logilab.common.compat import any |
14 from logilab.common.compat import any |
14 from logilab.mtconverter import html_escape |
15 from logilab.mtconverter import html_escape |
15 |
16 |
16 from yams.constraints import SizeConstraint, StaticVocabularyConstraint |
17 from yams.constraints import SizeConstraint, StaticVocabularyConstraint |
410 req = form.req |
411 req = form.req |
411 value = form.context[field]['rawvalue'] |
412 value = form.context[field]['rawvalue'] |
412 inputid = form.context[field]['id'] |
413 inputid = form.context[field]['id'] |
413 helperid = '%shelper' % inputid |
414 helperid = '%shelper' % inputid |
414 if not value: |
415 if not value: |
415 value = today() |
416 value = date.today() |
416 year, month = value.year, value.month |
417 year, month = value.year, value.month |
417 onclick = "toggleCalendar('%s', '%s', %s, %s);" % ( |
418 onclick = "toggleCalendar('%s', '%s', %s, %s);" % ( |
418 helperid, inputid, year, month) |
419 helperid, inputid, year, month) |
419 return (u"""<a onclick="toggleCalendar('%s', '%s', %s, %s);" class="calhelper"> |
420 return (u"""<a onclick="toggleCalendar('%s', '%s', %s, %s);" class="calhelper"> |
420 <img src="%s" title="%s" alt="" /></a><div class="calpopup hidden" id="%s"></div>""" |
421 <img src="%s" title="%s" alt="" /></a><div class="calpopup hidden" id="%s"></div>""" |
641 |
642 |
642 def format_single_value(self, req, value): |
643 def format_single_value(self, req, value): |
643 return value and ustrftime(value, req.property_value(self.format_prop)) or u'' |
644 return value and ustrftime(value, req.property_value(self.format_prop)) or u'' |
644 |
645 |
645 def render_example(self, req): |
646 def render_example(self, req): |
646 return self.format_value(req, now()) |
647 return self.format_value(req, datetime.now()) |
647 |
648 |
648 |
649 |
649 class DateTimeField(DateField): |
650 class DateTimeField(DateField): |
650 format_prop = 'ui.datetime-format' |
651 format_prop = 'ui.datetime-format' |
651 |
652 |