sprint3: dashboard counts per user + import owner_id + export visibility filter

This commit is contained in:
Agent Zero
2026-07-29 02:11:29 +02:00
parent 517e1b6d8b
commit b06aeeb720
3 changed files with 86 additions and 3 deletions
+8 -2
View File
@@ -92,15 +92,21 @@ async def export_data(
- format: 'csv' or 'xlsx' (default: csv)
"""
tenant_id = uuid.UUID(current_user["tenant_id"])
user_id = uuid.UUID(current_user["user_id"])
is_system_admin = current_user.get("is_system_admin", False)
# Determine filename based on entity_type
filename = f"{entity_type}_export.csv"
# Fetch CSV data from the appropriate service function
if entity_type == "contacts":
csv_data = await import_export_service.export_contacts_csv(db, tenant_id)
csv_data = await import_export_service.export_contacts_csv(
db, tenant_id, user_id=user_id, is_system_admin=is_system_admin
)
elif entity_type == "companies":
csv_data = await import_export_service.export_companies_csv(db, tenant_id)
csv_data = await import_export_service.export_companies_csv(
db, tenant_id, user_id=user_id, is_system_admin=is_system_admin
)
else:
raise HTTPException(status_code=400, detail=f"Unsupported entity_type: {entity_type}")