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


{% block title %}Step 2: Shibboleth{% 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: Shibboleth
</div>
{% endblock %}


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

    <form action="." method="post">{% csrf_token %}
        {% if done %}
            <p>There is no need to register for shibboleth. {{ 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 saml_session %}
            {% if status %}
            <ul class="errorlist">
                <li>{{ status }}</li>
            </ul>
            {% endif %}
            <p>You have an established SAML 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 SAML. {% 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>
            <input type="submit" name="logout" value="SAML Logout" class="button" />
        {% else %}
            {% if status %}
            <ul class="errorlist">
                <li>{{ status }}</li>
            </ul>
            {% endif %}
            <p>Please choose your institute below to register your shibboleth identity:</p>
            {% form_as_div form %}
            <input type="submit" name="login" value="SAML Login" class="button" />
            <h3>Contact</h3>
            <p>Please contact {{ accounts_email }} for further information.</p>
        {% endif %}

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