equal
deleted
inserted
replaced
733 |
733 |
734 def current_values(self, entity): |
734 def current_values(self, entity): |
735 values = entity.attribute_values(self.name) |
735 values = entity.attribute_values(self.name) |
736 if values and hasattr(values[0], 'strftime'): |
736 if values and hasattr(values[0], 'strftime'): |
737 formatstr = entity.req.property_value(self.format_key) |
737 formatstr = entity.req.property_value(self.format_key) |
738 return [values[0].strftime(formatstr)] |
738 return [values[0].strftime(str(formatstr))] |
739 return values |
739 return values |
740 |
740 |
741 def render_example(self, req): |
741 def render_example(self, req): |
742 formatstr = req.property_value(self.format_key) |
742 formatstr = req.property_value(self.format_key) |
743 return datetime.now().strftime(formatstr) |
743 return datetime.now().strftime(str(formatstr)) |
744 |
744 |
745 |
745 |
746 def _edit_render(self, entity): |
746 def _edit_render(self, entity): |
747 wdg = super(DateWidget, self)._edit_render(entity) |
747 wdg = super(DateWidget, self)._edit_render(entity) |
748 cal_button = self.render_calendar_popup(entity) |
748 cal_button = self.render_calendar_popup(entity) |
757 help.append('<span>%s</span>' % req._(descr)) |
757 help.append('<span>%s</span>' % req._(descr)) |
758 example = self.render_example(req) |
758 example = self.render_example(req) |
759 if example: |
759 if example: |
760 help.append('<span>(%s: %s)</span>' |
760 help.append('<span>(%s: %s)</span>' |
761 % (req._('sample format'), example)) |
761 % (req._('sample format'), example)) |
762 help.append(u'</div>') |
762 help.append(u'</div>') |
763 return u' '.join(help) |
763 return u' '.join(help) |
764 |
764 |
765 def render_calendar_popup(self, entity): |
765 def render_calendar_popup(self, entity): |
766 """calendar popup widget""" |
766 """calendar popup widget""" |
767 req = entity.req |
767 req = entity.req |
789 |
789 |
790 def render_example(self, req): |
790 def render_example(self, req): |
791 formatstr1 = req.property_value('ui.datetime-format') |
791 formatstr1 = req.property_value('ui.datetime-format') |
792 formatstr2 = req.property_value('ui.date-format') |
792 formatstr2 = req.property_value('ui.date-format') |
793 return req._('%(fmt1)s, or without time: %(fmt2)s') % { |
793 return req._('%(fmt1)s, or without time: %(fmt2)s') % { |
794 'fmt1': datetime.now().strftime(formatstr1), |
794 'fmt1': datetime.now().strftime(str(formatstr1)), |
795 'fmt2': datetime.now().strftime(formatstr2), |
795 'fmt2': datetime.now().strftime(str(formatstr2)), |
796 } |
796 } |
797 |
797 |
798 |
798 |
799 class TimeWidget(StringWidget): |
799 class TimeWidget(StringWidget): |
800 format_key = 'ui.time-format' |
800 format_key = 'ui.time-format' |