Unverified Commit e8f68eb6 authored by BaiJiangJie's avatar BaiJiangJie Committed by GitHub

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

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

* [Update] Action NO改为NULL

* [Update] Action NULL改为NONE
parent 59927ffc
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment