{% extends "base.html" %}
{% load i18n %}
{% load translations %}
{% load authnames %}
{% load crispy_forms_tags %}

{% block breadcrumbs %}
<li><a href="{% url 'profile' %}">{% trans "Your profile" %}</a></li>
{% endblock %}

{% block content %}

{% if form.errors or userform.errors or subscriptionform.errors %}
{% show_message "error" _("Please fix errors in the form.") %}
{% endif %}

<form method="post" action="{% url 'profile' %}">
{% csrf_token %}

<ul class="nav nav-pills">
<li class="active"><a data-toggle="tab" href="#languages">{% trans "Languages" %}</a></li>
<li><a data-toggle="tab" href="#preferences">{% trans "Preferences" %}</a></li>
<li><a data-toggle="tab" href="#subscriptions">{% trans "Subscriptions" %}</a></li>
<li><a data-toggle="tab" href="#account">{% trans "Account" %}</a></li>
<li><a data-toggle="tab" href="#auth">{% trans "Authentication" %}</a></li>
<li><a data-toggle="tab" href="#profile">{% trans "Profile" %}</a></li>
<li><a data-toggle="tab" href="#licenses">{% trans "Licenses" %}</a></li>
</ul>

<div class="tab-content">
<div class="tab-pane active" id="languages">
<div class="row">
<div class="col-lg-6">
<div class="panel panel-primary">
  <div class="panel-heading"><h4 class="panel-title">{% trans "Languages" %}</h4></div>
  <div class="panel-body">
    {{ form|crispy }}
  </div>
  <div class="panel-footer">
    <input type="submit" value="{% trans "Save" %}" class="btn btn-default" />
  </div>
</div>
</div>
<div class="col-lg-6 hidden-xs">
<div class="panel panel-primary">
  <div class="panel-heading"><h4 class="panel-title">{% trans "Description" %}</h4></div>
  <div class="panel-body">
    <p>
      {% blocktrans %}Choose which languages you prefer to translate. These will be offered to you on the dashboard to have easier access to chosen translations.{% endblocktrans %}
    </p>
    <p>
      {% blocktrans %}The secondary languages are shown next to the source string when translating.{% endblocktrans %}
    </p>
  </div>
  <div class="panel-footer">
  <a class="btn btn-default" href="{% documentation 'user/profile' 'languages' %}">{% trans "Documentation" %}</a>
  </div>
</div>
</div>
</div>
</div>
<div class="tab-pane" id="preferences">
<div class="row">
<div class="col-lg-6">
<div class="panel panel-primary">
  <div class="panel-heading"><h4 class="panel-title">{% trans "Preferences" %}</h4></div>
  <div class="panel-body">
    {{ usersettingsform|crispy }}
  </div>
  <div class="panel-footer">
    <input type="submit" value="{% trans "Save" %}" class="btn btn-default" />
  </div>
</div>
</div>
<div class="col-lg-6 hidden-xs">
<div class="panel panel-primary">
  <div class="panel-heading"><h4 class="panel-title">{% trans "Description" %}</h4></div>
  <div class="panel-body">
    <p>
      {% blocktrans %}Customize Weblate behavior to match your personal preferences.{% endblocktrans %}
    </p>
  </div>
  <div class="panel-footer">
  <a class="btn btn-default" href="{% documentation 'user/profile' 'preferences' %}">{% trans "Documentation" %}</a>
  </div>
</div>
</div>
</div>
</div>
<div class="tab-pane" id="subscriptions">
<div class="row">
<div class="col-lg-6">
{% with user.project_set.all as managed_projects %}
{% if managed_projects %}
<div class="panel panel-primary">
  <div class="panel-heading"><h4 class="panel-title">{% trans "Managed projects" %}</h4></div>
  <div class="panel-body">
    <div class="list-group">
{% for project in managed_projects %}
      <a class="list-group-item" href="{{ project.get_absolute_url }}">{{ project }}</a>
{% endfor %}
    </div>
    <p class="helptext">{% trans "You will automatically receive important notifications on managed projects." %}</p>
  </div>
</div>
{% endif %}
{% endwith %}
<div class="panel panel-primary">
  <div class="panel-heading"><h4 class="panel-title">{% trans "Subscribed projects" %}</h4></div>
  <div class="panel-body">
{% crispy subscriptionform %}
  </div>
  <div class="panel-footer">
    <input type="submit" value="{% trans "Save" %}" class="btn btn-default" />
  </div>
</div>
</div>
<div class="col-lg-6 hidden-xs">
<div class="panel panel-primary">
  <div class="panel-heading"><h4 class="panel-title">{% trans "Description" %}</h4></div>
  <div class="panel-body">
    <p>{% trans "You will receive chosen notifications via email for all your languages." %}</p>
  </div>
  <div class="panel-footer">
  <a class="btn btn-default" href="{% documentation 'user/profile' 'subscriptions' %}">{% trans "Documentation" %}</a>
  </div>
</div>
<div class="panel panel-primary">
  <div class="panel-heading"><h4 class="panel-title">{% trans "Subscription settings" %}</h4></div>
  <div class="panel-body">
{{ subscriptionsettingsform|crispy }}
  </div>
  <div class="panel-footer">
    <input type="submit" value="{% trans "Save" %}" class="btn btn-default" />
  </div>
</div>
</div>
</div>
</div>
<div class="tab-pane" id="account">
<div class="row">
<div class="col-lg-6">
<div class="panel panel-primary">
  <div class="panel-heading"><h4 class="panel-title">{% trans "Account" %}</h4></div>
  <div class="panel-body">
{{ userform|crispy }}
  </div>
  <div class="panel-footer">
    <input type="submit" value="{% trans "Save" %}" class="btn btn-default" />
  </div>
</div>
</div>
<div class="col-lg-6 hidden-xs">
<div class="panel panel-primary">
  <div class="panel-heading"><h4 class="panel-title">{% trans "Description" %}</h4></div>
  <div class="panel-body">
    <p>{% trans "Your name and email will appear as author on the commits." %}</p>
  </div>
  <div class="panel-footer">
  <a class="btn btn-default" href="{% documentation 'user/profile' %}">{% trans "Documentation" %}</a>
  </div>
</div>
</div>
</div>
</div>
<div class="tab-pane" id="auth">
<div class="row">
<div class="col-lg-6">
<div class="panel panel-primary">
  <div class="panel-heading"><h4 class="panel-title">{% trans "User identities" %}</h4></div>
  <div class="panel-body">
<p>{% trans "You can manage identities which are associated to this account and which can be used to log in." %}</p>
<p>{% trans "Currently associated:" %}</p>
<table class="table table-condensed">
<thead>
<tr>
<th>{% trans "Identity" %}</th>
<th>{% trans "User ID" %}</th>
<th>{% trans "Action" %}</th>
</td>
</tr>
<tbody>
<tr>
<th>{% trans "Password" %}</th>
<td>{{ request.user.username }}</td>
<td>
<a href="{% url 'password' %}" class="btn btn-default">{% if request.user.has_usable_password %}{% trans "Change password" %}{% else %}{% trans "Set password" %}{% endif %}</a>
</td>
</tr>
{% for assoc in associated %}
<tr>
<th>{% auth_name assoc.provider '' ' ' %}</th>
<td>{{ assoc.uid }}</th>
<td>
{% if associated.count > 1 %}
<a href="{% url 'social:disconnect_individual' assoc.provider assoc.id %}?next={% url 'profile' %}" class="disconnect btn btn-danger"><i class="fa fa-trash"></i> {% trans "Disconnect" %}</a>
{% endif %}
</td>

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

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


<div class="panel panel-danger">
  <div class="panel-heading"><h4 class="panel-title">{% trans "Removal" %}</h4></div>
  <div class="panel-body">

    <p>{% trans "Removal of the account deletes all your private data." %}</p>
   </div>
   <div class="panel-footer">
    <a class="btn btn-danger" href="{% url 'remove' %}"><i class="fa fa-trash"></i> {% trans "Remove my account" %}</a>
   </div>
</div>

</div>
<div class="col-lg-6 hidden-xs">
<div class="panel panel-primary">
  <div class="panel-heading"><h4 class="panel-title">{% trans "Description" %}</h4></div>
  <div class="panel-body">
    <p>{% trans "You can configure how you will log in on this site." %}</p>
  </div>
  <div class="panel-footer">
  <a class="btn btn-default" href="{% documentation 'user/profile' 'authentication' %}">{% trans "Documentation" %}</a>
  </div>
</div>
</div>
</div>

</div>
<div class="tab-pane" id="profile">
<div class="row">
<div class="col-lg-6">
<div class="panel panel-primary">
  <div class="panel-heading"><h4 class="panel-title">{% trans "Your summary" %}</h4></div>
  <div class="panel-body">
<table class="table table-condensed">
{% with request.user as user %}
{% include 'user-activity.html' %}
{% endwith %}
<tr>
{% url 'user_page' user=request.user.username as user_page%}
<th>{% trans "Your public profile" %}</th>
<td><a href="{{ user_page }}">{{ user_page }}</a></td>
</tr>
</table
</div>
</div>
</div>

{% if enable_avatars %}
<div class="panel panel-primary">
  <div class="panel-heading"><h4 class="panel-title">{% trans "Your avatar" %}</h4></div>
  <div class="panel-body">
<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>
</div>
{% endif %}

</div>

<div class="col-lg-6 hidden-xs">
<div class="panel panel-primary">
  <div class="panel-heading"><h4 class="panel-title">{% trans "Description" %}</h4></div>
  <div class="panel-body">
    <p>{% trans "Your public appearance on this site." %}</p>
  </div>
  <div class="panel-footer">
  <a class="btn btn-default" href="{% documentation 'user/profile' 'avatar' %}">{% trans "Documentation" %}</a>
  </div>
</div>
</div>

</div>

</div>

<div class="tab-pane" id="licenses">
<div class="row">
<div class="col-lg-6">
<div class="panel panel-primary">
  <div class="panel-heading"><h4 class="panel-title">{% trans "Licenses" %}</h4></div>
  <div class="panel-body">
<p>
{% trans "By registering you agree to use your name and email in the commits and provide your contribution under license defined by each translated project." %}
</p>

{% if licenses %}
<p>{% trans "Following translations have explicitly specified their licensing and copyright conditions:" %}</p>
<table class="table">
<thead>
<tr><th>{% trans "Project" %}</th><th>{% trans "License" %}</th></tr>
</thead>
<tbody>
{% for component in licenses %}
<tr>
<th><a href="{{ component.get_absolute_url }}">{{ component }}</a></th>
<td>
{% if component.license_url %}
<a href="{{ component.license_url }}">{{ component.license }}</a></p>
{% else %}
{{ component.license }}
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
</div>
</div>

</div>

<div class="col-lg-6 hidden-xs">
<div class="panel panel-primary">
  <div class="panel-heading"><h4 class="panel-title">{% trans "Description" %}</h4></div>
  <div class="panel-body">
    <p>{% trans "Please pay attention to the licensing information as these specify how others are allowed to use your translations." %}</p>
  </div>
</div>
</div>

</div>

</div>
</div>


</form>
<form method="post" action="" id="disconnect-form">{% csrf_token %}</form>

{% endblock %}
