mirror of https://github.com/jumpserver/jumpserver
[Update] 解决授权规则actions字段为空列表或只填一个action的问题 (#2888)
* [Update] 解决授权规则actions字段为空列表或只填一个action的问题 * [Update] Action NO改为NULL * [Update] Action NULL改为NONEpull/2891/head
parent
59927ffcd9
commit
e8f68eb6c1
|
@ -16,6 +16,7 @@ __all__ = [
|
|||
|
||||
|
||||
class Action:
|
||||
NONE = 0
|
||||
CONNECT = 0b00000001
|
||||
UPLOAD = 0b00000010
|
||||
DOWNLOAD = 0b00000100
|
||||
|
@ -51,12 +52,15 @@ class Action:
|
|||
|
||||
@classmethod
|
||||
def choices_to_value(cls, value):
|
||||
def to_choices(x, y):
|
||||
x = cls.NAME_MAP_REVERSE.get(x, 0)
|
||||
y = cls.NAME_MAP_REVERSE.get(y, 0)
|
||||
return x | y
|
||||
if not value:
|
||||
return None
|
||||
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)
|
||||
|
||||
@classmethod
|
||||
|
|
Loading…
Reference in New Issue