Merge branch 'main' into feat/plugin

This commit is contained in:
Yeuoly
2024-08-30 18:21:22 +08:00
11 changed files with 102 additions and 21 deletions

View File

@ -265,7 +265,7 @@ class TenantService:
return tenant
@staticmethod
def create_owner_tenant_if_not_exist(account: Account):
def create_owner_tenant_if_not_exist(account: Account, name: Optional[str] = None):
"""Create owner tenant if not exist"""
available_ta = (
TenantAccountJoin.query.filter_by(account_id=account.id).order_by(TenantAccountJoin.id.asc()).first()
@ -274,7 +274,10 @@ class TenantService:
if available_ta:
return
tenant = TenantService.create_tenant(f"{account.name}'s Workspace")
if name:
tenant = TenantService.create_tenant(name)
else:
tenant = TenantService.create_tenant(f"{account.name}'s Workspace")
TenantService.create_tenant_member(tenant, account, role="owner")
account.current_tenant = tenant
db.session.commit()