Changement de mode d'inscription
This commit is contained in:
parent
16b75820b3
commit
2140fcc7ee
4 changed files with 7 additions and 20 deletions
|
@ -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", )
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
{% block content %}
|
||||
<h2>Inscription d'un nouvel Ernestophoniste</h2>
|
||||
|
||||
<p>Entrez dans le champ validation le mot de passe donné par les chef-fe-s</p>
|
||||
{% if error %}
|
||||
<p>{{ error }}</p>
|
||||
{% endif %}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{% extends "base.html" %}
|
||||
{% block titre %}L'Ernestophone - Inscription{% endblock %}
|
||||
{% block content %}<p> Merci pour votre inscription. Votre compte sera bientôt activé par un-e chef-fe fanfare</p>
|
||||
{% block content %}<p> Merci pour votre inscription.</p>
|
||||
{% if error %}<p>{{ error }}</p>{% endif %}
|
||||
{% endblock %}
|
||||
|
|
Loading…
Reference in a new issue