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"]
is_valid = super().validate(extra_validators)
if self.weight.data and not (0.1 <= self.weight.data <= 5):
txt = ["Supported values between 0.1 and 5"]
if self.weight.data and not (0.1 <= self.weight.data):
txt = ["Supported values greater than 0.1"]
self.weight.errors = txt
is_valid = False
if self.height.data and not (0.1 <= self.height.data <= 5):
txt = ["Supported values between 0.1 and 5"]
if self.height.data and not (0.1 <= self.height.data):
txt = ["Supported values greater than 0.1"]
self.height.errors = txt
is_valid = False
if self.width.data and not (0.1 <= self.width.data <= 5):
txt = ["Supported values between 0.1 and 5"]
if self.width.data and not (0.1 <= self.width.data):
txt = ["Supported values greater than 0.1"]
self.width.errors = txt
is_valid = False
if self.depth.data and not (0.1 <= self.depth.data <= 5):
txt = ["Supported values between 0.1 and 5"]
if self.depth.data and not (0.1 <= self.depth.data):
txt = ["Supported values greater than 0.1"]
self.depth.errors = txt
is_valid = False

View File

@ -150,13 +150,13 @@ class Device(Thing):
generation.comment = """The generation of the device."""
version = db.Column(db.CIText())
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."""
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."""
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."""
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."""
color = Column(ColorType)
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
)
version = SanitizedStr(description=m.Device.version)
weight = Float(
validate=Range(0.1, 5), unit=UnitCodes.kgm, description=m.Device.weight.comment
)
width = Float(
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
)
weight = Float(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)
depth = Float(unit=UnitCodes.m, description=m.Device.depth.comment)
# TODO TimeOut 2. Comment actions and lots if there are time out.
actions = NestedOn(
'Action', many=True, dump_only=True, description=m.Device.actions.__doc__