{% extends 'admin/change_form.html' %}
{% load baton_tags %}

{% block content %}{{ block.super }}

{% for template, field, position in adminform.model_admin.baton_form_includes %}
    <template id="template-{{ field }}" data-position="{{ position }}">
        <div id='template-{{ field }}-container' class="baton-form-include baton-form-include-{{ position }}">
            {% include template %}
        </div>
    </template>
{% endfor %}

{% if adminform.model_admin.baton_form_object_tools_include %}
    <template id="template-object-tools" data-position="{{ adminform.model_admin.baton_form_object_tools_include.1 }}">
        {% include adminform.model_admin.baton_form_object_tools_include.0 %}
    </template>
{% endif %}

{% if adminform.model_admin.baton_summarize_fields %}
    {% for field, items in adminform.model_admin.baton_summarize_fields.items %}
        {% for item in items %}
            <script>
                Baton.Dispatcher.register('onReady', function () {
                    Baton.AI.addSummarization('{{ field }}', {{ item|to_json|safe }});
                })
            </script>
        {% endfor %}
    {% endfor %}
{% endif %}

{% if adminform.model_admin.baton_vision_fields %}
    {% for field, items in adminform.model_admin.baton_vision_fields.items %}
        {% for item in items %}
            <script>
                Baton.Dispatcher.register('onReady', function () {
                    Baton.AI.addVision('{{ field }}', {{ item|to_json|safe }});
                })
            </script>
        {% endfor %}
    {% endfor %}
{% endif %}

{% endblock %}
