{% extends "admin/base.html" %}
{% block content %}
    <form method="post" action="{% url 'admin:queue_confirm' %}">
        {% csrf_token %}
        <h3>{{ form.urls.label }}</h3>
        {{ form.urls.errors }}
        {{ form.urls }}
        {% if form.urls.help_text %}
            <p class="help">{{ form.urls.help_text|safe }}</p>
        {% endif %}


        {% if crawl_policies %}
            <input type="submit" name="action" value="Refresh" style="margin-top: 5px">

            <h3>Crawl polic{{ crawl_policies|length|pluralize:"y,ies" }}</h3>
            {% if crawl_policies|length == 1 %}
                <p>
                    This URL will be crawled with policy <a href="{% url 'admin:se_crawlpolicy_change' crawl_policy.id %}">{{ crawl_policy }}</a>:
                </p>
                <p>
                    {% include "admin/crawl_policy_desc.html" with add_to_queue=True label_tag="label_tag" %}
                </p>
                <p>
                    <a href="{% url 'admin:se_crawlpolicy_add' %}?url_regex={{ urls|first|urlencode }}">Create a new policy</a>
                </p>
            {% else %}
                <p>
                    These URLs will be crawled with policies:
                    <ul>
                        {% for crawl_policy in crawl_policies %}
                            <li><a href="{% url 'admin:se_crawlpolicy_change' crawl_policy.id %}">{{ crawl_policy }}</a></li>
                        {% endfor %}
                    </ul>
                </p>
            {% endif %}

            {% if crawl_policy.recursion == CrawlPolicy.CRAWL_ON_DEPTH or settings.SOSSE_BROWSABLE_HOME %}
                <h3>Parameters</h3>
            {% endif %}
            {% if crawl_policy.recursion == CrawlPolicy.CRAWL_ON_DEPTH %}
                {{ form.recursion_depth.errors }}
                {{ form.recursion_depth.label_tag }} {{ form.recursion_depth }}
                {% if form.recursion_depth.help_text %}
                    <small><p class="help">{{ form.recursion_depth.help_text|safe }}</p></small>
                {% endif %}
            {% endif %}
            {% if settings.SOSSE_BROWSABLE_HOME %}
                {{ form.show_on_homepage.errors }}
                {{ form.show_on_homepage }}
                <label class="vCheckboxLabel" for="id_show_on_homepage">Show on homepage</label>

                {% if form.show_on_homepage.help_text %}
                    <small><p class="help">{{ form.show_on_homepage.help_text|safe }}</p></small>
                {% endif %}
            {% endif %}
            <input type="hidden" name="confirmation" value="1">
            <p>
                <input type="submit" name="action" value="Confirm" autofocus>
            </p>
        {% else %}
            <input type="submit" name="action" value="Check and queue" style="margin-top: 5px">
        {% endif %}
    </form>
{% endblock %}
