def create_datetime_list_sub_form(): """ Patch Products.Formulator.StandardFields so we can add timezone subfield """ sub_form = BasicForm() year = ListField('year', title="Year", required=0, default="", items=create_items(2000, 2010, digits=4), size=1) month = ListField('month', title="Month", required=0, default="", items=create_items(1, 13, digits=2), size=1) day = ListField('day', title="Day", required=0, default="", items=create_items(1, 32, digits=2), size=1) sub_form.add_group("date") sub_form.add_fields([year, month, day], "date") hour = IntegerField('hour', title="Hour", required=0, display_width=2, display_maxwidth=2, max_length=2) minute = IntegerField('minute', title="Minute", required=0, display_width=2, display_maxwidth=2, max_length=2) ampm = ListField('ampm', title="am/pm", required=0, default="am", items=[("am", "am"), ("pm", "pm")], size=1) timezone = ListField('timezone', title="Timezone", required=0, default='GMT', items=gmt_timezones, size=1) sub_form.add_group("time") sub_form.add_fields([hour, minute, ampm, timezone], "time") return sub_form
def create_datetime_list_sub_form(): """ Patch Products.Formulator.StandardFields so we can add timezone subfield """ sub_form = BasicForm() year = ListField('year', title="Year", required=0, default="", items=create_items(2000, 2010, digits=4), size=1) month = ListField('month', title="Month", required=0, default="", items=create_items(1, 13, digits=2), size=1) day = ListField('day', title="Day", required=0, default="", items=create_items(1, 32, digits=2), size=1) sub_form.add_group("date") sub_form.add_fields([year, month, day], "date") hour = IntegerField('hour', title="Hour", required=0, display_width=2, display_maxwidth=2, max_length=2) minute = IntegerField('minute', title="Minute", required=0, display_width=2, display_maxwidth=2, max_length=2) ampm = ListField('ampm', title="am/pm", required=0, default="am", items=[("am","am"), ("pm","pm")], size=1) timezone = ListField('timezone', title = "Timezone", required = 0, default = 'GMT', items = gmt_timezones, size = 1) sub_form.add_group("time") sub_form.add_fields([hour, minute, ampm, timezone], "time") return sub_form
def create_datetime_text_sub_form(): sub_form = BasicForm() year = IntegerField('year', title="Year", required=0, display_width=4, display_maxwidth=4, max_length=4) month = IntegerField('month', title="Month", required=0, display_width=2, display_maxwidth=2, max_length=2) day = IntegerField('day', title="Day", required=0, display_width=2, display_maxwidth=2, max_length=2) sub_form.add_group("date") sub_form.add_fields([year, month, day], "date") hour = IntegerField('hour', title="Hour", required=0, display_width=2, display_maxwidth=2, max_length=2) minute = IntegerField('minute', title="Minute", required=0, display_width=2, display_maxwidth=2, max_length=2) ampm = StringField('ampm', title="am/pm", required=0, display_width=2, display_maxwidth=2, max_length=2) timezone = ListField('timezone', title="Timezone", required=0, default='GMT', items=gmt_timezones, size=1) sub_form.add_fields([hour, minute, ampm, timezone], "time") return sub_form
def create_datetime_text_sub_form(): sub_form = BasicForm() year = IntegerField('year', title="Year", required=0, display_width=4, display_maxwidth=4, max_length=4) month = IntegerField('month', title="Month", required=0, display_width=2, display_maxwidth=2, max_length=2) day = IntegerField('day', title="Day", required=0, display_width=2, display_maxwidth=2, max_length=2) sub_form.add_group("date") sub_form.add_fields([year, month, day], "date") hour = IntegerField('hour', title="Hour", required=0, display_width=2, display_maxwidth=2, max_length=2) minute = IntegerField('minute', title="Minute", required=0, display_width=2, display_maxwidth=2, max_length=2) ampm = StringField('ampm', title="am/pm", required=0, display_width=2, display_maxwidth=2, max_length=2) timezone = ListField('timezone', title = "Timezone", required = 0, default = 'GMT', items = gmt_timezones, size = 1) sub_form.add_fields([hour, minute, ampm, timezone], "time") return sub_form
def create_datetime_number_sub_form(field): sub_form = BasicForm() css_class = field.get_value('css_class') start_datetime = field.get_value('start_datetime') end_datetime = field.get_value('end_datetime') if start_datetime: first_year = start_datetime.year() else: first_year = 0 if end_datetime: last_year = end_datetime.year() else: last_year = 9999 year = IntegerField('year', title="Year", required=0, input_type='number', css_class=css_class, extra='min="%s" max="%s"' % (first_year, last_year), display_width=4, display_maxwidth=4, max_length=4) month = IntegerField('month', title="Month", required=0, input_type='number', css_class=css_class, extra='min="1" max="12"', display_width=2, display_maxwidth=2, max_length=2) day = IntegerField('day', title="Day", required=0, css_class=css_class, input_type='number', extra='min="1" max="31"', display_width=2, display_maxwidth=2, max_length=2) sub_form.add_group("date") sub_form.add_fields([year, month, day], "date") hour = IntegerField('hour', title="Hour", required=0, css_class=css_class, input_type='number', extra='min="0" max="23"', display_width=2, display_maxwidth=2, max_length=2) minute = IntegerField('minute', title="Minute", required=0, css_class=css_class, input_type='number', extra='min="0" max="59"', display_width=2, display_maxwidth=2, max_length=2) ampm = StringField('ampm', title="am/pm", required=0, css_class=css_class, display_width=2, display_maxwidth=2, max_length=2) timezone = ListField('timezone', title="Timezone", required=0, css_class=css_class, default='GMT', items=Widget.gmt_timezones, size=1) sub_form.add_fields([hour, minute, ampm, timezone], "time") return sub_form
def create_datetime_list_sub_form(field): """ Patch Products.Formulator.StandardFields so we can add timezone subfield """ sub_form = BasicForm() css_class = field.get_value('css_class') start_datetime = field.get_value('start_datetime') end_datetime = field.get_value('end_datetime') current_year = DateTime().year() if start_datetime: first_year = start_datetime.year() else: first_year = current_year if end_datetime: last_year = end_datetime.year() + 1 else: last_year = first_year + 11 year = ListField('year', title="Year", required=0, css_class=css_class, default="", items=create_items(first_year, last_year, digits=4), size=1) month = ListField('month', title="Month", required=0, css_class=css_class, default="", items=create_items(1, 13, digits=2), size=1) day = ListField('day', title="Day", required=0, css_class=css_class, default="", items=create_items(1, 32, digits=2), size=1) sub_form.add_group("date") sub_form.add_fields([year, month, day], "date") hour = IntegerField('hour', title="Hour", required=0, css_class=css_class, display_width=2, display_maxwidth=2, max_length=2) minute = IntegerField('minute', title="Minute", required=0, css_class=css_class, display_width=2, display_maxwidth=2, max_length=2) ampm = ListField('ampm', title="am/pm", required=0, css_class=css_class, default="am", items=[("am", "am"), ("pm", "pm")], size=1) timezone = ListField('timezone', title="Timezone", required=0, css_class=css_class, default='GMT', items=Widget.gmt_timezones, size=1) sub_form.add_group("time") sub_form.add_fields([hour, minute, ampm, timezone], "time") return sub_form
def initializeFieldForm(field_class): """Initialize the properties (fields and values) on a particular field class. Also add the tales and override methods. """ from Form import BasicForm from DummyField import fields form = BasicForm() override_form = BasicForm() tales_form = BasicForm() for field in getPropertyFields(field_class.widget): form.add_field(field, "widget") tales_field = fields.TALESField(field.id, title=field.get_value('title'), description="", default="", display_width=40, required=0) tales_form.add_field(tales_field, "widget") method_field = fields.MethodField(field.id, title=field.get_value("title"), description="", default="", required=0) override_form.add_field(method_field, "widget") for field in getPropertyFields(field_class.validator): form.add_field(field, "validator") tales_field = fields.TALESField(field.id, title=field.get_value('title'), description="", default="", display_with=40, required=0) tales_form.add_field(tales_field, "validator") method_field = fields.MethodField(field.id, title=field.get_value("title"), description="", default="", required=0) override_form.add_field(method_field, "validator") field_class.form = form field_class.override_form = override_form field_class.tales_form = tales_form
def initializeFieldForm(field_class): """Initialize the properties (fields and values) on a particular field class. Also add the tales and override methods. """ from Form import BasicForm from DummyField import fields form = BasicForm() override_form = BasicForm() tales_form = BasicForm() for field in getPropertyFields(field_class.widget): group = field.get_value("group") or "widget" form.add_field(field, group) tales_field = fields.TALESField(field.id, title=field.get_value('title'), description="", default="", display_width=40, required=0) tales_form.add_field(tales_field, group) method_field = fields.MethodField(field.id, title=field.get_value("title"), description="", default="", required=0) override_form.add_field(method_field, group) for field in getPropertyFields(field_class.validator): group = field.get_value("group") or "validator" form.add_field(field, group) tales_field = fields.TALESField(field.id, title=field.get_value('title'), description="", default="", display_with=40, required=0) tales_form.add_field(tales_field, group) method_field = fields.MethodField(field.id, title=field.get_value("title"), description="", default="", required=0) override_form.add_field(method_field, group) field_class.form = form field_class.override_form = override_form field_class.tales_form = tales_form