'''
Created on May 14, 2013

@author: moschlar
'''

from tg import config

import tw2.core as twc
import tw2.bootstrap.forms as twb
import tw2.bootstrap.wysihtml5 as twbw


__all__ = [
    'Wysihtml5',
    'MediumTextField',
    'SmallTextField',
    'CalendarDateTimePicker',
]


class LargeMixin(object):
    css_class = 'span8'


class MediumMixin(object):
    css_class = 'span4'


class SmallMixin(object):
    css_class = 'span2'


class Wysihtml5(LargeMixin, twbw.Wysihtml5):
    rows = 3
    wysihtml5_args = {
        'html': True,
    }


class MediumTextField(MediumMixin, twb.TextField):
    pass


class SmallTextField(SmallMixin, twb.TextField):
    pass


class CalendarDateTimePicker(SmallMixin, twb.CalendarDateTimePicker):

    datetimepicker_args = {
        'weekStart': 1,
        'autoClose': True,
        'todayBtn': True,
        'todayHighlight': True,
        'minuteStep': 15,
    }

    def __init__(self, *args, **kwargs):
        self.date_format = config.D_T_FMT.replace(':%S', '')
        super(CalendarDateTimePicker, self).__init__(*args, **kwargs)

@@ -49,31 +49,8 @@
 ''%0A%0A
-from tg import config%0A%0A
 impo
@@ -890,172 +890,251 @@
     
-def __init__(self, *args, **kwargs):%0A        self.date_format = config.D_T_FMT.replace(':%25S', '')%0A        super(CalendarDateTimePicker, self).__init__(*args, **kwargs)
+@classmethod%0A    def post_define(cls):%0A        from tg import config%0A        try:%0A            # Use configured D_T_FMT without seconds%0A            cls.date_format = config.D_T_FMT.replace(':%25S', '')%0A        except AttributeError:%0A            pass
 %0A

Fix DateTimePicker format string