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

{% block title %}
	{{ _("Moderator Tools") }}
{% endblock %}

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

<h3>
	{{ _("Edit Account") }}
</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.checkPerm(current_user, "CHANGE_USERNAMES") %}
		{{ render_field(form.username, tabindex=230) }}
		{{ render_field(form.display_name, tabindex=230) }}
		{{ render_field(form.forums_username, tabindex=230) }}
		{{ render_field_prefix(form.github_username, tabindex=230) }}
	{% endif %}

	{% if user.checkPerm(current_user, "CHANGE_RANK") %}
		{{ render_field(form.rank, tabindex=250) }}
	{% endif %}

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


<h3>{{ _("Password") }}</h3>
{% if user.password %}
	<p>{{ _("Has password") }}</p>
{% else %}
	<p class="text-danger">{{ _("Doesn't have password") }}</p>
{% endif %}

{% if not user.rank.atLeast(current_user.rank) %}
	<h3>{{ _("Ban") }}</h3>
	{% if user.ban %}
		<p>
			Banned by {{ user.ban.banned_by.display_name }} at {{ user.ban.created_at | full_datetime }}
			{% if user.ban.expires_at %}
				until {{ user.ban.expires_at | date }}
			{% endif %}
		</p>
		<blockquote>
			{{ user.ban.message }}
		</blockquote>
		<form method="POST" action="{{ url_for('users.modtools_unban', username=user.username) }}">
			<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
			<input type="submit" value="{{ _('Unban') }}" class="btn btn-primary" />
		</form>
	{% else %}
		<form method="POST" action="{{ url_for('users.modtools_ban', username=user.username) }}">
			<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
			<div class="form-group">
				<label for="message">{{ _("Message") }}</label>
				<input id="message" class="form-control" type="text" name="message" required minlength="5">
				<small class="form-text text-muted">
					{{ _("Message to display to banned user") }}
				</small>
			</div>
			<div class="form-group">
				<label for="expires_at">{{ _("Expires At") }}</label>
				<input id="expires_at" class="form-control" type="date" name="expires_at">
				<small class="form-text text-muted">
					{{ _("Expiry date. Leave blank for permanent ban") }}
				</small>
			</div>
			<input type="submit" value="{{ _('Ban') }}" class="btn btn-danger" />
		</form>
	{% endif %}

	<h3>{{ _("Change Email and Send Password Reset") }}</h3>
	<form method="POST" action="{{ url_for('users.modtools_set_email', username=user.username) }}">
		<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
		<div class="form-group">
			<label for="email">{{ _("Email Address") }}</label>
			<input type="email" class="form-control" name="email" id="email" value="{{ user.email or '' }}" />
		</div>
		<input type="submit" value="{{ _('Save') }}" class="btn btn-primary" />
	</form>
{% endif %}

{% endblock %}