diff --git a/users/forms.py b/users/forms.py index c9f97508..79302182 100644 --- a/users/forms.py +++ b/users/forms.py @@ -299,11 +299,6 @@ class ResetPasswordForm(forms.Form): email = forms.EmailField(max_length=255) -class ResendConfirmationEmailForm(forms.Form): - """Formulaire de renvoie du mail de confirmation""" - pass - - class MassArchiveForm(forms.Form): """Formulaire d'archivage des users inactif. Prend en argument du formulaire la date de depart avant laquelle archiver les diff --git a/users/models.py b/users/models.py index 48c91be9..0ca94a37 100755 --- a/users/models.py +++ b/users/models.py @@ -339,7 +339,7 @@ class User( def set_active(self): """Enable this user if he subscribed successfully one time before 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.facture_set.filter(valid=True).filter( Q(vente__type_cotisation="All") | Q(vente__type_cotisation="Adhesion") diff --git a/users/templates/users/resend_confirmation_email.html b/users/templates/users/resend_confirmation_email.html new file mode 100644 index 00000000..2c086ccd --- /dev/null +++ b/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 %} + +
+ {% csrf_token %} +

{% blocktrans %}Re-send confirmation email{% endblocktrans %}

+

{% blocktrans %}The confirmation email will be sent to {{ email }}.{% endblocktrans %}

+ {% trans "Confirm" as tr_confirm %} + {% bootstrap_button tr_confirm button_type="submit" icon="ok" button_class="btn-success" %} +
+
+
+
+{% endblock %} + diff --git a/users/views.py b/users/views.py index 16acd748..5c23932e 100644 --- a/users/views.py +++ b/users/views.py @@ -107,7 +107,6 @@ from .forms import ( PassForm, ConfirmMailForm, ResetPasswordForm, - ResendConfirmationEmailForm, ClubAdminandMembersForm, GroupForm, InitialRegisterForm, @@ -228,7 +227,7 @@ def edit_info(request, user, userid): if user_form.should_send_confirmation_email: 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 form( @@ -1034,26 +1033,24 @@ def process_passwd(request, req): def resend_confirmation_email(request, userid): """ 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(): - 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) messages.success(request, _("An email to confirm your address was sent.")) return redirect(reverse("users:profil", kwargs={"userid": userid})) return form( - {"userform": userform, "action_name": _("Send")}, "users/user.html", request + {"email": user.email}, + "users/resend_confirmation_email.html", + request, )