{% extends "base.html" %}
{% load i18n %}

{% block content %}
<h2>{% trans 'Task' %} #{{ task.id }}: {{ task.method }}</h2>

<h3>{% trans 'Details' %}</h3>
<table class="details">
  <tr>
    <th>{% trans "ID" %}</th>
    <td>{{ task.id }}</td>
  </tr>
  <tr>
    <th>{% trans "Method" %}</th>
    <td>{{ task.method }}</td>
  </tr>
  <tr>
    <th>{% trans "Args" %}</th>
    <td>{% for arg in task.get_args_display.iteritems %}<b>{{ arg.0 }}:</b> {{ arg.1 }}<br />{% endfor %}</td>
  </tr>
  <tr>
    <th>{% trans "Label" %}</th>
    <td>{{ task.label }}</td>
  </tr>
  <tr>
    <th>{% trans "State" %}</th>
    <td class="{{ task.get_state_display }}">{{ task.get_state_display }}</td>
  </tr>

  <tr>
    <th>{% trans "Worker" %}</th>
    <td>{% if task.worker %}{{ task.worker }}{% endif %}</td>
  </tr>
  <tr>
    <th>{% trans "Channel" %}</th>
    <td>{{ task.channel }}</td>
  </tr>
  <tr>
    <th>{% trans "Arch" %}</th>
    <td>{{ task.arch }}</td>
  </tr>

  <tr>
    <th>{% trans "Exclusive" %}</th>
    <td>{{ task.exclusive }}</td>
  </tr>
  <tr>
    <th>{% trans "Priority" %}</th>
    <td>{{ task.priority }}</td>
  </tr>
  <tr>
    <th>{% trans "Waiting" %}</th>
    <td>{{ task.waiting }}</td>
  </tr>
  <tr>
    <th>{% trans "Awaited" %}</th>
    <td>{{ task.awaited }}</td>
  </tr>
  <tr>
    <th>{% trans "Owner" %}</th>
    <td>{{ task.owner }}</td>
  </tr>
{% if task.resubmitted_by %}
  <tr>
    <th>{% trans "Resubmitted by" %}</th>
    <td>{{ task.resubmitted_by }}</td>
  </tr>
{% endif %}
{% if task.resubmitted_from %}
  <tr>
    <th>{% trans "Resubmitted from" %}</th>
    <td>#{{ task.resubmitted_from.id }} <a href="{% url 'task/detail' task.resubmitted_from.id %}">task</a></td>
  </tr>
{% endif %}
  <tr>
    <th>{% trans "Created" %}</th>
    <td>{% if task.dt_created %}{{ task.dt_created|date:"Y-m-d H:i:s" }}{% endif %}</td>
  </tr>
  <tr>
    <th>{% trans "Started" %}</th>
    <td>{% if task.dt_started %}{{ task.dt_started|date:"Y-m-d H:i:s" }}{% endif %}</td>
  </tr>
  <tr>
    <th>{% trans "Finished" %}</th>
    <td>{% if task.dt_finished %}{{ task.dt_finished|date:"Y-m-d H:i:s" }}{% endif %}</td>
  </tr>
  <tr>
      <th>{% trans "Spent time" %}</th>
      <td>{{ task.get_time_display }}</td>
  </tr>
  <tr>
    <th>{% trans "Comment" %}</th>
    <td>{% if task.comment %}{{ task.comment }}{% endif %}</td>
  </tr>
</table>


<h3>{% trans 'Result' %}</h3>
<pre class="log">
{{ task.result }}
</pre>


{% if logs %}
<h3>{% trans 'Logs' %}</h3>
<ul>
{% for log in logs %}
  <li><a href="{% url 'task/log' task.id log %}">{{ log }}</a> [<a href="{% url 'task/log' task.id log %}?format=raw">download</a>]</li>
{% endfor %}
</ul>
{% endif %}


{% if task_list %}
<h3>{% trans 'Subtask list' %}</h3>
{% include "task/list_include.html" %}
{% endif %}

{% endblock %}
