{% extends "admin/base_site.html" %}
{% load i18n admin_static admin_urls %}

{% block extrastyle %}
<link rel="stylesheet" type="text/css" href="{% static 'admin/css/forms.css' %}" />
{% include "admin/inc/extrastyle.html" %}
{% endblock %}

{% block breadcrumbs %}
<div class="breadcrumbs">
    <a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
    &rsaquo;
    <a href="{% url 'admin:app_list' app_label=opts.app_label %}">
        {{ opts.app_config.verbose_name }}
    </a>
    &rsaquo;
    <a href="{% url opts|admin_urlname:'changelist' %}">{{ module_name }}</a>
    &rsaquo;
    &rsaquo; {{ project.short_description }}
    </div>
{% endblock %}

{% block content %}
<div id="content-main">
    <h1>{{ project.short_description }}</h1>
    <table class="collapse-left">
        <tr>
            <th>Start date</th>
            <td>{{ project.start_datetime }}</td>
        </tr>
        <tr>
            <th>Priority</th>
            <td>{{ project.priority }}</td>
        </tr>
        <tr>
            <th>Team messages document URL</th>
            <td>
                <a href="{{ project.review_document_url }}">
                    {{ project.review_document_url }}
                </a>
            </td>
        </tr>
        <tr>
            <th>Project data</th>
            <td class="project-data">
                <table class="collapse-left">
                    {% for key, value in project.project_data.items %}
                    <tr>
                        <th>{{ key }}</th>
                        <td>
                        {% if 'URL' in key %}
                            <a href="{{ value }}">{{ value }}</a>
                        {% else %}
                            {{ value }}
                        {% endif %}
                        </td>
                    </tr>
                    {% endfor %}
                </table>
            </td>
        </tr>
    </table>
    <h2>Progress</h2>
    <ol class="tasks">
    {% for task in tasks %}
        <li>
            <p>
                <strong>{{ task.step_description }}:</strong> {{ task.status }}
                {% if 'start_datetime' in task %}
                    (Created {{ task.start_datetime }})
                {% endif %}
            </p>

            {% if task.assignments %}
            Assignments:
            <ul>
                {% for assignment in task.assignments %}
                <li class="task-assignment">
                    <table class="collapse-left">
                        <tr>
                            <th>Worker</th>
                            <td>{{ assignment.worker }}</td>
                        </tr>
                        <tr>
                            <th>Start date</th>
                            <td>{{ assignment.start_datetime }}</td>
                        </tr>
                        <tr>
                            <th>Status</th>
                            <td>{{ assignment.status }}</td>
                        </tr>
                    </table>
                </li>
                {% endfor %}
            </ul>
            {% endif %}

            {% if task.latest_data %}
            <strong>Additional Info:</strong>
            <ul>
                {% for key, value in task.latest_data.items %}
                <li>{{ key }}: {{ value }}</li>
                {% endfor %}
            </ul>
            {% endif %}
        </li>
    {% endfor %}
    </ol>
</div>
{% endblock %}
