From 7b3fb146e4200c9b6236dc8ebb6b76f74d03d3b3 Mon Sep 17 00:00:00 2001 From: goerch Date: Fri, 10 Nov 2023 14:10:07 +0100 Subject: [PATCH] Reformatting file --- flask_appbuilder/forms.py | 215 +++++++++++++++++++++++++------------- 1 file changed, 142 insertions(+), 73 deletions(-) diff --git a/flask_appbuilder/forms.py b/flask_appbuilder/forms.py index 2e47ef70ce..f850f0c0dc 100644 --- a/flask_appbuilder/forms.py +++ b/flask_appbuilder/forms.py @@ -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__(