[Update] 解决授权规则actions字段为空列表或只填一个action的问题 (#2888)

* [Update] 解决授权规则actions字段为空列表或只填一个action的问题

* [Update] Action NO改为NULL

* [Update] Action NULL改为NONE
pull/2891/head
BaiJiangJie 5 years ago committed by GitHub
parent 59927ffcd9
commit e8f68eb6c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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):
if not 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, 0)
y = cls.NAME_MAP_REVERSE.get(y, 0)
x = cls.NAME_MAP_REVERSE.get(x, cls.NONE)
y = cls.NAME_MAP_REVERSE.get(y, cls.NONE)
return x | y
if not value:
return None
return reduce(to_choices, value)
@classmethod

Loading…
Cancel
Save