{% extends "base.html" %}
{% load i18n %}
{% load socialprofile_tags %}

{% block headtitle %}{% trans "Profile for " %}{{ user.username }}{% endblock %}

{% block header %}
    <header data-role="header" data-position="fixed">
        <a href="{{ sp_form.returnTo.value|default:'/' }}" data-role="button" data-icon="arrow-l"
           data-mini="true">{% trans "Back" %}</a>

        <h1>{% trans "Profile" %}</h1>
        {% if request.user.username == user_form.username.value %}
            <a href="{% url "sp_profile_edit_page" %}?returnTo={{ sp_form.returnTo.value }}" data-role="button"
               data-mini="true" data-ajax="false">{% trans "Edit" %}</a>
        {% endif %}
    </header>
{% endblock %}

{% block content %}
    <section title="profile" data-role="content">


        <section title="{% trans 'Picture' %}" class="sp-profile-img">
            <img src="{{ sp_form.image_url.value|default:"http://www.gravatar.com/avatar/00000000000000000000000000000000?d=mm" }}">

            <h2 class="sp-profile-name">{{ user_form.first_name.value|default:"&nbsp;" }} {{ user_form.last_name.value|default:"&nbsp;" }}</h2>
        </section>
        <ul class="sp-profile-block" data-role="listview" data-inset="true">
            <li>{{ user_form.username.label_tag }}&nbsp;{{ user_form.username.value|default:"&nbsp;" }}</li>

            <li>{{ user_form.email.label_tag }}&nbsp;{{ user_form.email.value|default:"&nbsp;" }}</li>

            <li>{{ sp_form.gender.label_tag }}&nbsp;{{ sp_form.gender.value|title|default:"&nbsp;" }}</li>

            <li>{{ sp_form.url.label_tag }}
                <div>&nbsp;{{ sp_form.url.value|urlize }}</div>
            </li>

            <li>{{ sp_form.description.label_tag }}&nbsp;{{ sp_form.description.value|default:"&nbsp;" }}</li>
            {% if request.user.username == user_form.username.value %}
                <li><label>{% trans "Authentication:" %}&nbsp;</label>
                    {% for user_social_auth in user.social_auth.all %}
                        {{ user_social_auth.provider|social_provider_name }}{% if not forloop.last %},&nbsp;{% endif %}
                    {% empty %}
                        {% trans "No Social Authentications." %}
                    {% endfor %}
                </li>
            {% endif %}
        </ul>

    </section>
{% endblock %}

