diff --git a/gestion/forms.py b/gestion/forms.py index b472722..287e029 100644 --- a/gestion/forms.py +++ b/gestion/forms.py @@ -9,6 +9,8 @@ class RegistrationFormUser(UserCreationForm): fields = ('username', 'first_name', 'last_name', 'password1', 'password2', 'email',) class InscriptionMembreForm(forms.ModelForm): + validation = forms.CharField(max_length=100) + class Meta: model = ErnestoUser fields = ("phone", "instru", ) diff --git a/gestion/views.py b/gestion/views.py index fe649eb..1b64c79 100644 --- a/gestion/views.py +++ b/gestion/views.py @@ -17,32 +17,17 @@ def inscription_membre(request): requbis = request.POST.copy() user_form = RegistrationFormUser(requbis) comp_form = InscriptionMembreForm(requbis) - sender = "fanfare@ens.fr" - chefs = ErnestoUser.objects.filter(is_chef=True) - receivers = "" - for u in chefs: - if u.user.email != "": - receivers += u.user.email + ', ' if user_form.is_valid() and comp_form.is_valid(): pseudo = user_form.cleaned_data['username'] - msg = MIMEMultipart("alternative") - msg["Subject"]=u'Activation de compte' - part1 = MIMEText(u"""Bonjour, l'utilisateur """ + pseudo + """ vient de créer son compte sur le site de l'Ernestophone. - Pour qu'il puisse accéder aux ressources, allez dans l'interface d'administration, et cochez le comme actif-ve !""", "plain", "utf-8") - msg.attach(part1) - + if not (comp_form.cleaned_data['validation'] == "Pouet-ta-mere"): + error = "Le champ Validation ne correspond pas à celui attendu" + return render(request, "gestion/registration.html", locals()) member = user_form.save() - member.is_active = False member.save() (profile, _) = ErnestoUser.objects.get_or_create(user = member) comp_form = InscriptionMembreForm(requbis, instance = profile) comp_form.save() envoi = True - # try: - smtpObj = smtplib.SMTP('clipper.ens.fr', 25) - smtpObj.sendmail(sender, receivers, msg.as_string().encode('ascii')) - # except: - # error = "Une erreur est survenue, envoyez un mail à fanfare pour activer votre compte" return render(request, 'gestion/thanks.html', locals()) else: comp_form = InscriptionMembreForm() diff --git a/templates/gestion/registration.html b/templates/gestion/registration.html index a3ab5d5..ae6ed3c 100644 --- a/templates/gestion/registration.html +++ b/templates/gestion/registration.html @@ -3,7 +3,7 @@ {% block content %}
Entrez dans le champ validation le mot de passe donné par les chef-fe-s
{% if error %}{{ error }}
{% endif %} diff --git a/templates/gestion/thanks.html b/templates/gestion/thanks.html index 894ee1d..b1ccb60 100644 --- a/templates/gestion/thanks.html +++ b/templates/gestion/thanks.html @@ -1,5 +1,5 @@ {% extends "base.html" %} {% block titre %}L'Ernestophone - Inscription{% endblock %} -{% block content %}Merci pour votre inscription. Votre compte sera bientôt activé par un-e chef-fe fanfare
+{% block content %}Merci pour votre inscription.
{% if error %}{{ error }}
{% endif %} {% endblock %}