{% extends "site_base.html" %}

{% load i18n %}
{% load bootstrap_tags %}
{% load ifsetting_tag %}
{% load account_tags %}

{% block head_title %}{% trans "Log In" %}{% endblock %}

{% block body %}
    
    <h1>{% trans "Log In" %}</h1>
    
    {% if user.is_authenticated %}
        {% user_display user as user_display %}
        <p><span class="warning">{% trans "Note" %}</span>: {% blocktrans %}you are already logged in as {{ user_display }}.{% endblocktrans %}</p>
    {% else %}
        {% ifsetting ACCOUNT_OPEN_SIGNUP %}
        {% url acct_signup as signup_url %}
        <p>{% blocktrans %}Don't have an account? <a href="{{ signup_url }}">Sign up</a>!{% endblocktrans %}</p>
        {% endifsetting %}
        <p>
            <a href="{% url acct_passwd_reset %}">{% trans "Forgot password?" %}</a>
        </p>
    {% endif %}
    
    <form method="POST" action="{% url acct_login %}" autocapitalize="off">
        {% csrf_token %}
        <fieldset>
            {{ form|as_bootstrap }}
        </fieldset>
        {% if redirect_field_value %}
            <input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
        {% endif %}
        <div class="actions">
            <button type="submit" class="btn primary">{% trans "Log in" %}</button>
        </div>
    </form>
    
    {% ifsetting ACCOUNT_USE_OPENID %}
    <h2>{% trans "Or sign in with your OpenID" %}:</h2>
    <form action="/openid/register/" method="POST" autocapitalize="off">
        {% csrf_token %}
        <fieldset>
            {% if url_required %}
                <div class="clearfix">
                    <label for="id_username">* OpenID Identifier</label>
                    <div class="input">
                        <input class="openid" type="text" name="openid_url" />
                    </div>
                </div>
            {% else %}
                <div class="clearfix">
                    <label for="id_username">* OpenID Identifier</label>
                    <div class="input">
                        <input class="openid" type="text" name="openid_url" />
                    </div>
                </div>
            {% endif %}
            <div class="actions">
                <input type="submit" value="{% trans "Log in" %}" class="btn primary" />
            </div>
        </fieldset>
    </form>
    {% endifsetting %}
    
    {% if request.user.is_authenticated %}
        <div><a href="{% url acct_logout %}?next={{ request.path }}">logout</a></div>
    {% endif %}
    
    <p>{% blocktrans %}If you have any trouble logging in to your account, contact us at <a href="mailto:{{ CONTACT_EMAIL }}">{{ CONTACT_EMAIL }}</a>.{% endblocktrans %}</p>
{% endblock %}

{% block extra_body %}
<script>
    $("#id_username").focus();
</script>
{% endblock %}