Ejemplo n.º 1
0
 def load_field_info(self, field_info):
     field_datatype = field_info["Type"]
     is_key = field_info['Key'] in ('P', 'U')
     field_name = field_info['Field']
     if field_datatype == "NUMBER" and (field_info['Precision'] == 0
                                        or field_info['Precision'] == None):
         return IntField(field_name, is_key=is_key)
     elif field_datatype == 'NUMBER' and field_info['Precision'] > 0:
         return DecimalField(field_name, is_key=is_key)
     elif field_datatype == 'NVARCHAR2':
         return StringField(field_name, is_key=is_key)
     elif field_datatype == 'VARCHAR2':
         return StringField(field_name, is_key=is_key)
     elif field_datatype == 'FLOAT':
         return DecimalField(field_name, is_key=is_key)
     elif field_datatype == 'CHAR':
         return StringField(field_name, is_key=is_key)
     elif field_datatype == 'TIMESTAMP(6)':
         return DatetimeField(field_name, is_key=is_key)
     elif field_datatype == 'CLOB':
         return StringField(field_name, is_key=is_key)
     elif field_datatype == 'DATE':
         return DatetimeField(field_name, is_key=is_key)
     else:
         raise Exception('Unsupportted type ' + field_datatype)
Ejemplo n.º 2
0
 def add_fields(self, form, index):
     """A hook for adding extra fields on to each form instance."""
     if self.can_order:
         # Only pre-fill the ordering field for initial forms.
         if index < self._initial_form_count:
             form.fields[ORDERING_FIELD_NAME] = DecimalField(
                 ORDERING_FIELD_NAME,
                 label='Order',
                 initial=index + 1,
                 required=False)
         else:
             form.fields[ORDERING_FIELD_NAME] = DecimalField(
                 ORDERING_FIELD_NAME, label='Order', required=False)
     if self.can_delete:
         form.fields[DELETION_FIELD_NAME] = BooleanField(
             form.add_prefix(DELETION_FIELD_NAME),
             label='Delete',
             required=False,
             title='unchecked')
Ejemplo n.º 3
0
 def __init__(self, name='', value='', *args, **kwargs):
     fields = (SplitDateSplitTimeField(), SplitDateSplitTimeField(),
               DateField(size=10),
               ChoiceField(
                   content=attr(onchange='onChangeDateIntervalType(this)'),
                   choices=INTERVAL_CHOICES),
               DecimalField(initial=1,
                            size=5,
                            min_value=-32768,
                            max_value=32767))
     super(DateTimeIntervalField, self).__init__(name, value, fields, *args,
                                                 **kwargs)