{% extends 'base.html' %}
{% block content %}
<br><br><img class="myavatar" src="{{ url_for('avatar', user=user.username) }}" alt="">
{% if current_user.get_id() == user.get_id() %}
<form action="" method="post" enctype="multipart/form-data">
{{ form_update_avatar.hidden_tag() }}
<br>{{form_update_avatar.avatar.label()}}
{{form_update_avatar.avatar()}}
{% for error in form_update_avatar.avatar.errors %}
{{ error }}
{% endfor %}
{{ form_update_avatar.submit2() }}
</form>
{% endif %}
{% for category, message in get_flashed_messages(True) %}
<br><br><p class="{{ category }}">{{ message }}</p>
{% endfor %}
<br><br><h1>{{ user.username }}</h1>
{% if current_user.get_id() == user.get_id() %}
<form action='', method="post">
{{ form.hidden_tag() }}
{{ form.text.label() }}
{{ form.postimg(class="custom-file-input") }}
{% for error in form.postimg.errors if error != 'error' %}
<br>
<div class="error">{{ error }}</div>
{% endfor %}
<p><div>{{ form.text(class='textarea', rows=4, cols=50) }}</div>
{% for error in form.text.errors %}
<div class="error">{{ error }}</div>
<br>
{% endfor %}
{{ form.submit1() }}
</form><br>
{% endif %}
{% for post in user.posts %}
<div>
{{ post.author.username }} thinks {{ post.body }}
{% if current_user.get_id() == user.get_id() %}<a href="{{url_for('user', username=user.username, action='delete', user=user.username, id=post.id)}}"><img class="del" src="https://avatanplus.com/files/resources/original/5968a2c8f2ed115d40bbe123.png" alt=""></a>{% endif %}
</div>
{% endfor %}
{% endblock %}