{% extends "stg_detail.html" %}

{% block title %}{{ title }}{% endblock %}

{% block details %}

<h1><a href="{{ obj.get_absolute_url }}">ImportBatch {{ obj.id }}</a></h1>

<h2 class="batch_status_{{ obj.status }}">Status: {{ obj.status|capfirst }}</h2>

<ul>
    {% if eta %}
    <li>Estimated runtime: {{ eta|floatformat:1 }} hours</li>
    {% endif %}
    {% if obj.start %}
    <li>Started: {{ obj.hr_start }}</li>
    {% else %}
    <li><a href="{% url 'djhcup_staging.views.run_batch' obj_id=obj.id obj_type='ImportBatch' %}">Run this batch</a></li>
    {% endif %}
    {% if obj.complete %}
        <li>Completed: {{ obj.hr_complete }}</li>
        <li>Actual runtime {{ obj.hr_runtime|floatformat:1 }} hours</li>
    {% endif %}
    <li>Enqueued in batch: {{ enqueued|length }}</li>
    <li><a href="/admin/djhcup_staging/importbatch/{{ obj.id }}/">See this batch in the Django admin&rarr;</a></li>
</ul>

{% if enqueued|length > 0 %}
    <h2>Batch Contents</h2>
    <table class="batch_items">
    <tr><th>Item</th><th>Size (MB)</th><th>Estimated Runtime<br />(hours, SID CORE files)</th><th>Status</th></tr>
    {% for e in enqueued %}
        <tr class="status_{{ e.status }}">
            <td><a href="{{ e.get_absolute_url }}">{{ e.file.filename }}</a></td>
            <td>{{ e.file.hr_size }}</td>
            <td>{{ e.est_runtime|floatformat:1 }}</td>
            <td>{{ e.status }}{% if e.message %}<br
                />{{ e.message }}{% endif %}{% if e.start %}<br
                />Started {{ e.hr_start }}{% if e.complete %}<br
                />Completed {{ e.hr_complete }}{% for st in e.stagingtable_set.all %}<br
                /><a href="{{ st.get_absolute_url }}">StagingTable #{{ st.pk }}: {{ st.name }}</a>{% endfor %}
                {% endif %}
                {% endif %}</td>
        </tr>
    {% endfor %}
    </table>
{% endif %}

{% endblock %}
