Ignore:
Timestamp:
12 May 2011, 01:24:03 (14 years ago)
Author:
uli
Message:

Fix missing implementation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/widgets/datewidget.py

    r6052 r6056  
    2525from datetime import datetime
    2626from zope.formlib.i18n import _
    27 from zope.formlib.interfaces import ConversionError
     27from zope.formlib.interfaces import ConversionError, IDisplayWidget
    2828from zope.formlib.textwidgets import DateWidget, DateDisplayWidget, escape
    29 from zope.formlib.widget import renderElement
     29from zope.formlib.widget import renderElement, CustomWidgetFactory
     30from zope.interface import implements
    3031
    3132class FormattedDateWidget(DateWidget):
     
    5758    """
    5859    date_format = '%Y-%m-%d'
    59 
     60    implements(IDisplayWidget)
     61   
    6062    def __call__(self):
    6163        if self._renderedValueSet():
     
    6870        return renderElement("span", contents=escape(content),
    6971                             cssClass=self.cssClass)
     72
     73#: A dictionary of supported date formats.
     74DATE_FORMATS = {
     75    'iso': ('datepicker', '%Y-%m-%d'),
     76    'le':  ('datepicker-le', '%d/%m/%Y'),
     77    'de':  ('datepicker-de', '%d.%m.%Y'),
     78    'us':  ('datepicker-us', '%m/%d/%Y'),
     79    'iso-year': ('datepicker-year', '%Y-%m-%d'),
     80    'le-year':  ('datepicker-le-year', '%d/%m/%Y'),
     81    'de-year':  ('datepicker-de-year', '%d.%m.%Y'),
     82    'us-year':  ('datepicker-us-year', '%m/%d/%Y'),
     83    }
     84def FriendlyDateWidget(format):
     85    """Get a friendly date input widget for `format`.
     86    """
     87    css_class, date_format = DATE_FORMATS.get(format, DATE_FORMATS['le'])
     88    return CustomWidgetFactory(
     89        FormattedDateWidget,
     90        cssClass=css_class,
     91        date_format=date_format)
     92
     93def FriendlyDateDisplayWidget(format):
     94    """Get a friendly date display widget for `format`.
     95    """
     96    css_class, date_format = DATE_FORMATS.get(format, DATE_FORMATS['le'])
     97    return CustomWidgetFactory(
     98        FormattedDateDisplayWidget,
     99        date_format=date_format)
Note: See TracChangeset for help on using the changeset viewer.