Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/admin/blueprints/products.py
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,7 @@ def edit_product(tenant_id, product_id):
return redirect(url_for("products.edit_product", tenant_id=tenant_id, product_id=product_id))

product.formats = formats
logger.info(f"[DEBUG] Updated product.formats to: {formats}")
# Flag JSONB column as modified so SQLAlchemy generates UPDATE
from sqlalchemy.orm import attributes

Expand Down Expand Up @@ -955,6 +956,11 @@ def edit_product(tenant_id, product_id):
for po in existing_options[len(pricing_options_data) :]:
db_session.delete(po)

# Debug: Log final state before commit
logger.info(f"[DEBUG] About to commit product {product_id}")
logger.info(f"[DEBUG] product.formats = {product.formats}")
logger.info(f"[DEBUG] product.formats type = {type(product.formats)}")

db_session.commit()

flash(f"Product '{product.name}' updated successfully", "success")
Expand Down Expand Up @@ -1032,7 +1038,9 @@ def edit_product(tenant_id, product_id):
# Build set of selected format IDs for template checking
# Use composite key (agent_url, format_id) tuples per AdCP spec (same as main.py)
selected_format_ids = set()
logger.info(f"[DEBUG] Building selected_format_ids from product_dict['formats']: {product_dict['formats']}")
logger.info(
f"[DEBUG] Building selected_format_ids from product_dict['formats']: {product_dict['formats']}"
)
for fmt in product_dict["formats"]:
agent_url = None
format_id = None
Expand Down
2 changes: 1 addition & 1 deletion templates/add_product_gam.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ <h3 style="margin-top: 2rem; border-bottom: 2px solid #007bff; padding-bottom: 0
style="border: 2px solid #ddd; border-radius: 4px; padding: 1rem; cursor: pointer; transition: all 0.2s; background: white; position: relative;">
<input type="checkbox" name="formats" value="{{ format.agent_url }}|{{ format.id }}" data-format-id="{{ format.id }}" data-agent-url="{{ format.agent_url }}" {% if selected_format_ids and (format.agent_url, format.id) in selected_format_ids %}checked{% endif %} style="margin-right: 0.5rem;">
<strong>{{ format.name }}</strong>
<span class="format-info-icon" onclick="event.preventDefault(); event.stopPropagation(); showFormatInfo('{{ format.name }}', '{{ format.description or 'No description available' }}', '{{ format.preview_url or '' }}', '{{ format.agent_url or '' }}', '{{ format.id }}');" style="cursor: help; color: #007bff; font-size: 0.9rem; margin-left: 0.3rem; float: right;">ⓘ</span>
<span class="format-info-icon" onclick="event.preventDefault(); event.stopPropagation(); showFormatInfo({{ format.name | tojson }}, {{ (format.description or 'No description available') | tojson }}, {{ (format.preview_url or '') | tojson }}, {{ (format.agent_url or '') | tojson }}, {{ format.id | tojson }});" style="cursor: help; color: #007bff; font-size: 0.9rem; margin-left: 0.3rem; float: right;">ⓘ</span>
<br>
<small style="color: #666;">
{{ format.type }}
Expand Down