
{% extends "base.html" %}

{% block left_content %}
<div class="box box-50">
    <div class="boxin">
        <div class="header">
            <h3>Welcome to Gmail migration tool!</h3>
        </div>
        <div class="content">
            {% if migrations %}
            <table class="calendar" cellspacing="0">
                <thead>
                    <tr>
                        <th class="month first last">
                            Unfinished migrations:
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <tr class="first">
                        <td>
                            <ul>
                            {% for migration in migrations %}
                            <li>
                                <a href="{% url migrate_mail.migrate migration=migration.id %}">
                                    Migration from <em>{{ migration.from_email }}</em> 
                                    to <em>{{ migration.to_username }}@{{ migration.domain }}</em>
                                </a>
                                [ stopped at 
                                    {% if migration.labels_processed %}
                                        mail importing, imported {{ migration.message_cnt|default:0 }} messages
                                    {% else %}
                                        importing labels
                                    {% endif %}
                                ]
                                &bull;
                                <a onclick="return confirm('Are you sure?');" href="{% url migrate_mail.migrate_delete migration=migration.id %}">Delete</a>
                            </li>
                            {% endfor %}
                            </ul>
                        </td>
                    </tr>
                </tbody>
            </table>
            {% else %}
            <table class="calendar" cellspacing="0">
                <thead>
                    <tr>
                        <th class="month first last">
                            There are no unfinished migrations now. Thank you.
                        </th>
                    </tr>
                </thead>
            </table>
            {% endif %}
        </div>
    </div>
</div>
{% endblock %}

{% block right_content %}
<div class="box box-50">
    <div class="boxin">
        <div class="header">
            <h3>New migration</h3>
        </div>
        <form class="basic" action="" method="post">
            <div class="inner-form">
                {% for error in form.non_field_errors %}
                    <div class="msg msg-error"><p>{{ error }}</p></div>
                {% empty %}
                    {% if form.errors %}
                        <div class="msg msg-warn"><p>Please correct errors and press "Start copying" to start migration.</p></div>
                    {% else %}
                        <div class="msg msg-info"><p>Please input details and press "Start copying" to start migration.</p></div>
                    {% endif %}
                {% endfor %}
                <dl>
                {% for field in form %}
                    {% if field.is_hidden %}
                        {{ field }}
                    {% else %}
                        <dt>{{ field.label_tag }}</dt>
                        <dd>
                            {{ field }}
                            {% for error in field.errors %}
                                <small>{{ error }}</small>
                            {% empty %}
                                <small>&nbsp;</small>
                            {% endfor %}
                        </dd>
                    {% endif %}
                {% endfor %}
                    <dt></dt>
                    <dd>
                        <input class="button" type="submit" value="Start copying">
                    </dd>
                </dl>
            </div>
        </form>
    </div>
</div>
{% endblock %}
