Fix Cloud Connect accounts page: serialize customers as dicts for tojson

Pass customer_rows (list of {id, name} dicts) instead of SQLAlchemy
objects so the Jinja tojson filter can serialize them in JavaScript.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Ivo Oskamp 2026-03-20 09:00:51 +01:00
parent 64f686e275
commit 56f904bde3
2 changed files with 3 additions and 2 deletions

View File

@ -31,6 +31,7 @@ def cloud_connect_accounts():
) )
customers = Customer.query.filter_by(active=True).order_by(Customer.name.asc()).all() customers = Customer.query.filter_by(active=True).order_by(Customer.name.asc()).all()
customer_rows = [{"id": c.id, "name": c.name} for c in customers]
jobs = Job.query.filter_by(archived=False).order_by(Job.job_name.asc()).all() jobs = Job.query.filter_by(archived=False).order_by(Job.job_name.asc()).all()
# Attach derived fields for the template # Attach derived fields for the template
@ -45,7 +46,7 @@ def cloud_connect_accounts():
"main/cloud_connect_accounts.html", "main/cloud_connect_accounts.html",
unmatched=unmatched, unmatched=unmatched,
matched=matched, matched=matched,
customers=customers, customers=customer_rows,
jobs=jobs, jobs=jobs,
) )

View File

@ -163,7 +163,7 @@
autocomplete="off" /> autocomplete="off" />
<datalist id="ccCustomerList"> <datalist id="ccCustomerList">
{% for c in customers %} {% for c in customers %}
<option value="{{ c.name }}"></option> <option value="{{ c.name | e }}"></option>
{% endfor %} {% endfor %}
</datalist> </datalist>
</div> </div>