[Update] 修复Action转化的bug

pull/2891/head
BaiJiangJie 2019-07-06 14:46:01 +08:00
parent 0d72c4a7e0
commit a8c95093c4
1 changed files with 10 additions and 6 deletions

View File

@ -52,16 +52,20 @@ class Action:
@classmethod
def choices_to_value(cls, value):
if not value:
if not isinstance(value, list):
return cls.NONE
db_value = [
cls.NAME_MAP_REVERSE[v] for v in value
if v in cls.NAME_MAP_REVERSE.keys()
]
if not db_value:
return cls.NONE
if len(value) == 1:
return cls.NAME_MAP_REVERSE.get(value[0], cls.NONE)
def to_choices(x, y):
x = cls.NAME_MAP_REVERSE.get(x, cls.NONE)
y = cls.NAME_MAP_REVERSE.get(y, cls.NONE)
return x | y
return reduce(to_choices, value)
result = reduce(to_choices, db_value)
return result
@classmethod
def choices(cls):