mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Clean up enum-related functions
This commit is contained in:
parent
821ed7ef5d
commit
7c85496eb8
@ -45,15 +45,13 @@ class PermissionsCrafty:
|
||||
# **********************************************************************************
|
||||
@staticmethod
|
||||
def get_permissions_list():
|
||||
return [
|
||||
permission for _, permission in EnumPermissionsCrafty.__members__.items()
|
||||
]
|
||||
return list(EnumPermissionsCrafty.__members__.values())
|
||||
|
||||
@staticmethod
|
||||
def get_permissions(permissions_mask):
|
||||
return [
|
||||
permission
|
||||
for _, permission in EnumPermissionsCrafty.__members__.items()
|
||||
for permission in EnumPermissionsCrafty.__members__.values()
|
||||
if PermissionsCrafty.has_permission(permissions_mask, permission)
|
||||
]
|
||||
|
||||
@ -81,7 +79,7 @@ class PermissionsCrafty:
|
||||
|
||||
@staticmethod
|
||||
def get_all_permission_quantity_list():
|
||||
return {name: -1 for name, _ in EnumPermissionsCrafty.__members__.items()}
|
||||
return {name: -1 for name in EnumPermissionsCrafty.__members__.keys()}
|
||||
|
||||
@staticmethod
|
||||
def get_permission_quantity_list(user_id):
|
||||
|
@ -51,15 +51,13 @@ class PermissionsServers:
|
||||
|
||||
@staticmethod
|
||||
def get_permissions_list():
|
||||
return [
|
||||
permission for _, permission in EnumPermissionsServer.__members__.items()
|
||||
]
|
||||
return list(EnumPermissionsServer.__members__.values())
|
||||
|
||||
@staticmethod
|
||||
def get_permissions(permissions_mask):
|
||||
return [
|
||||
permission
|
||||
for _, permission in EnumPermissionsServer.__members__.items()
|
||||
for permission in EnumPermissionsServer.__members__.values()
|
||||
if PermissionsServers.has_permission(permissions_mask, permission)
|
||||
]
|
||||
|
||||
@ -82,13 +80,13 @@ class PermissionsServers:
|
||||
|
||||
@staticmethod
|
||||
def get_token_permissions(permissions_mask, api_permissions_mask):
|
||||
permissions_list = []
|
||||
for member in EnumPermissionsServer.__members__.items():
|
||||
return [
|
||||
permission
|
||||
for permission in EnumPermissionsServer.__members__.values()
|
||||
if PermissionHelper.both_have_perm(
|
||||
permissions_mask, api_permissions_mask, member[1]
|
||||
):
|
||||
permissions_list.append(member[1])
|
||||
return permissions_list
|
||||
permissions_mask, api_permissions_mask, permission
|
||||
)
|
||||
]
|
||||
|
||||
# **********************************************************************************
|
||||
# Role_Servers Methods
|
||||
|
Loading…
Reference in New Issue
Block a user