- Timestamp:
- 13 Apr 2012, 21:44:00 (13 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser.py
r8149 r8150 382 382 form_fields = grok.AutoFields(IApplicant).omit( 383 383 'locked', 'course_admitted', 'password') 384 form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le')385 384 label = _('Applicant') 386 385 pnav = 3 -
main/waeup.kofa/trunk/src/waeup/kofa/utils/overrides.zcml
r8148 r8150 25 25 /> 26 26 27 <adapter 28 for="waeup.kofa.schema.interfaces.IFormattedDate 29 zope.publisher.interfaces.browser.IBrowserRequest" 30 provides="zope.formlib.interfaces.IDisplayWidget" 31 factory="waeup.kofa.widgets.datewidget.FormattedDateDisplayWidget" 32 permission="zope.Public" 33 /> 34 27 35 </configure> -
main/waeup.kofa/trunk/src/waeup/kofa/widgets/datewidget.py
r8147 r8150 92 92 self.date_format = getattr(context, 'date_format', self.date_format) 93 93 self.show_year = getattr(context, 'show_year', self.show_year) 94 self.cssClass = FORMATS_BY_VALUE.get(( 95 self.date_format, self.show_year), self.cssClass) 94 # add css class determined by date_format and show_year 95 css_cls = FORMATS_BY_VALUE.get((self.date_format, self.show_year), '') 96 self.cssClass = ' '.join([self.cssClass, css_cls]).strip() 96 97 return super(FormattedDateWidget, self).__init__( 97 98 context, request, *args, **kw) … … 122 123 return value 123 124 125 124 126 class FormattedDateDisplayWidget(DateDisplayWidget): 125 127 """A date widget that supports different (and _explicit_) date formats. … … 128 130 """ 129 131 date_format = '%Y-%m-%d' 132 show_year = False 133 130 134 implements(IDisplayWidget) 135 136 def __init__(self, context, request, *args, **kw): 137 # try to grab date_format and show_year from bound schema field. 138 self.date_format = getattr(context, 'date_format', self.date_format) 139 self.show_year = getattr(context, 'show_year', self.show_year) 140 return super(FormattedDateDisplayWidget, self).__init__( 141 context, request, *args, **kw) 131 142 132 143 def __call__(self):
Note: See TracChangeset for help on using the changeset viewer.