{% extends 'base.html' %}                                                                                                                      
{% load i18n %}
{% load static %}

{% block title %}{% trans 'Your Profile' %}{% endblock title %}

{% block content %}

<h1>
  {% trans 'Your Profile' %} - 
  {% if user.first_name and user.last_name %}
    {{ user.first_name }} {{ user.last_name }}
  {% else %}
    {{ user.username }}
  {% endif %}
</h1>

{% if user.confirmedemail_set.count or user.confirmedopenid_set.count %}
<p>{% trans 'You have the following confirmed email addresses and OpenIDs:' %}</p>
<ul class="horizontal-list avatar-list">
    {% for email in user.confirmedemail_set.all %}
        <li><form action="{% url 'remove_confirmed_email' email.id %}" method="post">{% csrf_token %}
        <a href="{% url 'assign_photo_email' email.id %}">
        {% if email.photo %}
            <img class="thumbnail editable avatar-chooser" src="{% url 'raw_image' email.photo.id %}" alt=""></a>
        {% else %}
            <img class="thumbnail editable avatar-chooser" src="{% static '/img/nobody/64.png' %}" alt="Nobody"></a>
        {% endif %}
        {{ email.email }}
        <br><a href="{% url 'assign_photo_email' email.id %}">{% trans 'Change photo' %}</a>
        <br><br><input type="image" src="{% static '/img/delete_button.png' %}" value="{% trans 'Remove' %}"></form></li>
    {% endfor %}
    {% for openid in user.confirmedopenid_set.all %}
        <li><form action="{% url 'remove_confirmed_openid' openid.id %}" method="post">{% csrf_token %}
        <a href="{% url 'assign_photo_openid' openid.id %}">
        {% if openid.photo %}
            <img class="thumbnail editable avatar-chooser" src="{% url 'raw_image' openid.photo.id %}" alt=""></a>
        {% else %}
            <img class="thumbnail editable avatar-chooser" src="{% static '/img/nobody/64.png' %}" alt=""></a>
        {% endif %}
        {{openid.openid}}
        <br><a href="{% url 'assign_photo_openid' openid.id %}">{% trans 'Change photo' %}</a>
        <br><br><input type="image" src="{% static '/img/delete_button.png' %}" value="{% trans 'Remove' %}"></form></li>
    {% endfor %}
</ul>
<div class="clear-both"></div>
{% endif %}

{% if user.unconfirmedemail_set.count or user.unconfirmedopenid_set.count %}
<p>{% trans 'You have the following unconfirmed email addresses and OpenIDs:' %}</p>
<ul class="vertical-list">
    {% for email in user.unconfirmedemail_set.all %}
        <li><form action="{% url 'remove_unconfirmed_email' email.id %}" method="post">{% csrf_token %}{{ email.email }}
        <input type="image" src="{% static '/img/delete_button.png' %}" value="{% trans 'Remove' %}"></form>{# TODO: (expires in xx hours) #}</li>
    {% endfor %}
    {% for openid in user.unconfirmedopenid_set.all %}
        <li><form action="{% url 'remove_unconfirmed_openid' openid.id %}" method="post">{% csrf_token %}{{ openid.openid }}
        <input type="image" src="{% static '/img/delete_button.png' %}" value="{% trans 'Remove' %}"></form>{# TODO: (expires in xx hours) #}</li>
    {% endfor %}
</ul>
{% endif %}

<p>
{% if not max_emails %}
<a href="{% url 'add_email' %}">{% trans 'Add a new email address' %}</a>
|
{% endif %}
<a href="{% url 'add_openid' %}">{% trans 'Add a new OpenID' %}</a></p>
</p>

{% if user.photo_set.count %}
<p>{% trans 'Here are the photos you have uploaded/imported:' %}</p>
<ul class="horizontal-list avatar-list centered">
{% for photo in user.photo_set.all %}
<li><a href="{% url 'raw_image' photo.id %}"><img class="thumbnail" src="{% url 'raw_image' photo.id %}" title="{% blocktrans with photo.add_date as datetime %}Uploaded on {{ datetime }}{% endblocktrans %}" alt="{% blocktrans with photo.add_date as datetime %}Uploaded on {{ datetime }}{% endblocktrans %}"></a><br>
    <a href="{% url 'delete_photo' photo.id %}">{% trans 'Delete' %}</a></li>
{% endfor %}
</ul>
{% endif %}

{% if not max_photos %}
<p><a href="{% url 'upload_photo' %}">{% trans 'Upload a new photo' %}</a></p>
{% endif %}

<h2>{% trans 'Account settings' %}</h2>

{% if has_password %}
<p><a href="{% url 'password_change' %}">{% trans 'Change your password' %}</a></p>
{% else %}
<p><a href="{% url 'password_set' %}">{% trans 'Set a password' %}</a></p>
{% endif %}

<!-- <p><a href="{% url 'export' %}">{% trans 'Export your data' %}</a></p> -->

<p><a href="{% url 'delete' %}">{% trans 'Permanently delete your account' %}</a></p>

{% endblock content %}
