Browse Source

Removed some inused functions

master
tr4ck3ur des JM2L 9 years ago
parent
commit
0f10e6e784
1 changed files with 31 additions and 12 deletions
  1. +31
    -12
      jm2l/views.py

+ 31
- 12
jm2l/views.py View File

@@ -5,6 +5,8 @@ from pyramid.renderers import render_to_response
from pyramid.response import Response from pyramid.response import Response
from pyramid.view import notfound_view_config, forbidden_view_config from pyramid.view import notfound_view_config, forbidden_view_config
from pyramid.view import view_config from pyramid.view import view_config
from pyramid_mailer import get_mailer
from mako.template import Template
# Import Web Forms # Import Web Forms
from .forms import * from .forms import *
# Database access imports # Database access imports
@@ -16,6 +18,8 @@ from slugify import slugify
from icalendar import Calendar from icalendar import Calendar
from pytz import timezone from pytz import timezone
from icalendar import Event as Evt from icalendar import Event as Evt
from pyramid_mailer import get_mailer
from pyramid_mailer.message import Attachment, Message
# Then, standard libs # Then, standard libs
import webhelpers.paginate as paginate import webhelpers.paginate as paginate
import unicodedata import unicodedata
@@ -32,13 +36,6 @@ def remove_accents(input_str):
only_ascii = nkfd_form.encode('ASCII', 'ignore') only_ascii = nkfd_form.encode('ASCII', 'ignore')
return only_ascii return only_ascii


@view_config(route_name='tester', renderer="jm2l:templates/tester.mako")
def Tester(request):
JTiers = DBSession.query(Tiers).all()
MainTab = {'programme':'','presse':'', 'plan':'', 'participer':'',
'Tiers':JTiers, "logged_in":request.authenticated_userid }
return MainTab

## =-=- Here, We handle ICal requests -=-= ## =-=- Here, We handle ICal requests -=-=
@view_config(route_name='progr_iCal', renderer="string") @view_config(route_name='progr_iCal', renderer="string")
def ICal_Progamme_Request(request): def ICal_Progamme_Request(request):
@@ -211,11 +208,7 @@ def JSON_TimeLine_Request(request):
## =-=- Here, We handle HTTP requests - Public Part -=-= ## =-=- Here, We handle HTTP requests - Public Part -=-=
@view_config(route_name='home', renderer="jm2l:templates/NewIndex.mako") @view_config(route_name='home', renderer="jm2l:templates/NewIndex.mako")
def index_page(request): def index_page(request):
page = int(request.params.get('page', 1))
paginator = Entry.get_paginator(request, page)
profil = User.by_id(4)
profil_form = ProfilForm(request.POST, profil, meta={'csrf_context': request.session})
MainTab = {'programme':'','presse':'', 'plan':'', 'participer':'', 'paginator':paginator,
MainTab = {'programme':'','presse':'', 'plan':'', 'participer':'',
"logged_in":request.authenticated_userid } "logged_in":request.authenticated_userid }
return MainTab return MainTab


@@ -631,6 +624,7 @@ def participer(request):
form = UserRegisterForm(request.POST, TmpUsr, meta={'csrf_context': request.session}) form = UserRegisterForm(request.POST, TmpUsr, meta={'csrf_context': request.session})
MyLink=None MyLink=None
if request.method == 'POST' and form.validate(): if request.method == 'POST' and form.validate():
# Prepare mailer
form.populate_obj(TmpUsr) form.populate_obj(TmpUsr)
TmpUsr.nom = TmpUsr.nom.capitalize() TmpUsr.nom = TmpUsr.nom.capitalize()
TmpUsr.prenom = TmpUsr.prenom.capitalize() TmpUsr.prenom = TmpUsr.prenom.capitalize()
@@ -648,6 +642,31 @@ def participer(request):
DBSession.add(TmpUsr) DBSession.add(TmpUsr)
DBSession.flush() DBSession.flush()
MyLink = TmpUsr.my_hash MyLink = TmpUsr.my_hash

mailer = request.registry['mailer']
# Send the Welcome Mail
NewUser = TmpUsr
# Prepare Plain Text Message :
Mail_template = Template(filename='jm2l/templates/mail_plain.mako')
mail_plain = Mail_template.render(User=NewUser, action="Welcome")
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(User=NewUser, action="Welcome")
html = Attachment(data=mail_html, transfer_encoding="quoted-printable")
# Prepare Message
message = Message(subject="[JM2L] Mon inscription au site web JM2L",
sender="contact@jm2l.linux-azur.org",
recipients=[NewUser.mail],
body=body, html=html)
message.add_bcc("spam@style-python.fr")
mailer.send(message)



MainTab = {'programme':'','presse':'', 'plan':'', MainTab = {'programme':'','presse':'', 'plan':'',
'participer':'active', 'form':form, "link": MyLink, 'participer':'active', 'form':form, "link": MyLink,
'logged_in':request.authenticated_userid } 'logged_in':request.authenticated_userid }


Loading…
Cancel
Save