Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/add admin check #11050

Merged
merged 3 commits into from
Nov 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions api/models/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ def get_integrates(self) -> list[db.Model]:
def is_admin_or_owner(self):
return TenantAccountRole.is_privileged_role(self._current_tenant.current_role)

@property
def is_admin(self):
return TenantAccountRole.is_admin_role(self._current_tenant.current_role)

@property
def is_editor(self):
return TenantAccountRole.is_editing_role(self._current_tenant.current_role)
Expand Down Expand Up @@ -147,6 +151,10 @@ def is_valid_role(role: str) -> bool:
def is_privileged_role(role: str) -> bool:
return role and role in {TenantAccountRole.OWNER, TenantAccountRole.ADMIN}

@staticmethod
def is_admin_role(role: str) -> bool:
return role and role == TenantAccountRole.ADMIN

@staticmethod
def is_non_owner_role(role: str) -> bool:
return role and role in {
Expand Down