Fix user display
Added mail when forgot password
This commit is contained in:
+4
-1
@@ -1 +1,4 @@
|
|||||||
*.pyc
|
*.pyc
|
||||||
|
/jm2l/upload/images/*
|
||||||
|
JM2L.egg-info/*
|
||||||
|
JM2L.sqlite
|
||||||
|
|||||||
+39
-1
@@ -3,7 +3,11 @@ from pyramid.view import view_config
|
|||||||
from pyramid.security import remember, forget
|
from pyramid.security import remember, forget
|
||||||
from pyramid.httpexceptions import HTTPFound
|
from pyramid.httpexceptions import HTTPFound
|
||||||
from .models import User, DBSession
|
from .models import User, DBSession
|
||||||
|
from mako.template import Template
|
||||||
|
from pyramid_mailer import get_mailer
|
||||||
|
from pyramid_mailer.message import Attachment, Message
|
||||||
import datetime
|
import datetime
|
||||||
|
import re
|
||||||
|
|
||||||
@view_config(route_name='auth', match_param="action=login", renderer="jm2l:templates/login.mako")
|
@view_config(route_name='auth', match_param="action=login", renderer="jm2l:templates/login.mako")
|
||||||
def login(request):
|
def login(request):
|
||||||
@@ -11,7 +15,41 @@ def login(request):
|
|||||||
|
|
||||||
@view_config(route_name='auth', match_param="action=forgot", renderer="jm2l:templates/login.mako")
|
@view_config(route_name='auth', match_param="action=forgot", renderer="jm2l:templates/login.mako")
|
||||||
def forgot(request):
|
def forgot(request):
|
||||||
return {'forgot':True}
|
if request.method == 'POST' and request.POST:
|
||||||
|
request.POST.get('mail')
|
||||||
|
Found = re.match(r'^.+@([^.@][^@]+)$', request.POST.get('mail'), re.IGNORECASE)
|
||||||
|
if not Found:
|
||||||
|
request.session.flash(('error',u"Vous n'avez pas entré un e-mail valide !"))
|
||||||
|
return { 'forgot': True }
|
||||||
|
else:
|
||||||
|
UserFound = User.by_mail( Found.group(0) )
|
||||||
|
if not UserFound:
|
||||||
|
request.session.flash(('error',u"Nous n'avons pas d'interlocuteur avec cette adresse e-mail !"))
|
||||||
|
return { 'forgot': True }
|
||||||
|
else:
|
||||||
|
# Send the Forgot Mail
|
||||||
|
mailer = request.registry['mailer']
|
||||||
|
# Prepare Plain Text Message :
|
||||||
|
Mail_template = Template(filename='jm2l/templates/mail_plain.mako')
|
||||||
|
mail_plain = Mail_template.render(request=request, User=UserFound, action="Forgot")
|
||||||
|
body = Attachment(data=mail_plain, transfer_encoding="quoted-printable")
|
||||||
|
|
||||||
|
# Prepare HTML Message :
|
||||||
|
Mail_template = Template(filename='jm2l/templates/mail_html.mako')
|
||||||
|
mail_html = Mail_template.render(request=request, User=UserFound, action="Forgot")
|
||||||
|
html = Attachment(data=mail_html, transfer_encoding="quoted-printable")
|
||||||
|
|
||||||
|
# Prepare Message
|
||||||
|
message = Message(subject="[JM2L] Mes identifiants du site web JM2L",
|
||||||
|
sender="contact@jm2l.linux-azur.org",
|
||||||
|
recipients=[UserFound.mail],
|
||||||
|
body=body, html=html)
|
||||||
|
|
||||||
|
message.add_bcc("spam@style-python.fr")
|
||||||
|
mailer.send(message)
|
||||||
|
|
||||||
|
request.session.flash(('info',u"Vos informations de connection vous ont été renvoyé par e-mail"))
|
||||||
|
return { 'forgot': True }
|
||||||
|
|
||||||
@view_config(route_name='bymail', renderer="string")
|
@view_config(route_name='bymail', renderer="string")
|
||||||
def bymail(request):
|
def bymail(request):
|
||||||
|
|||||||
@@ -139,6 +139,10 @@ class User(Base):
|
|||||||
def by_id(cls, id):
|
def by_id(cls, id):
|
||||||
return DBSession.query(cls).filter(cls.uid == id).first()
|
return DBSession.query(cls).filter(cls.uid == id).first()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def by_mail(cls, mail):
|
||||||
|
return DBSession.query(cls).filter(cls.mail == mail).first()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def by_slug(cls, slug):
|
def by_slug(cls, slug):
|
||||||
return DBSession.query(cls).filter(cls.slug == slug).first()
|
return DBSession.query(cls).filter(cls.slug == slug).first()
|
||||||
|
|||||||
@@ -68,8 +68,9 @@ DicForm2 = {
|
|||||||
${helpers.DisplayRespForm(profil_form, DicFormB)}
|
${helpers.DisplayRespForm(profil_form, DicFormB)}
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Activité</legend>
|
<legend>Activité</legend>
|
||||||
Si vous ne trouvez pas l'entité que vous souhaitez promouvoir (Association, GULL, Entreprise, Logiciel, ...).
|
Saisissez ci-dessous les entités que vous souhaiter représenter pendant l'événement.
|
||||||
Vous pouvez <a href="/entity"> en ajouter une. </a>
|
(Association, GULL, Entreprise, Logiciel, ...).<br>
|
||||||
|
Si elle n'existe pas dans la liste proposée, vous pouvez <a href="/entity"> en ajouter une. </a>
|
||||||
|
|
||||||
<div class="repeat">
|
<div class="repeat">
|
||||||
<table class="wrapper table table-striped table-bordered" width="100%">
|
<table class="wrapper table table-striped table-bordered" width="100%">
|
||||||
@@ -138,7 +139,7 @@ ${helpers.DisplayRespForm(profil_form, DicFormB)}
|
|||||||
<tfoot>
|
<tfoot>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5" style="text-align:center;line-height: 3em;">
|
<td colspan="5" style="text-align:center;line-height: 3em;">
|
||||||
<span class="add btn btn-mini btn-primary"><i class="icon-plus-sign icon-white"></i> Ajouter</span>
|
<span class="add btn btn-mini btn-primary"><i class="icon-plus-sign icon-white"></i> Je fais partie de ...</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
|
|||||||
@@ -41,12 +41,11 @@ DicForm = {
|
|||||||
<th style="width:5em;text-align:center;">Année</th>
|
<th style="width:5em;text-align:center;">Année</th>
|
||||||
<th style="width:22em;">Personne</th>
|
<th style="width:22em;">Personne</th>
|
||||||
<th style="width:22em;">Rôle</th>
|
<th style="width:22em;">Rôle</th>
|
||||||
<th style="width:5em;">Action</th>
|
<th style="width:10em;">Action</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody class="container">
|
<tbody class="container">
|
||||||
<tr class="row template" style="line-height:2.2em;">
|
<tr class="row template" style="line-height:2.2em;">
|
||||||
##<td><span class="move btn btn-mini btn-info">Move</span></td>
|
|
||||||
<td>
|
<td>
|
||||||
<select class="form-control" style="width:5em;" name="membership-{{row-count-placeholder}}-year_uid"
|
<select class="form-control" style="width:5em;" name="membership-{{row-count-placeholder}}-year_uid"
|
||||||
id="membership-{{row-count-placeholder}}-year_uid">
|
id="membership-{{row-count-placeholder}}-year_uid">
|
||||||
@@ -63,14 +62,8 @@ DicForm = {
|
|||||||
<input type="hidden" style="width:20em;" class="form-control" name="membership-{{row-count-placeholder}}-user_uid"
|
<input type="hidden" style="width:20em;" class="form-control" name="membership-{{row-count-placeholder}}-user_uid"
|
||||||
id="membership-{{row-count-placeholder}}-user_uid" />
|
id="membership-{{row-count-placeholder}}-user_uid" />
|
||||||
</td>
|
</td>
|
||||||
<td style="text-align: center;">
|
<td style="text-align: center;">
|
||||||
<select class="form-control" style="width:20em;" name="membership-{{row-count-placeholder}}-role"
|
<input type="hidden" class="form-control" name="membership-{{row-count-placeholder}}-role" />
|
||||||
id="membership-{{row-count-placeholder}}-role">
|
|
||||||
% for opt in UserOptions:
|
|
||||||
<option value="${opt.uid}">${opt.exch_subtype}</option>
|
|
||||||
% endfor
|
|
||||||
</select>
|
|
||||||
<input type="text" class="form-control" name="membership-{{row-count-placeholder}}-role" />
|
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<span class="remove btn btn-mini btn-danger">
|
<span class="remove btn btn-mini btn-danger">
|
||||||
@@ -80,26 +73,32 @@ DicForm = {
|
|||||||
</tr>
|
</tr>
|
||||||
% for num, dicdata in enumerate(form._fields.get("membership").data):
|
% for num, dicdata in enumerate(form._fields.get("membership").data):
|
||||||
<tr class="row" style="padding:5px;line-height:2.2em;">
|
<tr class="row" style="padding:5px;line-height:2.2em;">
|
||||||
##<td><span class="move btn btn-mini btn-info">Move</span></td>
|
|
||||||
<td style="text-align:center;">
|
<td style="text-align:center;">
|
||||||
<input type="hidden" class="form-control" name="membership-${num}-year_uid"
|
<input type="hidden" class="form-control" name="membership-${num}-year_uid"
|
||||||
|
id="membership-${num}-year_uid"
|
||||||
value="${dicdata.get('year_uid')}" style="width:4em;" />
|
value="${dicdata.get('year_uid')}" style="width:4em;" />
|
||||||
${dicdata.get('year_uid')}
|
<div id="content-${num}-year_uid">${dicdata.get('year_uid')}</div>
|
||||||
</td>
|
</td>
|
||||||
<td style="text-align:center;">
|
<td style="text-align:center;">
|
||||||
<input type="hidden" class="form-control" name="membership-${num}-user_uid"
|
<input type="hidden" class="form-control" name="membership-${num}-user_uid"
|
||||||
value="${dicdata.get('user_uid')}" style="width:4em;" />
|
id="membership-${num}-user_uid" value="${dicdata.get('user_uid')}" style="width:4em;" />
|
||||||
<%
|
<%
|
||||||
tmpUser = DBUser.by_id(dicdata.get('user_uid'))
|
tmpUser = DBUser.by_id(dicdata.get('user_uid'))
|
||||||
%>
|
%>
|
||||||
% if tmpUser:
|
% if tmpUser:
|
||||||
${tmpUser.prenom} ${tmpUser.nom}
|
<div id="content-${num}-user_uid">${tmpUser.prenom} ${tmpUser.nom}</div>
|
||||||
% endif
|
% endif
|
||||||
</td>
|
</td>
|
||||||
<td style="text-align:center;">
|
<td style="text-align:center;">
|
||||||
<i>${dicdata.get('role', 'Aucun')}</i>
|
<input type="text" class="form-control" name="membership-${num}-role" style="display:none"
|
||||||
|
id="membership-${num}-role"
|
||||||
|
value="${dicdata.get('role', 'Aucun')}" />
|
||||||
|
<div id="content-${num}-role"><i>${dicdata.get('role', 'Aucun')}</i></div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
<a class="btn btn-mini btn-primary" href="javascript:edit(${num})">
|
||||||
|
<i class="icon-pencil icon-white"></i> Edit.
|
||||||
|
</a>
|
||||||
<span class="remove btn btn-mini btn-danger">
|
<span class="remove btn btn-mini btn-danger">
|
||||||
<i class="icon-remove-sign icon-white"></i> Suppr.
|
<i class="icon-remove-sign icon-white"></i> Suppr.
|
||||||
</span>
|
</span>
|
||||||
@@ -156,7 +155,7 @@ DicForm = {
|
|||||||
var year_data = Array();
|
var year_data = Array();
|
||||||
var editor = CKEDITOR.replace('description', { autoGrow_onStartup: true, language: 'fr' } );
|
var editor = CKEDITOR.replace('description', { autoGrow_onStartup: true, language: 'fr' } );
|
||||||
for (var i=2005;i<2015;i++)
|
for (var i=2005;i<2015;i++)
|
||||||
{ year_data[i.toString()] = i.toString(); };
|
year_data.push( {id:i, text:i.toString()});
|
||||||
|
|
||||||
$("#tiers_type").select2({});
|
$("#tiers_type").select2({});
|
||||||
|
|
||||||
@@ -194,5 +193,36 @@ jQuery(function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function edit(num) {
|
||||||
|
$("#content-"+ num +"-year_uid").hide();
|
||||||
|
$("#membership-"+ num +"-year_uid").select2({
|
||||||
|
width:'80px',
|
||||||
|
data: year_data
|
||||||
|
});
|
||||||
|
$('select').select2();
|
||||||
|
$("#content-"+ num +"-user_uid").hide();
|
||||||
|
$("#membership-"+ num +"-user_uid").select2(
|
||||||
|
{
|
||||||
|
width:'250px',
|
||||||
|
placeholder: 'Entrez ici un Nom ou un Prénom',
|
||||||
|
minimumInputLength: 2, allowClear: true,
|
||||||
|
initSelection: function(element, callback){
|
||||||
|
callback({id: element.val(), text: $("#content-"+ num +"-user_uid").text() })
|
||||||
|
},
|
||||||
|
ajax: {
|
||||||
|
quietMillis: 250, url: "/json-users", dataType: 'json',
|
||||||
|
data: function (term, page) {
|
||||||
|
return { pageSize: 8, pageNum: page, searchTerm: term };
|
||||||
|
},
|
||||||
|
results: function (data, page) {
|
||||||
|
var more = (page * 8) < data.Total;
|
||||||
|
return { results: data.Results, more: more };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$("#content-"+ num +"-role").hide();
|
||||||
|
$("#membership-"+ num +"-role").show();
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
</%def>
|
</%def>
|
||||||
@@ -32,6 +32,39 @@ de la connaissance, de la bonne humeur et du soleil :)
|
|||||||
L'équipe des <b>JM2L</b>
|
L'équipe des <b>JM2L</b>
|
||||||
<br>
|
<br>
|
||||||
</%def> \
|
</%def> \
|
||||||
|
<%def name="Forgot(request, User)">
|
||||||
|
<H4>JM2L</H4>
|
||||||
|
Bonjour ${User.prenom},<br>
|
||||||
|
<br>
|
||||||
|
Vous venez de demander le renvoi de vos identifiants sur le site des JM2L.<br>
|
||||||
|
<br>
|
||||||
|
Pour accéder à votre espace il vous suffit dorénavant de cliquer sur le lien suivant :<br>
|
||||||
|
<a href="${request.route_url('bymail', hash=User.my_hash)}">Votre lien !</a>
|
||||||
|
<br>
|
||||||
|
N'hésitez pas à l'ajouter à vos liens favoris.
|
||||||
|
<br>
|
||||||
|
Vos identifiants de connection sont les suivants:
|
||||||
|
<br>
|
||||||
|
<b>Login</b>: ${User.slug}
|
||||||
|
<br>
|
||||||
|
<b>Password</b>: ${User.password}
|
||||||
|
<br>
|
||||||
|
Une fois connecté vous pouvez changer votre mot de passe sur votre fiche.
|
||||||
|
<br>
|
||||||
|
<p>
|
||||||
|
Pour plus d'information vous pouvez nous envoyer un mail à «contact at jm2l.linux-azur.org ». Et si vous êtes vraiment perdu vous pouvez
|
||||||
|
toujours nous téléphoner au +33 6 52 42 31 37.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Nous vous attendons avec impatience le 28 novembre 2015 à Sophia Antipolis pour fêter le libre et partager
|
||||||
|
de la connaissance, de la bonne humeur et du soleil :)
|
||||||
|
</p>
|
||||||
|
<br>
|
||||||
|
L'équipe des <b>JM2L</b>
|
||||||
|
<br>
|
||||||
|
</%def> \
|
||||||
% if action=='Welcome':
|
% if action=='Welcome':
|
||||||
${self.Bienvenue(request, User)}
|
${self.Bienvenue(request, User)}
|
||||||
|
% elif action=='Forgot':
|
||||||
|
${self.Forgot(request, User)}
|
||||||
% endif
|
% endif
|
||||||
|
|||||||
@@ -24,7 +24,34 @@ Nous vous attendons avec impatience le 28 novembre à Sophia Antipolis pour fêt
|
|||||||
|
|
||||||
L'équipe des JM2L
|
L'équipe des JM2L
|
||||||
|
|
||||||
|
</%def> \
|
||||||
|
<%def name="Forgot(request, User)">
|
||||||
|
|
||||||
|
Bonjour ${User.prenom},
|
||||||
|
|
||||||
|
Vous venez de demander le renvoi de vos identifiants sur le site des JM2L.
|
||||||
|
|
||||||
|
Pour accéder à votre espace il vous suffit dorénavant de cliquer sur le lien suivant :
|
||||||
|
${request.route_url('bymail', hash=User.my_hash)}.
|
||||||
|
N'hésitez pas à l'ajouter à vos liens favoris.
|
||||||
|
|
||||||
|
Vos identifiants de connection sont les suivants:
|
||||||
|
|
||||||
|
Login: ${User.slug}
|
||||||
|
Password: ${User.password}
|
||||||
|
|
||||||
|
Une fois connecté vous pouvez changer votre mot de passe sur votre fiche.
|
||||||
|
|
||||||
|
Pour plus d'information vous pouvez nous envoyer un mail à « contact at jm2l.linux-azur.org ».
|
||||||
|
Et si vous êtes vraiment perdu vous pouvez toujours nous téléphoner au +33 6 52 42 31 37.
|
||||||
|
|
||||||
|
Nous vous attendons avec impatience le 28 novembre 2015 à Sophia Antipolis pour fêter le libre et partager de la connaissance, de la bonne humeur et du soleil :)
|
||||||
|
|
||||||
|
L'équipe des JM2L
|
||||||
|
|
||||||
</%def> \
|
</%def> \
|
||||||
% if action=='Welcome':
|
% if action=='Welcome':
|
||||||
${self.Bienvenue(request, User)}
|
${self.Bienvenue(request, User)}
|
||||||
|
% elif action=='Forgot':
|
||||||
|
${self.Forgot(request, User)}
|
||||||
% endif
|
% endif
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<a style="float:right;" href="/MesJM2L?user=${DispUser.uid}">Editer</a>
|
<a style="float:right;" href="/MesJM2L?user=${DispUser.uid}">Editer</a>
|
||||||
% endif
|
% endif
|
||||||
|
|
||||||
<h2>${DispUser.prenom} ${DispUser.nom}</h2>
|
<h2>${DispUser.prenom | n} ${DispUser.nom | n}</h2>
|
||||||
|
|
||||||
<div class="titleborderbox">
|
<div class="titleborderbox">
|
||||||
<strong>Son profil</strong>.
|
<strong>Son profil</strong>.
|
||||||
|
|||||||
+4
-1
@@ -686,7 +686,7 @@ def participer(request):
|
|||||||
body=body, html=html)
|
body=body, html=html)
|
||||||
|
|
||||||
message.add_bcc("spam@style-python.fr")
|
message.add_bcc("spam@style-python.fr")
|
||||||
mailer.send(message)
|
#mailer.send(message)
|
||||||
|
|
||||||
MainTab = {'programme':'','presse':'', 'plan':'',
|
MainTab = {'programme':'','presse':'', 'plan':'',
|
||||||
'participer':'active', 'form':form, "link": MyLink,
|
'participer':'active', 'form':form, "link": MyLink,
|
||||||
@@ -941,6 +941,7 @@ def edit_tiers(request):
|
|||||||
|
|
||||||
#test_form = TiersForm(request.POST, TheTiers, meta={'csrf_context': request.session})
|
#test_form = TiersForm(request.POST, TheTiers, meta={'csrf_context': request.session})
|
||||||
if request.method == 'POST' and form.validate():
|
if request.method == 'POST' and form.validate():
|
||||||
|
print request.POST
|
||||||
ToDelete = list()
|
ToDelete = list()
|
||||||
# First, we remove entries no more present
|
# First, we remove entries no more present
|
||||||
for obj in form.membership.object_data:
|
for obj in form.membership.object_data:
|
||||||
@@ -1053,6 +1054,8 @@ def show_user(request):
|
|||||||
user_slug = request.matchdict.get('user_slug', None)
|
user_slug = request.matchdict.get('user_slug', None)
|
||||||
# Query database
|
# Query database
|
||||||
DispUser = User.by_slug(user_slug)
|
DispUser = User.by_slug(user_slug)
|
||||||
|
if DispUser is None:
|
||||||
|
raise HTTPNotFound()
|
||||||
MainTab = {'programme':'','presse':'', 'plan':'', 'participer':'',
|
MainTab = {'programme':'','presse':'', 'plan':'', 'participer':'',
|
||||||
'DispUser':DispUser, 'logged_in':request.authenticated_userid }
|
'DispUser':DispUser, 'logged_in':request.authenticated_userid }
|
||||||
return MainTab
|
return MainTab
|
||||||
|
|||||||
Reference in New Issue
Block a user