{% extends "base.html" %}

{% block title %}
	&raquo; DC Contracts &raquo; {{contract.name}} &raquo;
 	Automatic HH Data Downloader
{% endblock %}

{% block nav %}
	<a href="/e/dc_contracts">DC Contracts</a> &raquo; 
	<a href="/e/dc_contracts/{{contract.id}}">{{contract.name}}</a> &raquo; 
	Automatic HH Data Downloader
{% endblock %}

{% block content %}

	{% if task %}

		<table>
			<caption>
				<a href="/e/dc_contracts/{{contract.id}}/auto_importer">Refresh page</a>
			</caption>
			<tr>
				<th>Is Locked?</th>
				<th>Is stopping?</th>
			</tr>
			<tr>
				<td>{{task.is_locked()}}</td>
				<td>{{task.stopped.isSet()}}</td>
			</tr>
		</table>        

		<form method="post">
			<fieldset {% if task.is_locked() %}disabled{% endif %}>
				<legend>Import Now</legend>
				<input type="hidden" name="dc_contract_id" value="{{contract.id}}">
				<input type="submit" value="Import" name="now">
			</fieldset>
		</form>

		<h2>Log</h2>

		<p>{{ task.get_status() }}</p>

		<ul>
			{% for message in task.messages %}
				<li>{{message}}</li>
			{% endfor %}
		</ul>

	{% else %}

		<p>The importer task has not been started.</p>

	{% endif %}

{% endblock %}
