0001-manager-switch-time-selection-to-the-html5-time-inpu.patch
chrono/manager/widgets.py | ||
---|---|---|
130 | 130 |
super(DateTimeWidget, self).__init__(attrs, options, usel10n) |
131 | 131 | |
132 | 132 | |
133 |
class TimeWidget(PickerWidgetMixin, TimeInput):
|
|
133 |
class TimeWidget(TimeInput): |
|
134 | 134 |
""" |
135 |
TimeWidget is the corresponding widget for Time field, it renders only the time section of |
|
136 |
datetime picker. |
|
135 |
TimeWidget is a widget for time selection, it uses the HTML5 "time" |
|
136 |
input type and has a bit of a fallback mechanism with the presence |
|
137 |
of the pattern attribute in case a standard text input is used. |
|
137 | 138 |
""" |
139 |
input_type = 'time' |
|
138 | 140 | |
139 |
format_name = 'TIME_INPUT_FORMATS' |
|
140 |
glyphicon = 'glyphicon-time' |
|
141 | ||
142 |
def __init__(self, attrs=None, options=None, usel10n=None): |
|
143 | ||
144 |
if options is None: |
|
145 |
options = {} |
|
146 | ||
147 |
# Set the default options to show only the timepicker object |
|
148 |
options['startView'] = options.get('startView', 1) |
|
149 |
options['minView'] = options.get('minView', 0) |
|
150 |
options['maxView'] = options.get('maxView', 1) |
|
151 |
options['format'] = options.get('format', 'hh:ii') |
|
152 | ||
153 |
super(TimeWidget, self).__init__(attrs, options, usel10n) |
|
141 |
def __init__(self, **kwargs): |
|
142 |
super(TimeWidget, self).__init__(**kwargs) |
|
143 |
self.attrs['step'] = '300' # 5 minutes |
|
144 |
self.attrs['pattern'] = '[0-9]{2}:[0-9]{2}' |
|
154 | 145 | |
155 | 146 | |
156 | 147 |
class WeekdaysWidget(SelectMultiple): |
157 |
- |