{% extends "forms.html" %}
{% load forms %}
{% load applications %}
{% load render_table from django_tables2 %}


{% block title %}Duplicate Applicant{% endblock %}


{% block breadcrumbs %}
<div class="breadcrumbs">
    <a href='{% url "index" %}'>Home</a>&nbsp;›
    <a href="{% url 'kg_application_list' %}">Applications</a>&nbsp;›
    <a href='{% url 'kg_application_detail' application.pk %}'>{{ application }}</a>&nbsp;›
    Duplicate Applicant
</div>
{% endblock %}


{% block content %}
<p>The following applicant in this application has been declared a duplicate:</p>
<div class="module">
    <h2>Applicant Details</h2>
    <div class="table-container">
        <table class="keyvalue">
            <tr><th>Name:</th><td>{{ application.applicant }}</td></tr>
            <tr><th>Institute:</th><td>{{ application.applicant.institute }}</td></tr>
            <tr><th>Username:</th><td>{{ application.applicant.username }}</td></tr>
            <tr><th>Email:</th><td>{{ application.applicant.email|urlize }}</td></tr>
        </table>
    </div>
</div>

{% if not application.existing_person %}
{% if application.applicant.similar_people %}
<div class="module">
    <form method="post" action=".">{% csrf_token %}
        <h2>Similar People</h2>
        <p>Please check that the applicant isn't an existing user.</p>
        {% get_similar_people_table  application.applicant as table %}
        {% render_table table %}
    </form>
</div>
{% endif %}
{% endif %}

<div class="module">
    <h2>Confirm</h2>
    <p>Please replace the applicant with an existing person, reopen the
    application, or cancel it.</p>


    <form method="post" action=".">{% csrf_token %}
        <div>
            {% load forms %}
            {% if form.errors or form.non_field_errors %}
            <div class="errornote">Please correct the error(s) below.</div>
            {% endif %}

            <fieldset class="aligned ()">
                {{ form.non_field_errors }}
                {% form_as_div form %}
                <input type="submit" name="replace" value="Replace applicant" class="button" />
            </fieldset>
        </div>

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