{% extends "base.html" %}

{% block title %} | Sign up{% endblock %}
{% block bodydata %} class="login" {% endblock %}

{% block main %}
<div class="container">
	<div class="row">
		<div class="col-sm-8 col-sm-offset-2 col-md-6 col-md-offset-3">
			<h3 class="header">Sign up</h3>
			{% include 'snippets/messages.html' %}

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

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

				<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">Password (again)</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-primary">Sign up</button>
				</div>
			</form>

			<div class="well text-center">Already signed up? Please <a href="{% url 'account_login' %}">sign in here</a> &bull; <a href="{% url 'account_reset_password' %}">Forgot password?</a></div>
		</div>
	</div>
</div>
{% endblock %}

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