Browse Source

Improve template for resending a confirmation email

release-2.9
Jean-Romain Garnier 6 years ago
committed by Gabriel Detraz
parent
commit
b190549618
  1. 5
      users/forms.py
  2. 2
      users/models.py
  3. 44
      users/templates/users/resend_confirmation_email.html
  4. 29
      users/views.py

5
users/forms.py

@ -299,11 +299,6 @@ class ResetPasswordForm(forms.Form):
email = forms.EmailField(max_length=255) email = forms.EmailField(max_length=255)
class ResendConfirmationEmailForm(forms.Form):
"""Formulaire de renvoie du mail de confirmation"""
pass
class MassArchiveForm(forms.Form): class MassArchiveForm(forms.Form):
"""Formulaire d'archivage des users inactif. Prend en argument """Formulaire d'archivage des users inactif. Prend en argument
du formulaire la date de depart avant laquelle archiver les du formulaire la date de depart avant laquelle archiver les

2
users/models.py

@ -339,7 +339,7 @@ class User(
def set_active(self): def set_active(self):
"""Enable this user if he subscribed successfully one time before """Enable this user if he subscribed successfully one time before
Reenable it if it was archived Reenable it if it was archived
Do nothing if disabed""" Do nothing if disabled or waiting for email confirmation"""
if self.state == self.STATE_NOT_YET_ACTIVE: if self.state == self.STATE_NOT_YET_ACTIVE:
if self.facture_set.filter(valid=True).filter( if self.facture_set.filter(valid=True).filter(
Q(vente__type_cotisation="All") | Q(vente__type_cotisation="Adhesion") Q(vente__type_cotisation="All") | Q(vente__type_cotisation="Adhesion")

44
users/templates/users/resend_confirmation_email.html

@ -0,0 +1,44 @@
{% extends 'users/sidebar.html' %}
{% comment %}
Re2o est un logiciel d'administration développé initiallement au rezometz. Il
se veut agnostique au réseau considéré, de manière à être installable en
quelques clics.
Copyright © 2017 Gabriel Détraz
Copyright © 2017 Lara Kermarec
Copyright © 2017 Augustin Lemesle
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
{% endcomment %}
{% load bootstrap3 %}
{% load i18n %}
{% block title %}{% trans "Confirmation email" %}{% endblock %}
{% block content %}
<form class="form" method="post">
{% csrf_token %}
<h4>{% blocktrans %}Re-send confirmation email{% endblocktrans %}</h4>
<p>{% blocktrans %}The confirmation email will be sent to {{ email }}.{% endblocktrans %}</p>
{% trans "Confirm" as tr_confirm %}
{% bootstrap_button tr_confirm button_type="submit" icon="ok" button_class="btn-success" %}
</form>
<br />
<br />
<br />
{% endblock %}

29
users/views.py

@ -107,7 +107,6 @@ from .forms import (
PassForm, PassForm,
ConfirmMailForm, ConfirmMailForm,
ResetPasswordForm, ResetPasswordForm,
ResendConfirmationEmailForm,
ClubAdminandMembersForm, ClubAdminandMembersForm,
GroupForm, GroupForm,
InitialRegisterForm, InitialRegisterForm,
@ -228,7 +227,7 @@ def edit_info(request, user, userid):
if user_form.should_send_confirmation_email: if user_form.should_send_confirmation_email:
user.confirm_email_address_mail(request) user.confirm_email_address_mail(request)
messages.warning(request, _("Sent a new confirmation email")) messages.success(request, _("Sent a new confirmation email"))
return redirect(reverse("users:profil", kwargs={"userid": str(userid)})) return redirect(reverse("users:profil", kwargs={"userid": str(userid)}))
return form( return form(
@ -1034,26 +1033,24 @@ def process_passwd(request, req):
def resend_confirmation_email(request, userid): def resend_confirmation_email(request, userid):
""" Renvoie du mail de confirmation """ """ Renvoie du mail de confirmation """
userform = ResendConfirmationEmailForm(request.POST or None) try:
user = User.objects.get(
id=userid,
state__in=[User.STATE_EMAIL_NOT_YET_CONFIRMED],
)
except User.DoesNotExist:
messages.error(request, _("The user doesn't exist."))
return redirect(reverse("users:profil", kwargs={"userid": userid}))
if userform.is_valid(): if userform.is_valid():
try:
user = User.objects.get(
id=userid,
state__in=[User.STATE_EMAIL_NOT_YET_CONFIRMED],
)
except User.DoesNotExist:
messages.error(request, _("The user doesn't exist."))
return form(
{"userform": userform, "action_name": _("Reset")},
"users/user.html",
request,
)
user.confirm_email_address_mail(request) user.confirm_email_address_mail(request)
messages.success(request, _("An email to confirm your address was sent.")) messages.success(request, _("An email to confirm your address was sent."))
return redirect(reverse("users:profil", kwargs={"userid": userid})) return redirect(reverse("users:profil", kwargs={"userid": userid}))
return form( return form(
{"userform": userform, "action_name": _("Send")}, "users/user.html", request {"email": user.email},
"users/resend_confirmation_email.html",
request,
) )

Loading…
Cancel
Save