Skip to content

Commit

Permalink
Reformatting file
Browse files Browse the repository at this point in the history
  • Loading branch information
goerch committed Nov 10, 2023
1 parent c114e84 commit 7b3fb14
Showing 1 changed file with 142 additions and 73 deletions.
215 changes: 142 additions & 73 deletions flask_appbuilder/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,79 +50,148 @@ class FieldConverter(object):
conversion_table = (
# sqlalchemy.types.Enum inherits from String, therefore `is_enum` must be
# checked before checking for `is_string`:
("is_enum", lambda conv, col_type : EnumField(
enum_class=col_type.enum_class,
enums=col_type.enums,
label=conv.label,
description=conv.description,
validators=conv.validators,
widget=Select2Widget(),
default=conv.default)),
("is_image", lambda conv, _ : ImageUploadField(conv.label,
description=conv.description,
validators=conv.validators,
widget=BS3ImageUploadFieldWidget(),
default=conv.default)),
("is_file", lambda conv, _ : FileUploadField(conv.label,
description=conv.description,
validators=conv.validators,
widget=BS3FileUploadFieldWidget(),
default=conv.default)),
("is_gridfs_file", lambda conv, _ : MongoFileField(conv.label,
description=conv.description,
validators=conv.validators,
widget=BS3FileUploadFieldWidget(),
default=conv.default)),
("is_gridfs_image", lambda conv, _ : MongoImageField(conv.label,
description=conv.description,
validators=conv.validators,
widget=BS3ImageUploadFieldWidget(),
default=conv.default)),
("is_text", lambda conv, _ : TextAreaField(conv.label,
description=conv.description,
validators=conv.validators,
widget=BS3TextAreaFieldWidget(),
default=conv.default)),
("is_binary", lambda conv, _ : TextAreaField(conv.label,
description=conv.description,
validators=conv.validators,
widget=BS3TextAreaFieldWidget(),
default=conv.default)),
("is_string", lambda conv, _ : StringField(conv.label,
description=conv.description,
validators=conv.validators,
widget=BS3TextFieldWidget(),
default=conv.default)),
("is_integer", lambda conv, _ : IntegerField(conv.label,
description=conv.description,
validators=conv.validators,
widget=BS3TextFieldWidget(),
default=conv.default)),
("is_float", lambda conv, _ : FloatField(conv.label,
description=conv.description,
validators=conv.validators,
widget=BS3TextFieldWidget(),
default=conv.default)),
("is_numeric", lambda conv, col_type : DecimalField(conv.label,
places=col_type.scale,
description=conv.description,
validators=conv.validators,
widget=BS3TextFieldWidget(),
default=conv.default)),
("is_boolean", lambda conv, _ : BooleanField(conv.label,
description=conv.description,
validators=conv.validators,
default=conv.default)),
("is_date", lambda conv, _ : DateField(conv.label,
description=conv.description,
validators=conv.validators,
widget=DatePickerWidget(),
default=conv.default)),
("is_datetime", lambda conv, _ : DateTimeField(conv.label,
description=conv.description,
validators=conv.validators,
widget=DateTimePickerWidget(),
default=conv.default)),
(
"is_enum",
lambda conv, col_type: EnumField(
enum_class=col_type.enum_class,
enums=col_type.enums,
label=conv.label,
description=conv.description,
validators=conv.validators,
widget=Select2Widget(),
default=conv.default,
),
),
(
"is_image",
lambda conv, _: ImageUploadField(
conv.label,
description=conv.description,
validators=conv.validators,
widget=BS3ImageUploadFieldWidget(),
default=conv.default,
),
),
(
"is_file",
lambda conv, _: FileUploadField(
conv.label,
description=conv.description,
validators=conv.validators,
widget=BS3FileUploadFieldWidget(),
default=conv.default,
),
),
(
"is_gridfs_file",
lambda conv, _: MongoFileField(
conv.label,
description=conv.description,
validators=conv.validators,
widget=BS3FileUploadFieldWidget(),
default=conv.default,
),
),
(
"is_gridfs_image",
lambda conv, _: MongoImageField(
conv.label,
description=conv.description,
validators=conv.validators,
widget=BS3ImageUploadFieldWidget(),
default=conv.default,
),
),
(
"is_text",
lambda conv, _: TextAreaField(
conv.label,
description=conv.description,
validators=conv.validators,
widget=BS3TextAreaFieldWidget(),
default=conv.default,
),
),
(
"is_binary",
lambda conv, _: TextAreaField(
conv.label,
description=conv.description,
validators=conv.validators,
widget=BS3TextAreaFieldWidget(),
default=conv.default,
),
),
(
"is_string",
lambda conv, _: StringField(
conv.label,
description=conv.description,
validators=conv.validators,
widget=BS3TextFieldWidget(),
default=conv.default,
),
),
(
"is_integer",
lambda conv, _: IntegerField(
conv.label,
description=conv.description,
validators=conv.validators,
widget=BS3TextFieldWidget(),
default=conv.default,
),
),
(
"is_float",
lambda conv, _: FloatField(
conv.label,
description=conv.description,
validators=conv.validators,
widget=BS3TextFieldWidget(),
default=conv.default,
),
),
(
"is_numeric",
lambda conv, col_type: DecimalField(
conv.label,
places=col_type.scale,
description=conv.description,
validators=conv.validators,
widget=BS3TextFieldWidget(),
default=conv.default,
),
),
(
"is_boolean",
lambda conv, _: BooleanField(
conv.label,
description=conv.description,
validators=conv.validators,
default=conv.default,
),
),
(
"is_date",
lambda conv, _: DateField(
conv.label,
description=conv.description,
validators=conv.validators,
widget=DatePickerWidget(),
default=conv.default,
),
),
(
"is_datetime",
lambda conv, _: DateTimeField(
conv.label,
description=conv.description,
validators=conv.validators,
widget=DateTimePickerWidget(),
default=conv.default,
),
),
)

def __init__(
Expand Down

0 comments on commit 7b3fb14

Please sign in to comment.