forked from tr4ck3ur/jm2l
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b7e2ea559e | |||
| e62ff8b5b7 | |||
| ce61e2c258 | |||
| a8399d0646 | |||
| 3e22a6a890 |
+2
-3
@@ -33,10 +33,10 @@ def add_renderer_globals(event):
|
|||||||
# @sched.scheduled_job('cron', day_of_week='sun', hour=22, minute=7)
|
# @sched.scheduled_job('cron', day_of_week='sun', hour=22, minute=7)
|
||||||
def mailer_tasks(config):
|
def mailer_tasks(config):
|
||||||
# Send the Welcome Mail
|
# Send the Welcome Mail
|
||||||
mailer = config.registry['mailer']
|
|
||||||
contact = DBSession.query(User).filter(User.uid == 1).one()
|
contact = DBSession.query(User).filter(User.uid == 1).one()
|
||||||
request = Request.blank('/', base_url='http://jm2l.linux-azur.org')
|
request = Request.blank('/', base_url='http://jm2l.linux-azur.org')
|
||||||
request.registry = config.registry
|
request.registry = config.registry
|
||||||
|
mailer = request.mailer
|
||||||
for staff_user in DBSession.query(User).filter(User.Staff is True):
|
for staff_user in DBSession.query(User).filter(User.Staff is True):
|
||||||
# Skip mail to contact
|
# Skip mail to contact
|
||||||
if staff_user == contact:
|
if staff_user == contact:
|
||||||
@@ -81,8 +81,7 @@ def main(global_config, **settings):
|
|||||||
authentication_policy=authentication_policy,
|
authentication_policy=authentication_policy,
|
||||||
authorization_policy=authorization_policy
|
authorization_policy=authorization_policy
|
||||||
)
|
)
|
||||||
#config.include('pyramid_mailer')
|
config.include('pyramid_mailer')
|
||||||
config.include('pyramid_mailer.debug')
|
|
||||||
config.add_subscriber(add_renderer_globals, BeforeRender)
|
config.add_subscriber(add_renderer_globals, BeforeRender)
|
||||||
print(settings)
|
print(settings)
|
||||||
# config.registry['mailer'] = mailer_factory_from_settings(settings)
|
# config.registry['mailer'] = mailer_factory_from_settings(settings)
|
||||||
|
|||||||
+3
-1
@@ -12,10 +12,12 @@ from .security import check_logged
|
|||||||
import datetime
|
import datetime
|
||||||
import re
|
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):
|
||||||
return {"comefrom":request.GET.get('from', "")}
|
return {"comefrom":request.GET.get('from', "")}
|
||||||
|
|
||||||
|
|
||||||
@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):
|
||||||
if request.method == 'POST' and request.POST:
|
if request.method == 'POST' and request.POST:
|
||||||
@@ -31,7 +33,7 @@ def forgot(request):
|
|||||||
return { 'forgot': True }
|
return { 'forgot': True }
|
||||||
else:
|
else:
|
||||||
# Send the Forgot Mail
|
# Send the Forgot Mail
|
||||||
mailer = request.registry['mailer']
|
mailer = request.mailer
|
||||||
# Prepare Plain Text Message :
|
# Prepare Plain Text Message :
|
||||||
Mail_template = Template(filename='jm2l/templates/mail_plain.mako')
|
Mail_template = Template(filename='jm2l/templates/mail_plain.mako')
|
||||||
mail_plain = Mail_template.render(request=request, User=UserFound, action="Forgot")
|
mail_plain = Mail_template.render(request=request, User=UserFound, action="Forgot")
|
||||||
|
|||||||
+2
-2
@@ -112,7 +112,7 @@ class TiersMember(MyBaseForm):
|
|||||||
csrf = False
|
csrf = False
|
||||||
|
|
||||||
year_uid = SelectField(u'Année', coerce=int,
|
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')
|
user_uid = StringField(u'user')
|
||||||
role = StringField(u'Role')
|
role = StringField(u'Role')
|
||||||
|
|
||||||
@@ -122,7 +122,7 @@ class TiersRole(MyBaseForm):
|
|||||||
csrf = False
|
csrf = False
|
||||||
|
|
||||||
year_uid = SelectField(u'Année', coerce=int,
|
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)
|
tiers_role = SelectField(u'Role', choices=TIERS_ROLE)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -657,7 +657,7 @@ class Event(Base):
|
|||||||
intervenants = relationship(User,
|
intervenants = relationship(User,
|
||||||
secondary='user_event_link',
|
secondary='user_event_link',
|
||||||
backref=backref('participate', uselist=False),
|
backref=backref('participate', uselist=False),
|
||||||
lazy='dynamic')
|
lazy='subquery')
|
||||||
interventions = relationship(User_Event, backref="matching_events")
|
interventions = relationship(User_Event, backref="matching_events")
|
||||||
Salle = relationship(Salles, backref='allevents')
|
Salle = relationship(Salles, backref='allevents')
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ def check_logged(request):
|
|||||||
# Don't answer to users that aren't logged
|
# Don't answer to users that aren't logged
|
||||||
raise HTTPForbidden(u'Vous devez vous identifier pour obtenir une réponse.')
|
raise HTTPForbidden(u'Vous devez vous identifier pour obtenir une réponse.')
|
||||||
|
|
||||||
|
|
||||||
def check_staff(request):
|
def check_staff(request):
|
||||||
""" This function is intended to raise an exception if the user is not a Staff member"""
|
""" This function is intended to raise an exception if the user is not a Staff member"""
|
||||||
check_logged(request)
|
check_logged(request)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<%inherit file="jm2l:templates/layout.mako"/>
|
<%inherit file="jm2l:templates/layout.mako"/>
|
||||||
<%def name="jsAddOn()">
|
<%def name="jsAddOn()">
|
||||||
<script src="/vendor/timeline/js/timeline-src.js"></script>
|
<script src="/vendor/timeline/js/timeline-min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
var timeline = new VMM.Timeline("timeline", '95%', '600px');
|
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"}}};
|
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"}}};
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ if Counter==0:
|
|||||||
</span>
|
</span>
|
||||||
<br/>
|
<br/>
|
||||||
avec
|
avec
|
||||||
% for num, inter in enumerate(event.intervenants.all()):
|
% for num, inter in enumerate(event.intervenants):
|
||||||
%if num>0:
|
%if num>0:
|
||||||
,
|
,
|
||||||
%endif
|
%endif
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
<div class="borderbox">
|
<div class="borderbox">
|
||||||
Intervenants programmés:
|
Intervenants programmés:
|
||||||
<ul>
|
<ul>
|
||||||
% if event.intervenants.count()==0:
|
% if len(event.intervenants)==0:
|
||||||
<i><b>Aucun</b></i>
|
<i><b>Aucun</b></i>
|
||||||
% else:
|
% else:
|
||||||
% for num, iterv in enumerate(event.intervenants):
|
% for num, iterv in enumerate(event.intervenants):
|
||||||
@@ -160,7 +160,7 @@ DicForm = {
|
|||||||
<td>
|
<td>
|
||||||
<u>Les Intervenants:</u>
|
<u>Les Intervenants:</u>
|
||||||
<ul>
|
<ul>
|
||||||
% if event.intervenants.count()==0:
|
% if len(event.intervenants)==0:
|
||||||
<i><b>Aucun</b></i>
|
<i><b>Aucun</b></i>
|
||||||
% else:
|
% else:
|
||||||
% for num, iterv in enumerate(event.intervenants):
|
% for num, iterv in enumerate(event.intervenants):
|
||||||
|
|||||||
@@ -391,9 +391,9 @@ TabJs = {'select':[], 'desc':[]}
|
|||||||
</div>
|
</div>
|
||||||
% endif
|
% endif
|
||||||
<br/>
|
<br/>
|
||||||
% if event.intervenants.count()>1:
|
% if len(event.intervenants)>1:
|
||||||
avec
|
avec
|
||||||
% for num, inter in enumerate(event.intervenants.all()):
|
% for num, inter in enumerate(event.intervenants):
|
||||||
<%
|
<%
|
||||||
if inter==uprofil:
|
if inter==uprofil:
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -188,18 +188,18 @@ ${helpers.uploader_js()}
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<h4>JM2L 2005-2020</h4>
|
<h4>JM2L 2005-2020</h4>
|
||||||
<p>
|
<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>
|
<a href="http://creativecommons.org/licenses/by-sa/4.0/">CopyFriendly</a>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
+33 6 52 42 31 37 ~ contact at jm2l.linux-azur dot org
|
+33 6 52 42 31 37 ~ contact at jm2l.linux-azur dot org
|
||||||
</p>
|
</p>
|
||||||
<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>
|
Hébergé par <a href="http://www.heberg-24.com/"> Heberg24 </a>
|
||||||
</p>
|
</p>
|
||||||
<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>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
@@ -222,22 +222,6 @@ ${jsitem | n}
|
|||||||
HandleControls();
|
HandleControls();
|
||||||
</script>
|
</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:
|
% if request.user:
|
||||||
<script>
|
<script>
|
||||||
function handlevote() {
|
function handlevote() {
|
||||||
|
|||||||
+9
-7
@@ -314,8 +314,10 @@ class MediaUpload(MediaPath):
|
|||||||
timage = Image.new('RGBA', (THUMBNAIL_SIZE, THUMBNAIL_SIZE), (255, 255, 255, 0))
|
timage = Image.new('RGBA', (THUMBNAIL_SIZE, THUMBNAIL_SIZE), (255, 255, 255, 0))
|
||||||
timage.paste(
|
timage.paste(
|
||||||
image,
|
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)
|
TargetFileName = self.thumbnailpath(filename)
|
||||||
|
if not TargetFileName.endswith('png'):
|
||||||
|
timage = timage.convert('RGB')
|
||||||
timage.save(TargetFileName)
|
timage.save(TargetFileName)
|
||||||
return self.thumbnailurl(os.path.basename(TargetFileName))
|
return self.thumbnailurl(os.path.basename(TargetFileName))
|
||||||
|
|
||||||
@@ -331,7 +333,7 @@ class MediaUpload(MediaPath):
|
|||||||
# Add thumbnail
|
# Add thumbnail
|
||||||
timage.paste(
|
timage.paste(
|
||||||
image,
|
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
|
# Stamp with PDF file type
|
||||||
timage.paste(
|
timage.paste(
|
||||||
pdf_indicator,
|
pdf_indicator,
|
||||||
@@ -355,7 +357,7 @@ class MediaUpload(MediaPath):
|
|||||||
# Add thumbnail
|
# Add thumbnail
|
||||||
timage.paste(
|
timage.paste(
|
||||||
image,
|
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
|
# Stamp with PDF file type
|
||||||
timage.paste(
|
timage.paste(
|
||||||
pdf_indicator,
|
pdf_indicator,
|
||||||
@@ -387,7 +389,7 @@ class MediaUpload(MediaPath):
|
|||||||
# Add thumbnail
|
# Add thumbnail
|
||||||
timage.paste(
|
timage.paste(
|
||||||
image,
|
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
|
# Stamp with PDF file type
|
||||||
timage.paste(
|
timage.paste(
|
||||||
stamp,
|
stamp,
|
||||||
@@ -420,7 +422,7 @@ class MediaUpload(MediaPath):
|
|||||||
# Add thumbnail
|
# Add thumbnail
|
||||||
timage.paste(
|
timage.paste(
|
||||||
image,
|
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
|
# Stamp with Blender file type
|
||||||
timage.paste(
|
timage.paste(
|
||||||
blender_indicator,
|
blender_indicator,
|
||||||
@@ -526,8 +528,8 @@ class MediaUpload(MediaPath):
|
|||||||
return self.delete()
|
return self.delete()
|
||||||
results = []
|
results = []
|
||||||
for name, fieldStorage in self.request.POST.items():
|
for name, fieldStorage in self.request.POST.items():
|
||||||
if isinstance(fieldStorage, unicode):
|
# if isinstance(fieldStorage, unicode):
|
||||||
continue
|
# continue
|
||||||
result = {}
|
result = {}
|
||||||
result['name'] = os.path.basename(fieldStorage.filename)
|
result['name'] = os.path.basename(fieldStorage.filename)
|
||||||
result['type'] = fieldStorage.type
|
result['type'] = fieldStorage.type
|
||||||
|
|||||||
+53
-53
@@ -25,6 +25,7 @@ from pyramid_mailer.message import Message
|
|||||||
from .security import check_staff, check_logged
|
from .security import check_staff, check_logged
|
||||||
# Then, standard libs
|
# Then, standard libs
|
||||||
import csv
|
import csv
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from StringIO import StringIO
|
from StringIO import StringIO
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@@ -41,7 +42,7 @@ from jm2l.const import CurrentYear
|
|||||||
from passlib.hash import argon2
|
from passlib.hash import argon2
|
||||||
|
|
||||||
|
|
||||||
## =-=- Here, We keep some usefull function -=-=
|
# =-=- Here, We keep some usefull function -=-=
|
||||||
def remove_accents(input_str):
|
def remove_accents(input_str):
|
||||||
""" This function is intended to remove all accent from input unicode string """
|
""" This function is intended to remove all accent from input unicode string """
|
||||||
nkfd_form = unicodedata.normalize('NFKD', input_str)
|
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}
|
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")
|
@view_config(route_name='progr_iCal', renderer="string")
|
||||||
def ICal_Progamme_Request(request):
|
def ICal_Progamme_Request(request):
|
||||||
year = int(request.matchdict.get('year', CurrentYear))
|
year = int(request.matchdict.get('year', CurrentYear))
|
||||||
@@ -171,40 +172,39 @@ def ICal_Progamme_Dyn_Request(request):
|
|||||||
|
|
||||||
|
|
||||||
## =-=- Here, We handle Json requests -=-=
|
## =-=- Here, We handle Json requests -=-=
|
||||||
|
|
||||||
|
def url_maker(page_number):
|
||||||
|
query = request.GET
|
||||||
|
query["page"] = str(page_number)
|
||||||
|
return request.current_route_url(_query=query)
|
||||||
|
|
||||||
|
|
||||||
@view_config(route_name='users_json', renderer="json")
|
@view_config(route_name='users_json', renderer="json")
|
||||||
def JSON_User_Request(request):
|
def JSON_User_Request(request):
|
||||||
""" Build a JSON answer with active users and pagination handling """
|
""" Build a JSON answer with active users and pagination handling """
|
||||||
# Check arguments consitency
|
# Check arguments consitency
|
||||||
pageSize = request.params.get('pageSize', "8")
|
page_size = request.params.get('pageSize', "8")
|
||||||
current_page = request.params.get('pageNum', "1")
|
current_page = request.params.get('pageNum', "1")
|
||||||
UserQuery = request.params.get('searchTerm', u"")
|
user_query = request.params.get('searchTerm', u"")
|
||||||
# Don't answer to users that aren't logged
|
# Don't answer to users that aren't logged
|
||||||
if not request.user:
|
if not request.user:
|
||||||
raise HTTPForbidden(u'Vous devez vous identifier pour obtenir une réponse.')
|
raise HTTPForbidden(u'Vous devez vous identifier pour obtenir une réponse.')
|
||||||
# Check consistancy of parameters
|
# Check constancy of parameters
|
||||||
if pageSize.isdigit() and current_page.isdigit():
|
if page_size.isdigit() and current_page.isdigit():
|
||||||
current_page = int(current_page)
|
current_page = int(current_page)
|
||||||
pageSize = int(pageSize)
|
page_size = int(page_size)
|
||||||
else:
|
else:
|
||||||
return HTTPBadRequest('pageSize and pageNum accept only digits.')
|
return HTTPBadRequest('pageSize and pageNum accept only digits.')
|
||||||
# Query database
|
# Query database
|
||||||
Users = DBSession.query(User.uid, User.nom, User.prenom) \
|
part = remove_accents(user_query)
|
||||||
.filter(User.slug.contains(remove_accents(UserQuery)))
|
users_set = DBSession.query(User.uid, User.nom, User.prenom) \
|
||||||
page_url = paginate.PageURL_WebOb(request)
|
.filter(User.slug.contains(part.decode("utf-8"))).all()
|
||||||
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)
|
records = paginate.Page(users_set, current_page, url_maker=url_maker, items_per_page=page_size)
|
||||||
return {"Results": ListMatchUser, "Total": records.item_count,
|
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}
|
"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='tiers_json', renderer="json")
|
@view_config(route_name='tiers_json', renderer="json")
|
||||||
def JSON_Tiers_Request(request):
|
def JSON_Tiers_Request(request):
|
||||||
@@ -223,13 +223,13 @@ def JSON_Tiers_Request(request):
|
|||||||
else:
|
else:
|
||||||
return HTTPBadRequest('pageSize and pageNum accept only digits.')
|
return HTTPBadRequest('pageSize and pageNum accept only digits.')
|
||||||
# Query database
|
# Query database
|
||||||
JTiers = DBSession.query(Tiers.uid, Tiers.name) \
|
part = remove_accents(TiersQuery)
|
||||||
.filter(Tiers.slug.contains(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(j_tiers, current_page, url_maker=url_maker, items_per_page=pageSize)
|
||||||
records = paginate.Page(JTiers, current_page, url=page_url, items_per_page=pageSize)
|
list_match_tiers = list(map(lambda t: {"id": t.uid, "text": t.name}, records.items))
|
||||||
ListMatchTiers = map(lambda t: {"id": t.uid, "text": t.name}, records)
|
return {"Results": list_match_tiers, "Total": records.item_count,
|
||||||
return {"Results": ListMatchTiers, "Total": records.item_count,
|
|
||||||
"logged_in": request.authenticated_userid}
|
"logged_in": request.authenticated_userid}
|
||||||
|
|
||||||
|
|
||||||
@@ -237,25 +237,25 @@ def JSON_Tiers_Request(request):
|
|||||||
def JSON_Progamme_Request(request):
|
def JSON_Progamme_Request(request):
|
||||||
year = int(request.matchdict.get('year', CurrentYear))
|
year = int(request.matchdict.get('year', CurrentYear))
|
||||||
# Initialization
|
# Initialization
|
||||||
DicResult = dict()
|
dic_result = dict()
|
||||||
# Query database
|
# Query database
|
||||||
# Compute days used by all events matching the specified input year
|
# 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.for_year == year) \
|
||||||
.filter(Event.event_type != None) \
|
.filter(Event.event_type is not None) \
|
||||||
.group_by(func.strftime('%d', Event.start_time)).all()
|
.group_by(func.strftime('%d', Event.start_time)).all()
|
||||||
|
|
||||||
for Day in Days:
|
for Day in days:
|
||||||
Events = DBSession.query(Event) \
|
events = DBSession.query(Event) \
|
||||||
.filter(Event.for_year == year) \
|
.filter(Event.for_year == year) \
|
||||||
.filter(Event.event_type != 'Stand') \
|
.filter(Event.event_type != 'Stand') \
|
||||||
.filter(text("strftime('%d', start_time) = :dow")).params(dow=Day.day) \
|
.filter(text("strftime('%d', start_time) = :dow")).params(dow=Day.day) \
|
||||||
.order_by(Event.start_time)
|
.order_by(Event.start_time)
|
||||||
|
|
||||||
ListEv = []
|
list_ev = []
|
||||||
for ev in Events:
|
for ev in events:
|
||||||
if ev.event_type:
|
if ev.event_type:
|
||||||
ListEv.append({
|
list_ev.append({
|
||||||
"uid": "%d/%d" % (year, ev.uid),
|
"uid": "%d/%d" % (year, ev.uid),
|
||||||
"desc": ev.name,
|
"desc": ev.name,
|
||||||
"startDate": ev.start_time.strftime('%Y-%m-%dT%H:%M:%S+01:00'),
|
"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"),
|
"placeName": ev.Salle and (ev.Salle.name or "unk"),
|
||||||
"status": ev.event_type
|
"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")
|
@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]),
|
"credit": ",".join(["%s %s" % (i.prenom, i.nom) for i in ev.intervenants]),
|
||||||
"caption": ""}
|
"caption": ""}
|
||||||
})
|
})
|
||||||
if year == 2018:
|
if year == 2020:
|
||||||
DicResult = {
|
DicResult = {
|
||||||
"lang": "fr",
|
"lang": "fr",
|
||||||
"headline": "JM2L 2018",
|
"headline": "JM2L 2020",
|
||||||
"type": "default",
|
"type": "default",
|
||||||
"startDate": "2018,12,15,10",
|
"startDate": "2020,11,28,10",
|
||||||
"text": "<i><span class='c1'>11ème Édition</span></i>",
|
"text": "<i><span class='c1'>11ème Édition</span></i>",
|
||||||
"asset":
|
"asset":
|
||||||
{
|
{
|
||||||
"media": embeed_video("video/ogg", "/resources/2017/Video/JM2L2017_Reportage_FR3.ogv"),
|
"media": embeed_video("video/ogg", "/resources/2017/Video/JM2L2017_Reportage_FR3.ogv"),
|
||||||
"credit": "Reportage France 3",
|
"credit": "Reportage France 3",
|
||||||
"caption": "JM2L 2018"
|
"caption": "Dans nos précédentes éditions, une vidéo des JM2L 2017"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elif year == 2017:
|
elif year == 2017:
|
||||||
@@ -1716,21 +1716,21 @@ def edit_event(request):
|
|||||||
]
|
]
|
||||||
salle_dispo = salle_dispo.filter(Salles.place_type == 'Stand')
|
salle_dispo = salle_dispo.filter(Salles.place_type == 'Stand')
|
||||||
elif intervention == "Atelier":
|
elif intervention == "Atelier":
|
||||||
form.duration.choices = map(lambda d: (d, u'Atelier (%dh%.2d)' % (d / 60, d % 60)),
|
form.duration.choices = list(map(lambda d: (d, u'Atelier (%dh%.2d)' % (d / 60, d % 60)),
|
||||||
[60, 90, 120, 150, 180, 210, 240])
|
[60, 90, 120, 150, 180, 210, 240]))
|
||||||
if not duration in map(lambda d, y: d, form.duration.choices):
|
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)))
|
form.duration.choices.append((duration, u'Atelier (%dh%.2d)' % (duration / 60, duration % 60)))
|
||||||
salle_dispo = salle_dispo.filter(Salles.place_type.in_(['Atelier', 'MAO']))
|
salle_dispo = salle_dispo.filter(Salles.place_type.in_(['Atelier', 'MAO']))
|
||||||
elif intervention == "Table_ronde":
|
elif intervention == "Table_ronde":
|
||||||
form.duration.choices = map(lambda d: (d, u'Table ronde (%dh%.2d)' % (d / 60, d % 60)),
|
form.duration.choices = list(map(lambda d: (d, u'Table ronde (%dh%.2d)' % (d / 60, d % 60)),
|
||||||
[60, 90, 120, 150])
|
[60, 90, 120, 150]))
|
||||||
if not duration in map(lambda d, y: d, form.duration.choices):
|
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)))
|
form.duration.choices.append((duration, u'Table ronde (%dh%.2d)' % (duration / 60, duration % 60)))
|
||||||
salle_dispo = salle_dispo.filter(Salles.place_type == 'Table ronde')
|
salle_dispo = salle_dispo.filter(Salles.place_type == 'Table ronde')
|
||||||
elif intervention == "Concert":
|
elif intervention == "Concert":
|
||||||
form.duration.choices = map(lambda d: (d, u'Concert (%dh%.2d)' % (d / 60, d % 60)),
|
form.duration.choices = list(map(lambda d: (d, u'Concert (%dh%.2d)' % (d / 60, d % 60)),
|
||||||
[60, 90, 120, 150, 180, 210, 240])
|
[60, 90, 120, 150, 180, 210, 240]))
|
||||||
if not duration in map(lambda d, y: d, form.duration.choices):
|
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)))
|
form.duration.choices.append((duration, u'Concert (%dh%.2d)' % (duration / 60, duration % 60)))
|
||||||
salle_dispo = salle_dispo.filter(Salles.place_type.in_(['Stand', 'MAO']))
|
salle_dispo = salle_dispo.filter(Salles.place_type.in_(['Stand', 'MAO']))
|
||||||
else:
|
else:
|
||||||
@@ -2027,8 +2027,8 @@ def edit_tiers_category(request):
|
|||||||
if dic_result[opt.slug_entity_type]['title'] != opt.entity_type or \
|
if dic_result[opt.slug_entity_type]['title'] != opt.entity_type or \
|
||||||
tst[1] != opt.entity_subtype:
|
tst[1] != opt.entity_subtype:
|
||||||
list_changes.append(('changed', opt.uid,
|
list_changes.append(('changed', opt.uid,
|
||||||
dic_result[opt.slug_entity_type]['title'],
|
dic_result[opt.slug_entity_type]['title'],
|
||||||
tst[1]))
|
tst[1]))
|
||||||
else:
|
else:
|
||||||
list_changes.append(('remove', opt.uid, opt.entity_type, opt.entity_subtype))
|
list_changes.append(('remove', opt.uid, opt.entity_type, opt.entity_subtype))
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
APP_CONFIG = "prod.ini"
|
import sys
|
||||||
|
sys.path.append("/srv/.venv_jm2l/lib/python3.7/site-packages")
|
||||||
#Setup logging
|
ini_path = "/srv/jm2l.linux-azur.org/jm2l/production.ini"
|
||||||
import logging.config
|
from pyramid.paster import get_app, setup_logging
|
||||||
logging.config.fileConfig(APP_CONFIG)
|
setup_logging(ini_path)
|
||||||
|
application = get_app(ini_path, 'main')
|
||||||
#Load the application
|
|
||||||
from paste.deploy import loadapp
|
|
||||||
application = loadapp('config:%s' % APP_CONFIG)
|
|
||||||
Reference in New Issue
Block a user