Team Ai
Apppublic

Underground-Digital/Workflow-Engine

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
workspace_service.py53 linesDownload Raw Back to services
1from flask_login import current_user2 3from configs import dify_config4from extensions.ext_database import db5from models.account import Tenant, TenantAccountJoin, TenantAccountJoinRole6from services.account_service import TenantService7from services.feature_service import FeatureService8 9 10class WorkspaceService:11    @classmethod12    def get_tenant_info(cls, tenant: Tenant):13        if not tenant:14            return None15        tenant_info = {16            "id": tenant.id,17            "name": tenant.name,18            "plan": tenant.plan,19            "status": tenant.status,20            "created_at": tenant.created_at,21            "in_trail": True,22            "trial_end_reason": None,23            "role": "normal",24        }25 26        # Get role of user27        tenant_account_join = (28            db.session.query(TenantAccountJoin)29            .filter(TenantAccountJoin.tenant_id == tenant.id, TenantAccountJoin.account_id == current_user.id)30            .first()31        )32        tenant_info["role"] = tenant_account_join.role33 34        can_replace_logo = FeatureService.get_features(tenant_info["id"]).can_replace_logo35 36        if can_replace_logo and TenantService.has_roles(37            tenant, [TenantAccountJoinRole.OWNER, TenantAccountJoinRole.ADMIN]38        ):39            base_url = dify_config.FILES_URL40            replace_webapp_logo = (41                f"{base_url}/files/workspaces/{tenant.id}/webapp-logo"42                if tenant.custom_config_dict.get("replace_webapp_logo")43                else None44            )45            remove_webapp_brand = tenant.custom_config_dict.get("remove_webapp_brand", False)46 47            tenant_info["custom_config"] = {48                "remove_webapp_brand": remove_webapp_brand,49                "replace_webapp_logo": replace_webapp_logo,50            }51 52        return tenant_info53