feat: Frontend Inspector Upgrade (CRM & Strategy View)
This commit is contained in:
@@ -194,7 +194,34 @@ def get_company(company_id: int, db: Session = Depends(get_db), username: str =
|
|||||||
).filter(Company.id == company_id).first()
|
).filter(Company.id == company_id).first()
|
||||||
if not company:
|
if not company:
|
||||||
raise HTTPException(404, detail="Company not found")
|
raise HTTPException(404, detail="Company not found")
|
||||||
return company
|
|
||||||
|
# Enrich with Industry Details (Strategy)
|
||||||
|
industry_details = None
|
||||||
|
if company.industry_ai:
|
||||||
|
ind = db.query(Industry).filter(Industry.name == company.industry_ai).first()
|
||||||
|
if ind:
|
||||||
|
industry_details = {
|
||||||
|
"pains": ind.pains,
|
||||||
|
"gains": ind.gains,
|
||||||
|
"priority": ind.priority,
|
||||||
|
"notes": ind.notes,
|
||||||
|
"ops_focus_secondary": ind.ops_focus_secondary
|
||||||
|
}
|
||||||
|
|
||||||
|
# HACK: Attach to response object (Pydantic would be cleaner, but this works for fast prototyping)
|
||||||
|
# We convert to dict and append
|
||||||
|
resp = company.__dict__.copy()
|
||||||
|
resp["industry_details"] = industry_details
|
||||||
|
# Handle SQLAlchemy internal state
|
||||||
|
if "_sa_instance_state" in resp: del resp["_sa_instance_state"]
|
||||||
|
# Handle relationships manually if needed, or let FastAPI encode the SQLAlchemy model + extra dict
|
||||||
|
# Better: return a custom dict merging both
|
||||||
|
|
||||||
|
# Since we use joinedload, relationships are loaded.
|
||||||
|
# Let's rely on FastAPI's ability to serialize the object, but we need to inject the extra field.
|
||||||
|
# The safest way without changing Pydantic schemas everywhere is to return a dict.
|
||||||
|
|
||||||
|
return {**resp, "enrichment_data": company.enrichment_data, "contacts": company.contacts, "signals": company.signals}
|
||||||
|
|
||||||
@app.post("/api/companies")
|
@app.post("/api/companies")
|
||||||
def create_company(company: CompanyCreate, db: Session = Depends(get_db), username: str = Depends(authenticate_user)):
|
def create_company(company: CompanyCreate, db: Session = Depends(get_db), username: str = Depends(authenticate_user)):
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user