remove restrictions in form for new placeholder

This commit is contained in:
Cayo Puigdefabregas 2023-08-02 11:39:17 +02:00
parent 4b7bf24d86
commit 6bf91d3362
3 changed files with 16 additions and 24 deletions

View File

@ -521,23 +521,23 @@ class NewDeviceForm(FlaskForm):
error = ["Not a correct value"] error = ["Not a correct value"]
is_valid = super().validate(extra_validators) is_valid = super().validate(extra_validators)
if self.weight.data and not (0.1 <= self.weight.data <= 5): if self.weight.data and not (0.1 <= self.weight.data):
txt = ["Supported values between 0.1 and 5"] txt = ["Supported values greater than 0.1"]
self.weight.errors = txt self.weight.errors = txt
is_valid = False is_valid = False
if self.height.data and not (0.1 <= self.height.data <= 5): if self.height.data and not (0.1 <= self.height.data):
txt = ["Supported values between 0.1 and 5"] txt = ["Supported values greater than 0.1"]
self.height.errors = txt self.height.errors = txt
is_valid = False is_valid = False
if self.width.data and not (0.1 <= self.width.data <= 5): if self.width.data and not (0.1 <= self.width.data):
txt = ["Supported values between 0.1 and 5"] txt = ["Supported values greater than 0.1"]
self.width.errors = txt self.width.errors = txt
is_valid = False is_valid = False
if self.depth.data and not (0.1 <= self.depth.data <= 5): if self.depth.data and not (0.1 <= self.depth.data):
txt = ["Supported values between 0.1 and 5"] txt = ["Supported values greater than 0.1"]
self.depth.errors = txt self.depth.errors = txt
is_valid = False is_valid = False

View File

@ -150,13 +150,13 @@ class Device(Thing):
generation.comment = """The generation of the device.""" generation.comment = """The generation of the device."""
version = db.Column(db.CIText()) version = db.Column(db.CIText())
version.comment = """The version code of this device, like v1 or A001.""" version.comment = """The version code of this device, like v1 or A001."""
weight = Column(Float(decimal_return_scale=4), check_range('weight', 0.1, 5)) weight = Column(Float(decimal_return_scale=4))
weight.comment = """The weight of the device in Kg.""" weight.comment = """The weight of the device in Kg."""
width = Column(Float(decimal_return_scale=4), check_range('width', 0.1, 5)) width = Column(Float(decimal_return_scale=4))
width.comment = """The width of the device in meters.""" width.comment = """The width of the device in meters."""
height = Column(Float(decimal_return_scale=4), check_range('height', 0.1, 5)) height = Column(Float(decimal_return_scale=4))
height.comment = """The height of the device in meters.""" height.comment = """The height of the device in meters."""
depth = Column(Float(decimal_return_scale=4), check_range('depth', 0.1, 5)) depth = Column(Float(decimal_return_scale=4))
depth.comment = """The depth of the device in meters.""" depth.comment = """The depth of the device in meters."""
color = Column(ColorType) color = Column(ColorType)
color.comment = """The predominant color of the device.""" color.comment = """The predominant color of the device."""

View File

@ -67,18 +67,10 @@ class Device(Thing):
validate=Range(1, 100), description=m.Device.generation.comment validate=Range(1, 100), description=m.Device.generation.comment
) )
version = SanitizedStr(description=m.Device.version) version = SanitizedStr(description=m.Device.version)
weight = Float( weight = Float(unit=UnitCodes.kgm, description=m.Device.weight.comment)
validate=Range(0.1, 5), unit=UnitCodes.kgm, description=m.Device.weight.comment width = Float(unit=UnitCodes.m, description=m.Device.width.comment)
) height = Float(unit=UnitCodes.m, description=m.Device.height.comment)
width = Float( depth = Float(unit=UnitCodes.m, description=m.Device.depth.comment)
validate=Range(0.1, 5), unit=UnitCodes.m, description=m.Device.width.comment
)
height = Float(
validate=Range(0.1, 5), unit=UnitCodes.m, description=m.Device.height.comment
)
depth = Float(
validate=Range(0.1, 5), unit=UnitCodes.m, description=m.Device.depth.comment
)
# TODO TimeOut 2. Comment actions and lots if there are time out. # TODO TimeOut 2. Comment actions and lots if there are time out.
actions = NestedOn( actions = NestedOn(
'Action', many=True, dump_only=True, description=m.Device.actions.__doc__ 'Action', many=True, dump_only=True, description=m.Device.actions.__doc__