Merge pull request #2891 from jumpserver/dev_perms

[Update] 修复Action转化的bug
pull/2893/head
老广 5 years ago committed by GitHub
commit eba8e54261
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -52,16 +52,20 @@ class Action:
@classmethod @classmethod
def choices_to_value(cls, value): 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 return cls.NONE
if len(value) == 1:
return cls.NAME_MAP_REVERSE.get(value[0], cls.NONE)
def to_choices(x, y): 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 x | y
return reduce(to_choices, value)
result = reduce(to_choices, db_value)
return result
@classmethod @classmethod
def choices(cls): def choices(cls):

Loading…
Cancel
Save