fix(api): predefined value for float

This commit is contained in:
pycook 2023-12-29 10:57:34 +08:00
parent 7036fe023c
commit e37650f4fc
1 changed files with 7 additions and 2 deletions

View File

@ -94,8 +94,13 @@ class AttributeValueManager(object):
@staticmethod @staticmethod
def _check_is_choice(attr, value_type, value): def _check_is_choice(attr, value_type, value):
choice_values = AttributeManager.get_choice_values(attr.id, value_type, attr.choice_web_hook, attr.choice_other) choice_values = AttributeManager.get_choice_values(attr.id, value_type, attr.choice_web_hook, attr.choice_other)
if str(value) not in list(map(str, [i[0] for i in choice_values])): if value_type == ValueTypeEnum.FLOAT:
return abort(400, ErrFormat.not_in_choice_values.format(value)) if float(value) not in list(map(float, [i[0] for i in choice_values])):
return abort(400, ErrFormat.not_in_choice_values.format(value))
else:
if str(value) not in list(map(str, [i[0] for i in choice_values])):
return abort(400, ErrFormat.not_in_choice_values.format(value))
@staticmethod @staticmethod
def _check_is_unique(value_table, attr, ci_id, type_id, value): def _check_is_unique(value_table, attr, ci_id, type_id, value):