mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-06-27 07:17:10 +00:00
Merge branch 'dev' of github.com:jumpserver/jumpserver into dev
This commit is contained in:
commit
cc56c92562
@ -15,7 +15,7 @@ from .user import AdminUser, SystemUser
|
|||||||
from .utils import Connectivity
|
from .utils import Connectivity
|
||||||
from orgs.mixins import OrgModelMixin, OrgManager
|
from orgs.mixins import OrgModelMixin, OrgManager
|
||||||
|
|
||||||
__all__ = ['Asset']
|
__all__ = ['Asset', 'ProtocolsMixin']
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ __all__ = [
|
|||||||
|
|
||||||
|
|
||||||
class Action:
|
class Action:
|
||||||
|
NONE = 0
|
||||||
CONNECT = 0b00000001
|
CONNECT = 0b00000001
|
||||||
UPLOAD = 0b00000010
|
UPLOAD = 0b00000010
|
||||||
DOWNLOAD = 0b00000100
|
DOWNLOAD = 0b00000100
|
||||||
@ -51,13 +52,20 @@ class Action:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def choices_to_value(cls, value):
|
def choices_to_value(cls, 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
|
||||||
|
|
||||||
def to_choices(x, y):
|
def to_choices(x, y):
|
||||||
x = cls.NAME_MAP_REVERSE.get(x, 0)
|
|
||||||
y = cls.NAME_MAP_REVERSE.get(y, 0)
|
|
||||||
return x | y
|
return x | y
|
||||||
if not value:
|
|
||||||
return None
|
result = reduce(to_choices, db_value)
|
||||||
return reduce(to_choices, value)
|
return result
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def choices(cls):
|
def choices(cls):
|
||||||
|
Loading…
Reference in New Issue
Block a user