{% extends "users/settings_base.html" %}

{% block title %}
	{{ _("Edit Profile - %(username)s", username=user.username) }}
{% endblock %}

{% block pane %}
<h2 class="mt-0">{{ _("Edit Profile") }}</h2>

<h3>{{ _("Profile Picture") }}</h3>
<div class="row">
	<div class="col-md-2">
		{% if user.forums_username %}
			<a href="https://forum.luanti.org/ucp.php?i=profile&mode=avatar">
		{% elif user.email %}
			<a href="https://en.gravatar.com/">
		{% endif %}
		<img class="img-fluid user-photo img-thumbnail  img-thumbnail-1" src="{{ user.get_profile_pic_url() }}">
		{% if user.forums_username or user.email %}
			</a>
		{% endif %}
	</div>
	<div class="col">
		{% if user.forums_username %}
			<form method="post" action="{{ url_for('users.user_check_forums', username=user.username) }}" class="me-2" style="display:inline-block;">
				<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
				<input type="submit" class="btn btn-primary" value="{{  _('Import from forums') }}" />
			</form>
		{% endif %}
		{% if user.profile_pic %}
			<form method="post" action="{{ url_for('users.user_remove_profile_pic', username=user.username) }}" class="me-2" style="display:inline-block;">
				<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
				<input type="submit" class="btn btn-secondary" value="{{  _('Remove profile picture') }}" />
			</form>
		{% elif user.email %}
			<a class="btn btn-primary" href="https://en.gravatar.com/">
				Gravatar
			</a>
		{% else %}
			<a class="btn btn-secondary disabled"
					data-toggle="tooltip" data-placement="bottom"
					title="Please add an email address to use Gravatar"
					style="pointer-events: all;">
				Gravatar
			</a>
		{% endif %}
	</div>
</div>
{% if user.forums_username %}
	<p class="text-muted mt-3">
		{{ _("Profile pictures should be square, at least 64x64px, and one of the following formats: jpeg, png, or webp.") }}
	</p>
{% endif %}

<h3>{{ _("Profile Information") }}</h3>

{% from "macros/forms.html" import render_field, render_field_prefix, render_submit_field %}
<form action="" method="POST" class="form" role="form">
	{{ form.hidden_tag() }}

	{% if user.check_perm(current_user, "CHANGE_DISPLAY_NAME") %}
		{{ render_field(form.display_name, tabindex=230, hint=_("Pretending to be another user is grounds for a permanent ban")) }}
	{% endif %}

	{% if user.check_perm(current_user, "CHANGE_PROFILE_URLS") %}
		{{ render_field(form.website_url, tabindex=232) }}
		{{ render_field(form.donate_url, tabindex=233) }}
	{% endif %}

	<p>
		{{ render_submit_field(form.submit, tabindex=280) }}
	</p>
</form>

{% endblock %}
