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

{% block title %}
	{{ _("Email and Notifications - %(username)s", username=user.username) }}
{% endblock %}

{% block pane %}
	<h2 class="mt-0">{{ _("Email and Notifications") }}</h2>

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

		<h3>{{ _("Email Address") }}</h3>

		{{ render_field(form.email, tabindex=100) }}

		<p>
			{{  _("Your email is needed to recover your account if you forget your password, and to send (configurable) notifications.") }}
			{{  _("Your email will never be shared with a third-party.") }}
		</p>

		{% if user.email_verifications.filter_by(is_password_reset=False).count() > 0 %}
			<p>
				<i>{{ _("There is at least one verification pending.") }}</i>
			</p>
		{% endif %}

		<h3>{{ _("Notification Settings") }}</h3>

		{% if is_new %}
			<p class="alert alert-info">
				{{ _("Email notifications are currently turned off. Click 'save' to enable.") }}
			</p>
		{% endif %}

		<p>
			{{ _("Configure whether certain types of notifications are sent immediately, or as part of a daily digest.") }}
		</p>

		<table class="table">
			<tr>
				<th>{{ _("Event") }}</th>
				<th>{{ _("Description") }}</th>
				<td>{{ _("Immediately") }}</td>
				<td>{{ _("In digest") }}</td>
			</tr>
			{% for type in types %}
				<tr>
					<td>{{ type.getTitle() }}</td>
					<td>{{ type.get_description() }}</td>
					<td style="text-align: center;">
						{{ render_checkbox_field(form["pref_" + type.toName()]) }}
					</td>
					<td style="text-align: center;">
						{{ render_checkbox_field(form["pref_" + type.toName() + "_digest"]) }}
					</td>
				</tr>
			{% endfor %}
		</table>

		<p class="mt-5">
			{{ render_submit_field(form.submit, tabindex=280) }}
		</p>
	</form>
{% endblock %}