|
@@ -125,6 +125,10 @@ class Account(UserMixin, Base):
|
|
|
def is_dataset_operator(self):
|
|
|
return self._current_tenant.current_role == TenantAccountRole.DATASET_OPERATOR
|
|
|
|
|
|
+ @property
|
|
|
+ def is_leader(self):
|
|
|
+ return TenantAccountRole.is_leader_role(self._current_tenant.current_role)
|
|
|
+
|
|
|
|
|
|
class TenantStatus(enum.StrEnum):
|
|
|
NORMAL = "normal"
|
|
@@ -137,6 +141,7 @@ class TenantAccountRole(enum.StrEnum):
|
|
|
EDITOR = "editor"
|
|
|
NORMAL = "normal"
|
|
|
DATASET_OPERATOR = "dataset_operator"
|
|
|
+ LEADER = "leader"
|
|
|
|
|
|
@staticmethod
|
|
|
def is_valid_role(role: str) -> bool:
|
|
@@ -148,13 +153,14 @@ class TenantAccountRole(enum.StrEnum):
|
|
|
TenantAccountRole.EDITOR,
|
|
|
TenantAccountRole.NORMAL,
|
|
|
TenantAccountRole.DATASET_OPERATOR,
|
|
|
+ TenantAccountRole.LEADER,
|
|
|
}
|
|
|
|
|
|
@staticmethod
|
|
|
def is_privileged_role(role: str) -> bool:
|
|
|
if not role:
|
|
|
return False
|
|
|
- return role in {TenantAccountRole.OWNER, TenantAccountRole.ADMIN}
|
|
|
+ return role in {TenantAccountRole.OWNER, TenantAccountRole.ADMIN, TenantAccountRole.LEADER}
|
|
|
|
|
|
@staticmethod
|
|
|
def is_admin_role(role: str) -> bool:
|
|
@@ -171,13 +177,17 @@ class TenantAccountRole(enum.StrEnum):
|
|
|
TenantAccountRole.EDITOR,
|
|
|
TenantAccountRole.NORMAL,
|
|
|
TenantAccountRole.DATASET_OPERATOR,
|
|
|
+ TenantAccountRole.LEADER,
|
|
|
}
|
|
|
|
|
|
@staticmethod
|
|
|
def is_editing_role(role: str) -> bool:
|
|
|
if not role:
|
|
|
return False
|
|
|
- return role in {TenantAccountRole.OWNER, TenantAccountRole.ADMIN, TenantAccountRole.EDITOR}
|
|
|
+ return role in {TenantAccountRole.OWNER,
|
|
|
+ TenantAccountRole.ADMIN,
|
|
|
+ TenantAccountRole.EDITOR,
|
|
|
+ TenantAccountRole.LEADER}
|
|
|
|
|
|
@staticmethod
|
|
|
def is_dataset_edit_role(role: str) -> bool:
|
|
@@ -188,8 +198,15 @@ class TenantAccountRole(enum.StrEnum):
|
|
|
TenantAccountRole.ADMIN,
|
|
|
TenantAccountRole.EDITOR,
|
|
|
TenantAccountRole.DATASET_OPERATOR,
|
|
|
+ TenantAccountRole.LEADER,
|
|
|
}
|
|
|
|
|
|
+ @staticmethod
|
|
|
+ def is_leader_role(role: str) -> bool:
|
|
|
+ if not role:
|
|
|
+ return False
|
|
|
+ return role == TenantAccountRole.LEADER
|
|
|
+
|
|
|
|
|
|
class Tenant(db.Model): # type: ignore[name-defined]
|
|
|
__tablename__ = "tenants"
|