Fix WO render_badge None guard, updated_at slice, and backfill path

Add null guard to WO render_badge matching the PO version. Use
`or ""` before slicing updated_at to handle explicit None values.
Fix backfill_sites.py sys.path to use new lambdas/po/site_extractor.
This commit is contained in:
Adam Moussa 2026-05-12 14:53:42 -04:00
parent b545bfed3d
commit 4ba5c37f47
2 changed files with 4 additions and 2 deletions

View file

@ -40,6 +40,8 @@ def get_comments(work_order_id):
def render_badge(value, color_map):
if not value:
value = "unknown"
color = color_map.get(value, "#9ca3af")
label = esc(value.replace("_", " ").title())
return f'<span style="background:{color};color:#fff;padding:2px 10px;border-radius:12px;font-size:12px;font-weight:500;">{label}</span>'
@ -163,7 +165,7 @@ def render_work_orders_list(work_orders):
status = wo.get("wo_status", "unknown")
record_type = wo.get("record_type", "unknown")
due = esc(wo.get("due_date", ""))
updated = esc(wo.get("updated_at", "")[:16])
updated = esc((wo.get("updated_at") or "")[:16])
rows += f"""
<tr style="border-bottom:1px solid #f1f5f9;cursor:pointer;" onclick="window.location='/wo?id={wo_id}'">

View file

@ -8,7 +8,7 @@ Usage:
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "lambdas", "site_extractor"))
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "lambdas", "po", "site_extractor"))
import boto3
from handler import extract_site_code, parse_address, upsert_site