2023-05-15 08:51:32 +08:00
|
|
|
from extensions.ext_database import db
|
|
|
|
from models.account import Tenant
|
2023-08-12 00:57:00 +08:00
|
|
|
from models.provider import Provider
|
2023-05-15 08:51:32 +08:00
|
|
|
|
|
|
|
|
|
|
|
class WorkspaceService:
|
|
|
|
@classmethod
|
|
|
|
def get_tenant_info(cls, tenant: Tenant):
|
|
|
|
tenant_info = {
|
|
|
|
'id': tenant.id,
|
|
|
|
'name': tenant.name,
|
|
|
|
'plan': tenant.plan,
|
|
|
|
'status': tenant.status,
|
|
|
|
'created_at': tenant.created_at,
|
|
|
|
'providers': [],
|
2023-08-12 00:57:00 +08:00
|
|
|
'in_trial': True,
|
|
|
|
'trial_end_reason': None
|
2023-05-15 08:51:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
# Get providers
|
|
|
|
providers = db.session.query(Provider).filter(
|
|
|
|
Provider.tenant_id == tenant.id
|
|
|
|
).all()
|
|
|
|
|
|
|
|
# Add providers to the tenant info
|
|
|
|
tenant_info['providers'] = providers
|
|
|
|
|
|
|
|
return tenant_info
|