{% extends "base/base.html" %}

{% block title %}
<a href="{{ url_for('adm') }}">Panneau d'administration</a> » <h1>Édition du compte  de {{ user.name }}</h1>
{% endblock %}

{% block content %}
<section class="form">
	<a href="/user/{{ user.name }}">Visiter la page de profil de {{ user.name }}</a>
	<form action="{{ url_for('adm_edit_account', user_id=user.id) }}" method="post" enctype="multipart/form-data">
		{{ form.hidden_tag() }}
		<h2>Participation</h2>

		<div>
			{{ form.avatar.label }}
			<div>
				<img class="avatar" src="{{ url_for('static', filename=user.avatar) }}" meta="{{ user.avatar }}" />
				{{ form.avatar }}
			</div>
		</div>

		<div>
			{{ form.username.label }}
			{{ form.username(placeholder=user.name) }}
			{% for error in form.username.errors %}
			<span class="msgerror">{{ error }}</span>
			{% endfor %}
		</div>
		<div>
			{{ form.email.label }}
			{{ form.email(placeholder=user.email) }}
			{% for error in form.email.errors %}
			<span class="msgerror">{{ error }}</span>
			{% endfor %}
		</div>
		<div>
			{{ form.email_validate.label }}
			{{ form.email_validate(checked=True) }}
			<div class=desc>{{ form.email_validate.description }}</div>
		</div>
		<div>
			{{ form.password.label }}
			<div class=desc>{{ form.password.description }}</div>
			{{ form.password(placeholder='************') }}
			{% for error in form.password.errors %}
			<span class="msgerror">{{ error }}</span>
			{% endfor %}
		</div>

		<h2>Participation</h2>
		<div>
			{{ form.xp.label }}
			{{ form.xp(placeholder=user.xp) }}
			{% for error in form.xp.errors %}
			<span class="msgerror">{{ error }}</span>
			{% endfor %}
		</div>
		<div>
			{{ form.innovation.label }}
			{{ form.innovation(placeholder=user.innovation) }}
			{% for error in form.innovation.errors %}
			<span class="msgerror">{{ error }}</span>
			{% endfor %}
		</div>

		<h2>À propos</h2>
		<div>
			{{ form.birthday.label }}
			{{ form.birthday(value=user.birthday) }}
			{% for error in form.birthday.errors %}
			<span class="msgerror">{{ error }}</span>
			{% endfor %}
		</div>
		<div>
			{{ form.signature.label }}
			<textarea id="{{ form.signature.name }}" name="{{ form.signature.name }}">{{ user.signature }}</textarea>
			{% for error in form.signature.errors %}
			<span class="msgerror">{{ error }}</span>
			{% endfor %}
		</div>
		<div>
			{{ form.biography.label }}
			<textarea id="{{ form.biography.name }}" name="{{ form.biography.name }}">{{ user.bio }}</textarea>
			{% for error in form.biography.errors %}
			<span class="msgerror">{{ error }}</span>
			{% endfor %}
		</div>

		<h2>Préférences</h2>
		<div>
			{{ form.newsletter.label }}
			{{ form.newsletter(checked=user.newsletter) }}
			<div class=desc>{{ form.newsletter.description }}</div>
			{% for error in form.newsletter.errors %}
			<span class="msgerror">{{ error }}</span>
			{% endfor %}
		</div>
		<div>{{ form.submit(class_="bg-green") }}</div>
	</form>

	<h2 style="margin-top:30px;">Supprimer le compte</h2>
	<a href="{{ url_for('adm_delete_account', user_id=user.id) }}" class="button bg-red">Supprimer le compte</a>

</section>
{% endblock %}
