From 3e22a6a8903ba16463426d8e1e47ffb63189f47d Mon Sep 17 00:00:00 2001 From: tr4ck3ur Date: Mon, 28 Sep 2020 23:34:25 +0200 Subject: [PATCH] Latest fixes for python 3 branch --- jm2l/__init__.py | 5 +- jm2l/auth.py | 4 +- jm2l/models.py | 2 +- jm2l/security.py | 1 + jm2l/templates/Public/Programme.mako | 2 +- jm2l/templates/edit_event.mako | 4 +- jm2l/templates/helpers.mako | 4 +- jm2l/templates/layout.mako | 22 +------- jm2l/views.py | 82 ++++++++++++++-------------- 9 files changed, 56 insertions(+), 70 deletions(-) diff --git a/jm2l/__init__.py b/jm2l/__init__.py index 3b5a18f..d62820a 100644 --- a/jm2l/__init__.py +++ b/jm2l/__init__.py @@ -33,10 +33,10 @@ def add_renderer_globals(event): # @sched.scheduled_job('cron', day_of_week='sun', hour=22, minute=7) def mailer_tasks(config): # Send the Welcome Mail - mailer = config.registry['mailer'] contact = DBSession.query(User).filter(User.uid == 1).one() request = Request.blank('/', base_url='http://jm2l.linux-azur.org') request.registry = config.registry + mailer = request.mailer for staff_user in DBSession.query(User).filter(User.Staff is True): # Skip mail to contact if staff_user == contact: @@ -81,8 +81,7 @@ def main(global_config, **settings): authentication_policy=authentication_policy, authorization_policy=authorization_policy ) - #config.include('pyramid_mailer') - config.include('pyramid_mailer.debug') + config.include('pyramid_mailer') config.add_subscriber(add_renderer_globals, BeforeRender) print(settings) # config.registry['mailer'] = mailer_factory_from_settings(settings) diff --git a/jm2l/auth.py b/jm2l/auth.py index aae3197..f9fb16d 100644 --- a/jm2l/auth.py +++ b/jm2l/auth.py @@ -12,10 +12,12 @@ from .security import check_logged import datetime import re + @view_config(route_name='auth', match_param="action=login", renderer="jm2l:templates/login.mako") def login(request): return {"comefrom":request.GET.get('from', "")} + @view_config(route_name='auth', match_param="action=forgot", renderer="jm2l:templates/login.mako") def forgot(request): if request.method == 'POST' and request.POST: @@ -31,7 +33,7 @@ def forgot(request): return { 'forgot': True } else: # Send the Forgot Mail - mailer = request.registry['mailer'] + mailer = request.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") diff --git a/jm2l/models.py b/jm2l/models.py index 02fd928..e4b2991 100644 --- a/jm2l/models.py +++ b/jm2l/models.py @@ -657,7 +657,7 @@ class Event(Base): intervenants = relationship(User, secondary='user_event_link', backref=backref('participate', uselist=False), - lazy='dynamic') + lazy='subquery') interventions = relationship(User_Event, backref="matching_events") Salle = relationship(Salles, backref='allevents') diff --git a/jm2l/security.py b/jm2l/security.py index 7ea0b8a..f5141bb 100644 --- a/jm2l/security.py +++ b/jm2l/security.py @@ -15,6 +15,7 @@ def check_logged(request): # Don't answer to users that aren't logged raise HTTPForbidden(u'Vous devez vous identifier pour obtenir une réponse.') + def check_staff(request): """ This function is intended to raise an exception if the user is not a Staff member""" check_logged(request) diff --git a/jm2l/templates/Public/Programme.mako b/jm2l/templates/Public/Programme.mako index d45f06e..959acd6 100644 --- a/jm2l/templates/Public/Programme.mako +++ b/jm2l/templates/Public/Programme.mako @@ -132,7 +132,7 @@ if Counter==0:
avec - % for num, inter in enumerate(event.intervenants.all()): + % for num, inter in enumerate(event.intervenants): %if num>0: , %endif diff --git a/jm2l/templates/edit_event.mako b/jm2l/templates/edit_event.mako index 99771da..55b61fd 100644 --- a/jm2l/templates/edit_event.mako +++ b/jm2l/templates/edit_event.mako @@ -43,7 +43,7 @@
Intervenants programmés:
% endif
- % if event.intervenants.count()>1: + % if len(event.intervenants)>1: avec - % for num, inter in enumerate(event.intervenants.all()): + % for num, inter in enumerate(event.intervenants): <% if inter==uprofil: continue diff --git a/jm2l/templates/layout.mako b/jm2l/templates/layout.mako index 8ac5f61..9adc839 100644 --- a/jm2l/templates/layout.mako +++ b/jm2l/templates/layout.mako @@ -188,18 +188,18 @@ ${helpers.uploader_js()}

JM2L 2005-2020

- Concocté par Linux Azur ~ + Concocté par Linux Azur ~ CopyFriendly

+33 6 52 42 31 37 ~ contact at jm2l.linux-azur dot org

- Conception et construction en DIY ~ + Conception et construction en DIY ~ Hébergé par Heberg24

- Vous avez trouvé un bug ? Reportez-le ici + Vous avez trouvé un bug ? Reportez-le ici

@@ -222,22 +222,6 @@ ${jsitem | n} HandleControls(); - % if request.user: