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

Solution/role based app setting[WIP] #10946

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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 @@ -107,6 +107,10 @@ def get_integrates(self) -> list[db.Model]:
@property
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):
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 in {TenantAccountRole.ADMIN}

@staticmethod
def is_non_owner_role(role: str) -> bool:
return role and role in {
Expand Down
11 changes: 11 additions & 0 deletions api/models/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,17 @@ class App(db.Model):
workflow_id = db.Column(StringUUID, nullable=True)
status = db.Column(db.String(255), nullable=False, server_default=db.text("'normal'::character varying"))
enable_site = db.Column(db.Boolean, nullable=False)
# to enable/disable public site URL
# _enable_site = db.Column("enable_site", db.Boolean, nullable=False, server_default=db.text("false"))

# @property
# def enable_site(self) -> Literal[False]:
# return False

# @enable_site.setter
# def enable_site(self, value: bool) -> None:
# self._enable_site = value

enable_api = db.Column(db.Boolean, nullable=False)
api_rpm = db.Column(db.Integer, nullable=False, server_default=db.text("0"))
api_rph = db.Column(db.Integer, nullable=False, server_default=db.text("0"))
Expand Down
4 changes: 4 additions & 0 deletions api/services/app_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,10 @@ def update_app_site_status(self, app: App, enable_site: bool) -> App:
:param enable_site: enable site status
:return: App instance
"""

if not current_user.is_admin:
return app

if enable_site == app.enable_site:
return app

Expand Down
Loading