aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorBonfaceKilz2021-10-19 16:39:32 +0300
committerBonfaceKilz2021-10-25 14:00:14 +0300
commit3c074638ca0b5e175e2dbb93aaf3bf21e8af8151 (patch)
tree37125a855b98de90ae7ef955e71108e0d7e84975 /wqflask
parent5d6559cdc0f9251a90b351bf440b930a000f8354 (diff)
downloadgenenetwork2-3c074638ca0b5e175e2dbb93aaf3bf21e8af8151.tar.gz
Move access_roles enums to it's own module
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/wqflask/access_roles.py30
-rw-r--r--wqflask/wqflask/resource_manager.py32
2 files changed, 32 insertions, 30 deletions
diff --git a/wqflask/wqflask/access_roles.py b/wqflask/wqflask/access_roles.py
new file mode 100644
index 00000000..6cffbc81
--- /dev/null
+++ b/wqflask/wqflask/access_roles.py
@@ -0,0 +1,30 @@
+import functools
+from enum import Enum, unique
+
+
+@functools.total_ordering
+class OrderedEnum(Enum):
+ @classmethod
+ @functools.lru_cache(None)
+ def _member_list(cls):
+ return list(cls)
+
+ def __lt__(self, other):
+ if self.__class__ is other.__class__:
+ member_list = self.__class__._member_list()
+ return member_list.index(self) < member_list.index(other)
+ return NotImplemented
+
+
+@unique
+class DataRole(OrderedEnum):
+ NO_ACCESS = "no-access"
+ VIEW = "view"
+ EDIT = "edit"
+
+
+@unique
+class AdminRole(OrderedEnum):
+ NOT_ADMIN = "not-admin"
+ EDIT_ACCESS = "edit-access"
+ EDIT_ADMINS = "edit-admins"
diff --git a/wqflask/wqflask/resource_manager.py b/wqflask/wqflask/resource_manager.py
index 9665ebb0..4e160bb8 100644
--- a/wqflask/wqflask/resource_manager.py
+++ b/wqflask/wqflask/resource_manager.py
@@ -1,8 +1,6 @@
import redis
import json
-import functools
-from enum import Enum, unique
from flask import Blueprint
from flask import current_app
@@ -12,34 +10,8 @@ from flask import render_template
from typing import Dict
from wqflask.decorators import login_required
-
-
-@functools.total_ordering
-class OrderedEnum(Enum):
- @classmethod
- @functools.lru_cache(None)
- def _member_list(cls):
- return list(cls)
-
- def __lt__(self, other):
- if self.__class__ is other.__class__:
- member_list = self.__class__._member_list()
- return member_list.index(self) < member_list.index(other)
- return NotImplemented
-
-
-@unique
-class DataRole(OrderedEnum):
- NO_ACCESS = "no-access"
- VIEW = "view"
- EDIT = "edit"
-
-
-@unique
-class AdminRole(OrderedEnum):
- NOT_ADMIN = "not-admin"
- EDIT_ACCESS = "edit-access"
- EDIT_ADMINS = "edit-admins"
+from wqflask.access_roles import AdminRole
+from wqflask.access_roles import DataRole
resource_management = Blueprint('resource_management', __name__)