Skip to content
Merged
6 changes: 3 additions & 3 deletions src/core/tools/media_buy_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,9 @@ def execute_approved_media_buy(media_buy_id: str, tenant_id: str) -> tuple[bool,
from src.core.database.models import Creative as CreativeModel
from src.core.database.models import CreativeAssignment

# Import adapter helper here (used for both creative upload and order approval)
from src.core.helpers.adapter_helpers import get_adapter

# Get all creative assignments for this media buy
stmt_assignments = select(CreativeAssignment).filter_by(media_buy_id=media_buy_id)
assignments = session.scalars(stmt_assignments).all()
Expand Down Expand Up @@ -621,9 +624,6 @@ def execute_approved_media_buy(media_buy_id: str, tenant_id: str) -> tuple[bool,

assets.append(asset)

# Import adapter helper at this scope level for both creative upload and order approval
from src.core.helpers.adapter_helpers import get_adapter

if assets:
logger.info(f"[APPROVAL] Uploading {len(assets)} creatives to adapter")

Expand Down
11 changes: 7 additions & 4 deletions templates/add_product.html
Original file line number Diff line number Diff line change
Expand Up @@ -537,10 +537,13 @@ <h3 style="margin-top: 2rem;">Property Authorization (AdCP) *</h3>
</div>
</div>

<!-- Targeting Configuration Widget -->
<h3 style="margin-top: 2rem;">Targeting Configuration (Optional)</h3>
<div class="alert" style="background: #fff3cd; border-left: 4px solid #ffc107; padding: 1rem; margin-bottom: 1rem;">
<strong>💡 Tip:</strong> Configure custom targeting (key-value pairs) to define who will see ads for this product.
<!-- Custom Targeting (Optional) -->
<h3 style="margin-top: 2rem;">
<i class="fas fa-bullseye"></i> Custom Targeting (Optional)
</h3>
<div class="alert alert-info" style="background: #fff9e6; border-left: 4px solid #ffc107; padding: 1rem; margin-bottom: 1rem;">
<strong>💡 Who Sees This:</strong> Configure custom targeting (key-value pairs) to define which audience segments will see ads for this product.
<br><small style="color: #666;">Example: sport=basketball, genre=action, age=18-34</small>
</div>

{# Simple targeting selector - matches existing UI patterns #}
Expand Down
8 changes: 6 additions & 2 deletions templates/components/targeting_selector_simple.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ <h4>🎯 Custom Targeting</h4>
document.addEventListener('DOMContentLoaded', async function() {
try {
const tenantId = '{{ tenant_id }}';
const response = await fetch(`/api/tenant/${tenantId}/targeting/all`);
const response = await fetch(`/api/tenant/${tenantId}/targeting/all`, {
credentials: 'same-origin'
});
const data = await response.json();

availableKeys = data.customKeys || [];
Expand Down Expand Up @@ -169,7 +171,9 @@ <h4>🎯 Custom Targeting</h4>

try {
const tenantId = '{{ tenant_id }}';
const response = await fetch(`/api/tenant/${tenantId}/targeting/values/${keyId}`);
const response = await fetch(`/api/tenant/${tenantId}/targeting/values/${keyId}`, {
credentials: 'same-origin'
});
const data = await response.json();

availableValues[keyId] = data.values || [];
Expand Down
17 changes: 7 additions & 10 deletions templates/edit_product.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,20 +120,17 @@ <h4 style="margin-top: 0; margin-bottom: 0.5rem;">Pricing Options (Recommended)<
</div>
{% endif %}

<!-- Targeting Configuration Widget -->
<h3 style="margin-top: 2rem;">Targeting Configuration (Optional)</h3>
<div class="alert" style="background: #fff3cd; border-left: 4px solid #ffc107; padding: 1rem; margin-bottom: 1rem;">
<strong>💡 Tip:</strong> Configure custom targeting (key-value pairs) to define who will see ads for this product.
<!-- Custom Targeting (Optional) -->
<h3 style="margin-top: 2rem;">
<i class="fas fa-bullseye"></i> Custom Targeting (Optional)
</h3>
<div class="alert alert-info" style="background: #fff9e6; border-left: 4px solid #ffc107; padding: 1rem; margin-bottom: 1rem;">
<strong>💡 Who Sees This:</strong> Configure custom targeting (key-value pairs) to define which audience segments will see ads for this product.
<br><small style="color: #666;">Example: sport=basketball, genre=action, age=18-34</small>
</div>

{# Simple targeting selector - matches existing UI patterns #}
<div style="background: #ffcccc; padding: 1rem; border: 2px solid red; margin: 1rem 0;">
<strong>DEBUG: About to include targeting selector widget</strong>
</div>
{% include 'components/targeting_selector_simple.html' %}
<div style="background: #ccffcc; padding: 1rem; border: 2px solid green; margin: 1rem 0;">
<strong>DEBUG: Finished including targeting selector widget</strong>
</div>
<input type="hidden" id="targeting-data" name="targeting_template" value="{{ product.targeting_template | tojson if product.targeting_template else '{}' }}">

<div style="margin-top: 2rem;">
Expand Down
5 changes: 5 additions & 0 deletions templates/targeting_browser.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

{% block content %}
<style>
/* Ensure tab-content wrapper is always visible */
.targeting-browser .tab-content {
display: block !important;
}

/* Fix Bootstrap tab visibility - allow proper tab switching */
.targeting-browser .tab-pane {
display: none;
Expand Down
Loading