diff --git a/api/models/account.py b/api/models/account.py index 60b4f11aad2bd..3b8782dc5e506 100644 --- a/api/models/account.py +++ b/api/models/account.py @@ -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): @@ -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 { diff --git a/api/models/model.py b/api/models/model.py index b7c89ce97c13c..40000597decc3 100644 --- a/api/models/model.py +++ b/api/models/model.py @@ -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")) diff --git a/api/services/app_service.py b/api/services/app_service.py index af2b77d633657..a3eb0e01244d8 100644 --- a/api/services/app_service.py +++ b/api/services/app_service.py @@ -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