5 Commits

Author SHA1 Message Date
tr4ck3ur b7e2ea559e Latest fix on thumbnail generation 2020-09-29 22:49:30 +02:00
tr4ck3ur e62ff8b5b7 Fixed map to list 2020-09-29 01:14:11 +02:00
tr4ck3ur ce61e2c258 Fixed home page 2020-09-29 00:26:20 +02:00
tr4ck3ur a8399d0646 wsgi for python3 2020-09-28 23:41:02 +02:00
tr4ck3ur 3e22a6a890 Latest fixes for python 3 branch 2020-09-28 23:34:25 +02:00
13 changed files with 87 additions and 102 deletions
+2 -3
View File
@@ -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)
+3 -1
View File
@@ -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")
+2 -2
View File
@@ -112,7 +112,7 @@ class TiersMember(MyBaseForm):
csrf = False
year_uid = SelectField(u'Année', coerce=int,
choices=zip(range(2006, CurrentYear + 1), range(2006, CurrentYear + 1)))
choices=list(zip(range(2006, CurrentYear + 1), range(2006, CurrentYear + 1))))
user_uid = StringField(u'user')
role = StringField(u'Role')
@@ -122,7 +122,7 @@ class TiersRole(MyBaseForm):
csrf = False
year_uid = SelectField(u'Année', coerce=int,
choices=zip(range(2006, CurrentYear + 1), range(2006, CurrentYear + 1)))
choices=list(zip(range(2006, CurrentYear + 1), range(2006, CurrentYear + 1))))
tiers_role = SelectField(u'Role', choices=TIERS_ROLE)
+1 -1
View File
@@ -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')
+1
View File
@@ -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)
+1 -1
View File
@@ -1,6 +1,6 @@
<%inherit file="jm2l:templates/layout.mako"/>
<%def name="jsAddOn()">
<script src="/vendor/timeline/js/timeline-src.js"></script>
<script src="/vendor/timeline/js/timeline-min.js"></script>
<script>
var timeline = new VMM.Timeline("timeline", '95%', '600px');
var c = {language:{ lang:"fr",api:{wikipedia:"fr"},date:{month:["janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre"],month_abbr:["janv.","févr.","mars","avril","mai","juin","juil.","août","sept.","oct.","nov.","dec."],day:["Dimanche","Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi"],day_abbr:["Dim.","Lu.","Ma.","Me.","Jeu.","Vend.","Sam."]},dateformats:{year:"yyyy",month_short:"mmm",month:"mmmm yyyy",full_short:"d mmm",full:"d mmmm yyyy",time_short:"HH:MM:SS",time_no_seconds_short:"HH:MM",time_no_seconds_small_date:"HH:MM'<br/><small>'d mmmm yyyy'</small>'",full_long:"dddd',' d mmm yyyy 'à' HH:MM",full_long_small_date:"HH:MM'<br/><small>'dddd',' d mmm yyyy'</small>'"},messages:{loading_timeline:"Chargement de la frise en cours... ",return_to_title:"Retour à la page d'accueil",expand_timeline:"Elargir la frise",contract_timeline:"Réduire la frise",wikipedia:"Extrait de Wikipedia, l'encyclopédie libre",loading_content:"Chargement",loading:"Chargement",swipe_nav:"Swipe to Navigate"}}};
+1 -1
View File
@@ -132,7 +132,7 @@ if Counter==0:
</span>
<br/>
avec
% for num, inter in enumerate(event.intervenants.all()):
% for num, inter in enumerate(event.intervenants):
%if num>0:
,
%endif
+2 -2
View File
@@ -43,7 +43,7 @@
<div class="borderbox">
Intervenants programmés:
<ul>
% if event.intervenants.count()==0:
% if len(event.intervenants)==0:
<i><b>Aucun</b></i>
% else:
% for num, iterv in enumerate(event.intervenants):
@@ -160,7 +160,7 @@ DicForm = {
<td>
<u>Les Intervenants:</u>
<ul>
% if event.intervenants.count()==0:
% if len(event.intervenants)==0:
<i><b>Aucun</b></i>
% else:
% for num, iterv in enumerate(event.intervenants):
+2 -2
View File
@@ -391,9 +391,9 @@ TabJs = {'select':[], 'desc':[]}
</div>
% endif
<br/>
% 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
+3 -19
View File
@@ -188,18 +188,18 @@ ${helpers.uploader_js()}
<div class="container">
<h4>JM2L 2005-2020</h4>
<p>
Concocté par <a href="http://www.linux-azur.org/">Linux Azur</a> ~
Concocté par <a href="https://www.linux-azur.org/">Linux Azur</a> ~
<a href="http://creativecommons.org/licenses/by-sa/4.0/">CopyFriendly</a>
</p>
<p>
+33 6 52 42 31 37 ~ contact at jm2l.linux-azur dot org
</p>
<p>
Conception et construction en <a href="http://git.linux-azur.org/JM2L/jm2l/src/master">DIY</a> ~
Conception et construction en <a href="https://git.linux-azur.org/tr4ck3ur/jm2l/src/branch/feature/python-3-migration">DIY</a> ~
Hébergé par <a href="http://www.heberg-24.com/"> Heberg24 </a>
</p>
<p>
Vous avez trouvé un bug ? <a href="http://git.linux-azur.org/JM2L/jm2l/issues">Reportez-le ici</a>
Vous avez trouvé un bug ? <a href="https://git.linux-azur.org/tr4ck3ur/jm2l/issues/new">Reportez-le ici</a>
</p>
</div>
</footer>
@@ -222,22 +222,6 @@ ${jsitem | n}
HandleControls();
</script>
<!-- Piwik
<script type="text/javascript">
var _paq = _paq || [];
_paq.push(["setDocumentTitle", document.domain + "/" + document.title]);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//stats.style-python.fr/";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', 4]);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<noscript><p><img src="//stats.style-python.fr/piwik.php?idsite=4" style="border:0;" alt="" /></p></noscript>
End Piwik Code -->
% if request.user:
<script>
function handlevote() {
+9 -7
View File
@@ -314,8 +314,10 @@ class MediaUpload(MediaPath):
timage = Image.new('RGBA', (THUMBNAIL_SIZE, THUMBNAIL_SIZE), (255, 255, 255, 0))
timage.paste(
image,
((THUMBNAIL_SIZE - image.size[0]) / 2, (THUMBNAIL_SIZE - image.size[1]) / 2))
(int((THUMBNAIL_SIZE - image.size[0]) / 2), int((THUMBNAIL_SIZE - image.size[1]) / 2)))
TargetFileName = self.thumbnailpath(filename)
if not TargetFileName.endswith('png'):
timage = timage.convert('RGB')
timage.save(TargetFileName)
return self.thumbnailurl(os.path.basename(TargetFileName))
@@ -331,7 +333,7 @@ class MediaUpload(MediaPath):
# Add thumbnail
timage.paste(
image,
((THUMBNAIL_SIZE - image.size[0]) / 2, (THUMBNAIL_SIZE - image.size[1]) / 2))
(int((THUMBNAIL_SIZE - image.size[0]) / 2), int((THUMBNAIL_SIZE - image.size[1]) / 2)))
# Stamp with PDF file type
timage.paste(
pdf_indicator,
@@ -355,7 +357,7 @@ class MediaUpload(MediaPath):
# Add thumbnail
timage.paste(
image,
((THUMBNAIL_SIZE - image.size[0]) / 2, (THUMBNAIL_SIZE - image.size[1]) / 2))
(int((THUMBNAIL_SIZE - image.size[0]) / 2), int((THUMBNAIL_SIZE - image.size[1]) / 2)))
# Stamp with PDF file type
timage.paste(
pdf_indicator,
@@ -387,7 +389,7 @@ class MediaUpload(MediaPath):
# Add thumbnail
timage.paste(
image,
((THUMBNAIL_SIZE - image.size[0]) / 2, (THUMBNAIL_SIZE - image.size[1]) / 2))
(int((THUMBNAIL_SIZE - image.size[0]) / 2), int((THUMBNAIL_SIZE - image.size[1]) / 2)))
# Stamp with PDF file type
timage.paste(
stamp,
@@ -420,7 +422,7 @@ class MediaUpload(MediaPath):
# Add thumbnail
timage.paste(
image,
((THUMBNAIL_SIZE - image.size[0]) / 2, (THUMBNAIL_SIZE - image.size[1]) / 2))
(int((THUMBNAIL_SIZE - image.size[0]) / 2), int((THUMBNAIL_SIZE - image.size[1]) / 2)))
# Stamp with Blender file type
timage.paste(
blender_indicator,
@@ -526,8 +528,8 @@ class MediaUpload(MediaPath):
return self.delete()
results = []
for name, fieldStorage in self.request.POST.items():
if isinstance(fieldStorage, unicode):
continue
# if isinstance(fieldStorage, unicode):
# continue
result = {}
result['name'] = os.path.basename(fieldStorage.filename)
result['type'] = fieldStorage.type
+57 -57
View File
@@ -25,6 +25,7 @@ from pyramid_mailer.message import Message
from .security import check_staff, check_logged
# Then, standard libs
import csv
try:
from StringIO import StringIO
except ImportError:
@@ -41,7 +42,7 @@ from jm2l.const import CurrentYear
from passlib.hash import argon2
## =-=- Here, We keep some usefull function -=-=
# =-=- Here, We keep some usefull function -=-=
def remove_accents(input_str):
""" This function is intended to remove all accent from input unicode string """
nkfd_form = unicodedata.normalize('NFKD', input_str)
@@ -70,7 +71,7 @@ def Live(request):
return {'year': year, "DisplayYear": year, 'events': Events, "logged_in": request.authenticated_userid}
## =-=- Here, We handle ICal requests -=-=
# =-=- Here, We handle ICal requests -=-=
@view_config(route_name='progr_iCal', renderer="string")
def ICal_Progamme_Request(request):
year = int(request.matchdict.get('year', CurrentYear))
@@ -171,39 +172,38 @@ def ICal_Progamme_Dyn_Request(request):
## =-=- Here, We handle Json requests -=-=
@view_config(route_name='users_json', renderer="json")
def JSON_User_Request(request):
""" Build a JSON answer with active users and pagination handling """
# Check arguments consitency
pageSize = request.params.get('pageSize', "8")
current_page = request.params.get('pageNum', "1")
UserQuery = request.params.get('searchTerm', u"")
# Don't answer to users that aren't logged
if not request.user:
raise HTTPForbidden(u'Vous devez vous identifier pour obtenir une réponse.')
# Check consistancy of parameters
if pageSize.isdigit() and current_page.isdigit():
current_page = int(current_page)
pageSize = int(pageSize)
else:
return HTTPBadRequest('pageSize and pageNum accept only digits.')
# Query database
Users = DBSession.query(User.uid, User.nom, User.prenom) \
.filter(User.slug.contains(remove_accents(UserQuery)))
page_url = paginate.PageURL_WebOb(request)
records = paginate.Page(Users, current_page, url=page_url, items_per_page=pageSize)
ListMatchUser = map(lambda u: {"id": u.uid, "text": "%s %s" % (u.prenom, u.nom)}, records)
return {"Results": ListMatchUser, "Total": records.item_count,
"logged_in": request.authenticated_userid}
def get_paginator(request, page=1, items_per_page=10):
def url_maker(page_number):
query = request.GET
query["page"] = str(page_number)
return request.current_route_url(_query=query)
return Page(sql-query-here, page=page, items_per_page=items_per_page, url_maker=url_maker)
@view_config(route_name='users_json', renderer="json")
def JSON_User_Request(request):
""" Build a JSON answer with active users and pagination handling """
# Check arguments consitency
page_size = request.params.get('pageSize', "8")
current_page = request.params.get('pageNum', "1")
user_query = request.params.get('searchTerm', u"")
# Don't answer to users that aren't logged
if not request.user:
raise HTTPForbidden(u'Vous devez vous identifier pour obtenir une réponse.')
# Check constancy of parameters
if page_size.isdigit() and current_page.isdigit():
current_page = int(current_page)
page_size = int(page_size)
else:
return HTTPBadRequest('pageSize and pageNum accept only digits.')
# Query database
part = remove_accents(user_query)
users_set = DBSession.query(User.uid, User.nom, User.prenom) \
.filter(User.slug.contains(part.decode("utf-8"))).all()
records = paginate.Page(users_set, current_page, url_maker=url_maker, items_per_page=page_size)
list_match_user = list(map(lambda u: {"id": u.uid, "text": "%s %s" % (u.prenom, u.nom)}, records))
return {"Results": list_match_user, "Total": records.item_count,
"logged_in": request.authenticated_userid}
@view_config(route_name='tiers_json', renderer="json")
@@ -223,13 +223,13 @@ def JSON_Tiers_Request(request):
else:
return HTTPBadRequest('pageSize and pageNum accept only digits.')
# Query database
JTiers = DBSession.query(Tiers.uid, Tiers.name) \
.filter(Tiers.slug.contains(remove_accents(TiersQuery)))
part = remove_accents(TiersQuery)
j_tiers = DBSession.query(Tiers.uid, Tiers.name) \
.filter(Tiers.slug.contains(part.decode("utf-8"))).all()
page_url = paginate.PageURL_WebOb(request)
records = paginate.Page(JTiers, current_page, url=page_url, items_per_page=pageSize)
ListMatchTiers = map(lambda t: {"id": t.uid, "text": t.name}, records)
return {"Results": ListMatchTiers, "Total": records.item_count,
records = paginate.Page(j_tiers, current_page, url_maker=url_maker, items_per_page=pageSize)
list_match_tiers = list(map(lambda t: {"id": t.uid, "text": t.name}, records.items))
return {"Results": list_match_tiers, "Total": records.item_count,
"logged_in": request.authenticated_userid}
@@ -237,25 +237,25 @@ def JSON_Tiers_Request(request):
def JSON_Progamme_Request(request):
year = int(request.matchdict.get('year', CurrentYear))
# Initialization
DicResult = dict()
dic_result = dict()
# Query database
# Compute days used by all events matching the specified input year
Days = DBSession.query(func.strftime('%d', Event.start_time).label('day')) \
days = DBSession.query(func.strftime('%d', Event.start_time).label('day')) \
.filter(Event.for_year == year) \
.filter(Event.event_type != None) \
.filter(Event.event_type is not None) \
.group_by(func.strftime('%d', Event.start_time)).all()
for Day in Days:
Events = DBSession.query(Event) \
for Day in days:
events = DBSession.query(Event) \
.filter(Event.for_year == year) \
.filter(Event.event_type != 'Stand') \
.filter(text("strftime('%d', start_time) = :dow")).params(dow=Day.day) \
.order_by(Event.start_time)
ListEv = []
for ev in Events:
list_ev = []
for ev in events:
if ev.event_type:
ListEv.append({
list_ev.append({
"uid": "%d/%d" % (year, ev.uid),
"desc": ev.name,
"startDate": ev.start_time.strftime('%Y-%m-%dT%H:%M:%S+01:00'),
@@ -263,9 +263,9 @@ def JSON_Progamme_Request(request):
"placeName": ev.Salle and (ev.Salle.name or "unk"),
"status": ev.event_type
})
DicResult[Day.day] = ListEv
dic_result[Day.day] = list_ev
return {'all': DicResult}
return {'all': dic_result}
@view_config(route_name='timeline_json', renderer="json")
@@ -312,18 +312,18 @@ def JSON_TimeLine_Request(request):
"credit": ",".join(["%s %s" % (i.prenom, i.nom) for i in ev.intervenants]),
"caption": ""}
})
if year == 2018:
if year == 2020:
DicResult = {
"lang": "fr",
"headline": "JM2L 2018",
"headline": "JM2L 2020",
"type": "default",
"startDate": "2018,12,15,10",
"startDate": "2020,11,28,10",
"text": "<i><span class='c1'>11ème Édition</span></i>",
"asset":
{
"media": embeed_video("video/ogg", "/resources/2017/Video/JM2L2017_Reportage_FR3.ogv"),
"credit": "Reportage France 3",
"caption": "JM2L 2018"
"caption": "Dans nos précédentes éditions, une vidéo des JM2L 2017"
}
}
elif year == 2017:
@@ -1716,21 +1716,21 @@ def edit_event(request):
]
salle_dispo = salle_dispo.filter(Salles.place_type == 'Stand')
elif intervention == "Atelier":
form.duration.choices = map(lambda d: (d, u'Atelier (%dh%.2d)' % (d / 60, d % 60)),
[60, 90, 120, 150, 180, 210, 240])
if not duration in map(lambda d, y: d, form.duration.choices):
form.duration.choices = list(map(lambda d: (d, u'Atelier (%dh%.2d)' % (d / 60, d % 60)),
[60, 90, 120, 150, 180, 210, 240]))
if not duration in map(lambda d: d[0], form.duration.choices):
form.duration.choices.append((duration, u'Atelier (%dh%.2d)' % (duration / 60, duration % 60)))
salle_dispo = salle_dispo.filter(Salles.place_type.in_(['Atelier', 'MAO']))
elif intervention == "Table_ronde":
form.duration.choices = map(lambda d: (d, u'Table ronde (%dh%.2d)' % (d / 60, d % 60)),
[60, 90, 120, 150])
if not duration in map(lambda d, y: d, form.duration.choices):
form.duration.choices = list(map(lambda d: (d, u'Table ronde (%dh%.2d)' % (d / 60, d % 60)),
[60, 90, 120, 150]))
if not duration in map(lambda d: d[0], form.duration.choices):
form.duration.choices.append((duration, u'Table ronde (%dh%.2d)' % (duration / 60, duration % 60)))
salle_dispo = salle_dispo.filter(Salles.place_type == 'Table ronde')
elif intervention == "Concert":
form.duration.choices = map(lambda d: (d, u'Concert (%dh%.2d)' % (d / 60, d % 60)),
[60, 90, 120, 150, 180, 210, 240])
if not duration in map(lambda d, y: d, form.duration.choices):
form.duration.choices = list(map(lambda d: (d, u'Concert (%dh%.2d)' % (d / 60, d % 60)),
[60, 90, 120, 150, 180, 210, 240]))
if not duration in map(lambda d: d[0], form.duration.choices):
form.duration.choices.append((duration, u'Concert (%dh%.2d)' % (duration / 60, duration % 60)))
salle_dispo = salle_dispo.filter(Salles.place_type.in_(['Stand', 'MAO']))
else:
+6 -9
View File
@@ -1,9 +1,6 @@
APP_CONFIG = "prod.ini"
#Setup logging
import logging.config
logging.config.fileConfig(APP_CONFIG)
#Load the application
from paste.deploy import loadapp
application = loadapp('config:%s' % APP_CONFIG)
import sys
sys.path.append("/srv/.venv_jm2l/lib/python3.7/site-packages")
ini_path = "/srv/jm2l.linux-azur.org/jm2l/production.ini"
from pyramid.paster import get_app, setup_logging
setup_logging(ini_path)
application = get_app(ini_path, 'main')