{% extends "base.html" %}
{% load url from future %}
{% load i18n %}
{% load translations %}

{% block content %}

{% if form.errors or userform.errors or subscriptionform.errors %}
<div class="ui-widget">
    <div style="padding: 0pt 0.7em;" class="ui-state-error ui-corner-all"> 
        <p><span style="float: left; margin-right: 0.3em;" class="ui-icon ui-icon-alert"></span>
        {% trans "Please fix errors in the form." %}
        </p>
    </div>
</div>
{% endif %}

<form method="post" action="{% url 'profile' %}">
{% csrf_token %}
<div class="tabs preferences" id="tabs-preferences">
<ul>
<li><a href="#preferences">{% trans "Preferences" %}</a></li>
<li><a href="#subscriptions">{% trans "Subscriptions" %}</a></li>
<li><a href="#account">{% trans "Account" %}</a></li>
<li><a href="#auth">{% trans "Authentication" %}</a></li>
<li><a href="#info">{% trans "Information" %}</a></li>
<li><a href="#licenses">{% trans "Licenses" %}</a></li>
{% if enable_avatars %}
<li><a href="#avatar">{% trans "Avatar" %}</a></li>
{% endif %}
<li><a href="#remove">{% trans "Removal" %}</a></li>
</ul>
<div id="preferences">
<table>
{{ form.as_table }}
</table>
</div>
<div id="subscriptions">
<p>{% trans "You will receive chosen notifications via email for all your languages." %}</p>
<table>
{{ subscriptionform.as_table }}
</table>
</div>
<div id="account">
<table>
{{ userform.as_table }}
</table>
<span class="helptext">{% trans "Your name and email will appear as author on Git commits." %}</span>
</div>
<div id="auth">

<p><a href="{% url 'password' %}" class="button">{% if request.user.has_usable_password %}{% trans "Change password" %}{% else %}{% trans "Set password" %}{% endif %}</a></p>

<p>{% trans "You can manage third party identities which are associated to this account." %}</p>
<p>{% trans "Currently associated:" %}</p>
<table>
<thead>
<tr>
<th>{% trans "Identity" %}</th>
<th>{% trans "User ID" %}</th>
<th>{% trans "Action" %}</th>
</td>
</tr>
<tbody>
{% for assoc in associated %}
<tr>
<th>{{ assoc.provider }}</th>
<td>{{ assoc.uid }}</th>
<td>
<a href="{% url 'social:disconnect_individual' assoc.provider assoc.id %}?next={% url 'profile' %}" class="disconnect button">{% trans "Disconnect" %}</a>
</td>

</tr>
{% endfor %}
</tbody>
</table>

{% if new_backends %}
<p>{% trans "Add new association:" %}</p>
{% for name in new_backends %}
  <a class="button" href="{% url 'social:begin' name %}?next={% url 'profile' %}">{{ name }}</a>
{% endfor %}
{% endif %}

</div>
<div id="info">
{% with request.user as user %}
{% include 'user-activity.html' %}
{% endwith %}
<p>
{% url 'user_page' user=request.user.username as user_page%}
{% trans "Your public profile:" %}
<a href="{{ user_page }}">{{ user_page }}</a>
</p>
</div>
<div id="licenses">
<p>
{% trans "By registering you agree to use your name and email in Git commits and provide your contribution under license defined by each translated project." %}
</p>

{% if licenses %}
<p>{% trans "Following projects have explicitly specified their licensing and copyright conditions:" %}</p>
<dl>
{% for project in licenses %}
<dt><strong>{{ project.name }}</strong></dt>
<dd>
{% if project.license_url %}
<a href="{{ project.license_url }}">{{ project.license }}</a></p>
{% else %}
{{ project.license }}
{% endif %}
</dd>
{% endfor %}
</dl>
{% endif %}
</div>
{% if enable_avatars %}
<div id="avatar">
<p class="border"><img src="{% url 'user_avatar' user=request.user.username size=128 %}" /></p>
<p><a href="https://www.libravatar.org/">{% trans "Avatars are provided using libravatar." %}</a></p>
</div>
{% endif %}

<div id="remove">
{% show_message 'warning' _('Removal of the account deletes all your private data.') %}
<p><a class="button" href="{% url 'remove' %}">{% trans "Remove my account" %}</a></p>
</div>
</div>


<input type="submit" value="{% trans "Save" %}" class="button" />
</form>
<form method="post" action="" id="disconnect-form">{% csrf_token %}</form>

{% endblock %}
