{% extends base %}
{% from 'macro.html' import breadcrumbs with context %}
{% block content %}

<div class="row">
    <div class="span12">
        {{- breadcrumbs([[url_for('author.info', user_id=user.id), 'Мой профиль']]) }}
    </div>

    <div class="span12">
                    <h1>{{ page_title }}</h1>
                    <form id="main" action="#main" method="POST" enctype="multipart/form-data" class="form-horizontal">
                        <fieldset>
                            <legend>Основное</legend>
                            {% if profile_ok %}<div class="alert-mini green">Профиль успешно обновлен</div>{% endif %}
                            {% for field in profile_form %}
                                {% if field.widget.input_type == 'hidden' %}{{ field }}{% else %}
                                <div class="control-group{% if field.errors %} error{% endif %}">
                                    <label class="control-label">{{ field.label.text }}</label>
                                    <div class="controls">
                                        {{ field }}
                                        {% if field.errors and field.name != 'contacts' %}
                                            {% for error in field.errors %}
                                                <span class="help-inline">{{ error }}</span>
                                            {% endfor %}
                                        {% else %}
                                            <span class="help-inline small">{{ field.description }}</span>
                                        {% endif %}
                                    </div>
                                </div>
                            {% endif %}{% endfor %}
                            {% if profile_form_errors %}
                                <div class="control-group error">
                                    {% for error in profile_form_errors %}
                                        <span class="help-inline">{{ error }}</span>
                                    {% endfor %}
                                </div>
                            {% endif %}
                            <div class="form-actions">
                                <button class="btn btn-primary" type="submit" name="save_profile">Сохранить профиль</button>
                            </div>
                        </fieldset>
                    </form>

                    <form id="mail" action="#mail" method="POST" enctype="multipart/form-data" class="form-horizontal">
                        <fieldset>
                        <legend>Почта</legend>
                          {% if email_ok %}<div class="alert-mini green">Адрес электронной почты успешно обновлен</div>{% endif %}
                            {% for field in email_form %}
                                {% if field.widget.input_type == 'hidden' %}{{ field }}{% else %}
                                <div class="control-group{% if field.errors %} error{% endif %}">
                                    <label class="control-label">{{ field.label.text }}</label>
                                    <div class="controls">
                                        {{ field }}
                                        {% if field.errors %}
                                            {% for error in field.errors %}
                                                <span class="help-inline">{{ error }}</span>
                                            {% endfor %}
                                        {% else %}
                                            <span class="help-inline small">{{ field.description }}</span>
                                        {% endif %}
                                    </div>
                                </div>
                            {% endif %}{% endfor %}
                            {% if email_form_errors %}
                                <div class="control-group error">
                                    {% for error in email_form_errors %}
                                        <span class="help-inline">{{ error }}</span>
                                    {% endfor %}
                                </div>
                            {% endif %}
                            <div class="form-actions">
                                <button class="btn btn-primary" type="submit" name="save_email">Сменить e-mail</button>
                            </div>
                        </fieldset>
                    </form>

                    <form id="security" action="#security" method="POST" enctype="multipart/form-data" class="form-horizontal">
                        <fieldset>
                            <legend>Безопасность</legend>
                          {% if password_ok %}<div class="alert-mini green">Новый пароль установлен</div>{% endif %}
                            {% for field in password_form %}
                                {% if field.widget.input_type == 'hidden' %}{{ field }}{% else %}
                                <div class="control-group{% if field.errors %} error{% endif %}">
                                    <label class="control-label">{{ field.label.text }}</label>
                                    <div class="controls">
                                        {{ field }}
                                        {% if field.errors %}
                                            {% for error in field.errors %}
                                                <span class="help-inline">{{ error }}</span>
                                            {% endfor %}
                                        {% else %}
                                            <span class="help-inline small">{{ field.description }}</span>
                                        {% endif %}
                                    </div>
                                </div>
                            {% endif %}{% endfor %}
                            {% if password_form_errors %}
                                <div class="control-group error">
                                    {% for error in password_form_errors %}
                                        <span class="help-inline">{{ error }}</span>
                                    {% endfor %}
                                </div>
                            {% endif %}
                            <div class="form-actions">
                                <button class="btn btn-primary" type="submit" name="save_password">Сменить пароль</button>
                            </div>
                        </fieldset>
                    </form>

                    <form id="personal" action="#personal" method="POST" enctype="multipart/form-data" class="form-horizontal">
                        <fieldset>
                            <legend>Настройки отображения</legend>
                            {{ prefs_form.csrf_token }}
                          {% if prefs_ok %}<div class="alert-mini green">Личные настройки сохранены</div>{% endif %}
                            <div class="padded bootstrap checkbox">
                                <label>Скрыть жанры из поиска:</label>
                                {{ prefs_form.excluded_categories }}
                            </div>
                            <div class="padded bootstrap radio">
                                <label>Показать рассказ в списках:</label>
                                {{ prefs_form.detail_view }}
                            </div>
                            <div class="padded bootstrap radio">
                                <label>NSFW-предупреждения:</label>
                                {{ prefs_form.nsfw }}
                            </div>
                            <div class="padded">
                                <label>Скрывать ветки комментариев с данной глубиной (1 - скрывать все ветки, 0 - ничего не скрывать):</label>
                                {{ prefs_form.comments_maxdepth }}
                            </div>
                            <div class="padded">
                                <label>Скрывать под спойлером комментарии с данным рейтингом и ниже:</label>
                                {{ prefs_form.comment_spoiler_threshold }}
                            </div>
                            {% if prefs_form_errors %}
                                <div class="control-group error">
                                    {% for error in prefs_form_errors %}
                                        <span class="help-inline">{{ error }}</span>
                                    {% endfor %}
                                </div>
                            {% endif %}
                            <div class="form-actions">
                                <input class="btn btn-primary" type="submit" name="save_prefs" value="Сохранить личные настройки"/>
                            </div>
                        </fieldset>
                    </form>
    </div>

    <div class="span12">
        {{- breadcrumbs([[url_for('author.info', user_id=user.id), 'Мой профиль']]) }}
    </div>
</div>
{% endblock %}
