Add frontend pages imporvements
This commit is contained in:
@@ -234,14 +234,14 @@ class EnhancedTenantService:
|
||||
return []
|
||||
|
||||
async def update_tenant(
|
||||
self,
|
||||
tenant_id: str,
|
||||
update_data: TenantUpdate,
|
||||
self,
|
||||
tenant_id: str,
|
||||
update_data: TenantUpdate,
|
||||
user_id: str,
|
||||
session: AsyncSession = None
|
||||
) -> TenantResponse:
|
||||
"""Update tenant information with permission checks"""
|
||||
|
||||
|
||||
try:
|
||||
# Verify user has admin access
|
||||
access = await self.verify_user_access(user_id, tenant_id)
|
||||
@@ -250,29 +250,33 @@ class EnhancedTenantService:
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail="Insufficient permissions to update tenant"
|
||||
)
|
||||
|
||||
# Update tenant using repository
|
||||
|
||||
# Update tenant using repository with proper session management
|
||||
update_values = update_data.dict(exclude_unset=True)
|
||||
if update_values:
|
||||
updated_tenant = await self.tenant_repo.update(tenant_id, update_values)
|
||||
|
||||
if not updated_tenant:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
detail="Tenant not found"
|
||||
)
|
||||
|
||||
logger.info("Tenant updated successfully",
|
||||
tenant_id=tenant_id,
|
||||
updated_by=user_id,
|
||||
fields=list(update_values.keys()))
|
||||
|
||||
return TenantResponse.from_orm(updated_tenant)
|
||||
|
||||
# No updates to apply
|
||||
tenant = await self.tenant_repo.get_by_id(tenant_id)
|
||||
return TenantResponse.from_orm(tenant)
|
||||
|
||||
async with self.database_manager.get_session() as db_session:
|
||||
await self._init_repositories(db_session)
|
||||
updated_tenant = await self.tenant_repo.update(tenant_id, update_values)
|
||||
|
||||
if not updated_tenant:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
detail="Tenant not found"
|
||||
)
|
||||
|
||||
logger.info("Tenant updated successfully",
|
||||
tenant_id=tenant_id,
|
||||
updated_by=user_id,
|
||||
fields=list(update_values.keys()))
|
||||
|
||||
return TenantResponse.from_orm(updated_tenant)
|
||||
|
||||
# No updates to apply - get current tenant data
|
||||
async with self.database_manager.get_session() as db_session:
|
||||
await self._init_repositories(db_session)
|
||||
tenant = await self.tenant_repo.get_by_id(tenant_id)
|
||||
return TenantResponse.from_orm(tenant)
|
||||
|
||||
except HTTPException:
|
||||
raise
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user