email settings

This commit is contained in:
vabene1111
2021-05-30 15:53:16 +02:00
parent 505b60cb14
commit 3c778927e2
5 changed files with 248 additions and 80 deletions

View File

@@ -0,0 +1,82 @@
{% extends "base.html" %}
{% load crispy_forms_filters %}
{% load i18n %}
{% block title %}{% trans "E-mail Addresses" %}{% endblock %}
{% block content %}
<h3>{% trans "E-mail Addresses" %}</h3>
{% if user.emailaddress_set.all %}
<p>{% trans 'The following e-mail addresses are associated with your account:' %}</p>
<form action="{% url 'account_email' %}" class="email_list" method="post">
{% csrf_token %}
<fieldset class="blockLabels">
{% for emailaddress in user.emailaddress_set.all %}
<div class="ctrlHolder">
<label for="email_radio_{{ forloop.counter }}"
class="{% if emailaddress.primary %}primary_email{% endif %}">
<input id="email_radio_{{ forloop.counter }}" type="radio" name="email"
{% if emailaddress.primary or user.emailaddress_set.count == 1 %}checked="checked"{% endif %}
value="{{ emailaddress.email }}"/>
{{ emailaddress.email }}
{% if emailaddress.verified %}
<span class="badge badge-pill badge-success">{% trans "Verified" %}</span>
{% else %}
<span class="badge badge-pill badge-warning">{% trans "Unverified" %}</span>
{% endif %}
{% if emailaddress.primary %}<span class="badge badge-pill badge-info">{% trans "Primary" %}</span>{% endif %}
</label>
</div>
{% endfor %}
<div class="buttonHolder">
<button class="btn btn-success" type="submit"
name="action_primary">{% trans 'Make Primary' %}</button>
<button class="btn btn-info" type="submit"
name="action_send">{% trans 'Re-send Verification' %}</button>
<button class="btn btn-warning" type="submit" name="action_remove">{% trans 'Remove' %}</button>
</div>
</fieldset>
</form>
{% else %}
<p>
<strong>{% trans 'Warning:' %}</strong> {% trans "You currently do not have any e-mail address set up. You should really add an e-mail address so you can receive notifications, reset your password, etc." %}
</p>
{% endif %}
{% if can_add_email %}
<h3>{% trans "Add E-mail Address" %}</h3>
<form method="post" action="{% url 'account_email' %}" class="add_email">
{% csrf_token %}
{{ form | crispy }}
<button name="action_add" class="btn btn-success" type="submit">{% trans "Add E-mail" %}</button>
</form>
{% endif %}
{% endblock %}
{% block extra_body %}
<script type="text/javascript">
(function () {
var message = "{% trans 'Do you really want to remove the selected e-mail address?' %}";
var actions = document.getElementsByName('action_remove');
if (actions.length) {
actions[0].addEventListener("click", function (e) {
if (!confirm(message)) {
e.preventDefault();
}
});
}
})();
</script>
{% endblock %}

View File

@@ -0,0 +1,34 @@
{% extends "base.html" %}
{% load i18n %}
{% load account %}
{% block title %}{% trans "Confirm E-mail Address" %}{% endblock %}
{% block content %}
<h3>{% trans "Confirm E-mail Address" %}</h3>
{% if confirmation %}
{% user_display confirmation.email_address.user as user_display %}
<p>{% blocktrans with confirmation.email_address.email as email %}Please confirm that
<a href="mailto:{{ email }}">{{ email }}</a> is an e-mail address for user {{ user_display }}
.{% endblocktrans %}</p>
<form method="post" action="{% url 'account_confirm_email' confirmation.key %}">
{% csrf_token %}
<button class="btn btn-primary" type="submit">{% trans 'Confirm' %}</button>
</form>
{% else %}
{% url 'account_email' as email_url %}
<p>{% blocktrans %}This e-mail confirmation link expired or is invalid. Please
<a href="{{ email_url }}">issue a new e-mail confirmation request</a>.{% endblocktrans %}</p>
{% endif %}
{% endblock %}