{% extends "forms.html" %}
{% load forms %}
{% load applications %}


{% block title %}Step 2: AAF{% endblock %}


{% block breadcrumbs %}
<div class="breadcrumbs">
    <a href='{% url "index" %}'>Home</a>&nbsp;›
    <a href="{% url 'kg_application_list' %}">Applications</a>&nbsp;›
    {{ application }}&nbsp;›
    Step 2: AAF
</div>
{% endblock %}


{% block content %}
<div class="module">
    <h2>2. AAF</h2>

    <form action="." method="post">{% csrf_token %}
        {% if done %}
            <p>There is no need to register for AAF. {{ status }}</p>

            <p>The email address associated with this application is set to
            <b>{{ application.applicant.email }}</b>. This email address will receive all
            notifications concerning this application.</p>
        {% elif session_jwt %}
            {% if status %}
            <ul class="errorlist">
                <li>{{ status }}</li>
            </ul>
            {% endif %}
            <p>You have an established AAF session.</p>
            <div class="table-container">
                <table class="keyvalue">
                    {% for key,value in attrs.items %}
                    <tr><th>{{ key }}</th><td>{{ value }}</td></tr>
                    {% endfor %}
                </table>
            </div>
            <p>If you continue, then your details, including
            your email address, will be replaced by those above and you will be
            able to log in using AAF. {% if attrs.email != application.applicant.email %}
            All future emails concerning this application
            will then go to <b>{{ attrs.email }}</b> instead of
            {{ application.applicant.email }}. {% endif %}</p>
            <p>If the information above is not correct, then please do not
            continue.</p>
        {% else %}
            {% if status %}
            <ul class="errorlist">
                <li>{{ status }}</li>
            </ul>
            {% endif %}
            <p>Please choose your institute below to register your AAF identity:</p>
            {% form_as_div form %}
            <input type="submit" name="login" value="Login" class="button" />
            <h3>Contact</h3>
            <p>Please contact {{ accounts_email }} for further information.</p>
        {% endif %}

        {% application_actions %}
    </form>
</div>
{% endblock %}
