]{% extends 'base.html' %}
{% load social %}
{% block title %} | Sign up with email address{% endblock %}

{% block main %}
{% get_social_apps as social_apps %}
<div class="page-header">
    <div class="container">
        <h1>Sign up</h1>
    </div>
</div>

<div class="container">
    {% include 'snippets/messages.html' %}

    {% if redirect_field_value %}
        <div class="alert alert-warning">
            <p>Please sign up to continue.</p>
        </div>
    {% endif %}

    <div class="row">
        <div class="col-md-6 {% if not social_apps %}col-sm-8 col-sm-offset-2 col-md-offset-3{% endif %}">
            <h2 class="header">Sign up with email address</h2>

            {% if form.errors %}
                <div class="alert alert-danger">
                    <p>An error occurred. Please try again.</p>
                </div>
            {% endif %}

            <form action="{% url 'account_signup' %}" method="POST" novalidate>
                {% csrf_token %}

                {% if redirect_field_value %}
                    <input type="hidden" name="next" value="{{ redirect_field_value }}" />
                {% endif %}

                <div class="form-group {% if form.email.errors %}has-error{% endif %}">
                    <label for="email">Your email address</label>
                    <input type="email" class="form-control input-lg" id="email" name="email" value="{{ form.data.email }}" required />
                    {% if form.email.errors %}<span class="help-block">{{ form.email.errors|striptags }}</span>{% endif %}
                </div>

                <div class="form-group {% if form.password1.errors %}has-error{% endif %}">
                    <label for="password1">Password</label>
                    <input type="password" class="form-control input-lg" id="password1" name="password1" value="{{ form.data.password1 }}" required />
                    {% if form.password1.errors %}<span class="help-block">{{ form.password1.errors|striptags }}</span>{% endif %}
                </div>

                <div class="form-group {% if form.password2.errors or form.non_field_errors %}has-error{% endif %}">
                    <label for="password2">Repeat password</label>
                    <input type="password" class="form-control input-lg" id="password2" name="password2" value="{{ form.data.password2 }}" required />
                    {% if form.password2.errors %}<span class="help-block">{{ form.password2.errors|striptags }}</span>{% endif %}
                    {% if form.non_field_errors %}<span class="help-block">{{ form.non_field_errors|striptags }}</span>{% endif %}
                </div>

                <div class="form-group {% if form.display_name.errors %}has-error{% endif %}">
                    <label for="display_name">Choose a display name</label>
                    <input type="text" class="form-control input-lg" id="display_name" name="display_name" maxlength="50"  value="{{ form.data.display_name }}" required />
                    {% if form.display_name.errors %}<span class="help-block">{{ form.display_name.errors|striptags }}</span>{% endif %}
                </div>

                <div class="form-group">
                    <button type="submit" class="btn btn-lg btn-primary">Sign me up</button>
                </div>
            </form>
        </div>

        {% if social_apps %}
            <div class="col-md-6">
                <h2 class="header">Sign up with social account</h2>
                {% include 'snippets/social_apps.html' with process='login' %}
            </div>
        {% endif %}
    </div>

    <div class="row">
        <div class="col-md-12 text-center">
            <p>Already signed up? Please <a href="{{ login_url }}">sign in using an email address</a>{% if social_apps %}, or use your social account{% endif %}.</p>
        </div>
    </div>
</div>
{% endblock %}

{% block libraries %}
<script src="/static/js/admin.ui.forms.validate.js"></script>
{% endblock %}
