{% extends "base.html" %}
{% load static %}
{% block title %}{{ user.username }}: Профиль{% endblock %}
{% block content %}
<link href="{% static 'css/users/profile.css' %}" rel="stylesheet">
<div class="profile_block">
    <h1>Профиль</h1>
    <form method="post" enctype="multipart/form-data">
        {% csrf_token %}
        {% if user_form.non_field_errors %}
        <div class="alert alert-danger" role="alert">
            {% for error in form.non_field_errors %}
            <div>{{ error }}</div>
            {% endfor %}
        </div>
        {% endif %}
        {% for field in user_form %}
        <div class="mb-3 form_item">
            <label for="fieldInput" class="form-label">{{ field.label }}</label>
            <p id="fieldInput" aria-describedby="help">{{ field }}</p>
            {% for error in field.errors %}
            <div class="invalid-feedback d-block">
                {{ error }}
            </div>
            {% endfor %}
            <div id="help" class="form-text">{{ field.help_text }}</div>
        </div>
        {% endfor %}
        {% for field in profile_form %}
        <div class="mb-3 form_item">
            <label for="fieldInput" class="form-label">{{ field.label }}</label>
            <p id="fieldInput" aria-describedby="help">{{ field }}</p>
            {% for error in field.errors %}
            <div class="invalid-feedback d-block">
                {{ error }}
            </div>
            {% endfor %}
            <div id="help" class="form-text">{{ field.help_text }}</div>
        </div>
        {% endfor %}
        {% if messages %}
        {% for message in messages %}
        <p> {{ message }} </p>
        {% endfor %}
        {% endif %}
        <button class="btn btn-primary" type="submit">Сохранить изменения</button>
    </form>
    <a class="btn btn-danger" type="submit" href="{% url 'users:logout' %}">Выйти</a>
    <a href="{% url 'users:password_change' %}">Сменить пароль</a>
</div>
{% endblock content %}