|
@@ -13,6 +13,7 @@ from .forms import * |
|
|
from .models import * |
|
|
from .models import * |
|
|
from .helpers import Orga_helpers |
|
|
from .helpers import Orga_helpers |
|
|
from sqlalchemy import func, or_, text, and_ |
|
|
from sqlalchemy import func, or_, text, and_ |
|
|
|
|
|
from sqlalchemy.orm import aliased |
|
|
from os import path, makedirs, listdir |
|
|
from os import path, makedirs, listdir |
|
|
# Usefull tools |
|
|
# Usefull tools |
|
|
from slugify import slugify |
|
|
from slugify import slugify |
|
@@ -105,13 +106,13 @@ def ICal_Progamme_Dyn_Request(request): |
|
|
|
|
|
|
|
|
event = Evt() |
|
|
event = Evt() |
|
|
event['uid'] = "%d/%d" % ( year, 100 ) |
|
|
event['uid'] = "%d/%d" % ( year, 100 ) |
|
|
event.add('summary', "Les stands JM2L 2015" ) |
|
|
|
|
|
|
|
|
event.add('summary', "Les stands JM2L %s" % year ) |
|
|
event.add('dtstart', datetime.datetime.now().replace(tzinfo=tz, hour=10, minute=00 ) ) |
|
|
event.add('dtstart', datetime.datetime.now().replace(tzinfo=tz, hour=10, minute=00 ) ) |
|
|
event.add('dtend', datetime.datetime.now().replace(tzinfo=tz, hour=18, minute=00 ) ) |
|
|
event.add('dtend', datetime.datetime.now().replace(tzinfo=tz, hour=18, minute=00 ) ) |
|
|
event.add('created', datetime.datetime.now().replace(tzinfo=tz, hour=10, minute=00 ) ) |
|
|
event.add('created', datetime.datetime.now().replace(tzinfo=tz, hour=10, minute=00 ) ) |
|
|
event.add('description', "https://www.youtube.com/watch?v=91X65eEKxvU&t=6s" ) |
|
|
event.add('description', "https://www.youtube.com/watch?v=91X65eEKxvU&t=6s" ) |
|
|
event.add('location', "http://jm2l.linux-azur.org/img/325.gif" ) |
|
|
event.add('location', "http://jm2l.linux-azur.org/img/325.gif" ) |
|
|
event.add('url', "http://jm2l.linux-azur.org/2015/le-programme" ) |
|
|
|
|
|
|
|
|
event.add('url', "http://jm2l.linux-azur.org/%s/le-programme" % CurrentYear) |
|
|
event.add('priority', 5) |
|
|
event.add('priority', 5) |
|
|
cal.add_component(event) |
|
|
cal.add_component(event) |
|
|
|
|
|
|
|
@@ -814,7 +815,7 @@ def miam(request): |
|
|
|
|
|
|
|
|
miam_form = MiamForm(request.POST, request.user, meta={'csrf_context': request.session}) |
|
|
miam_form = MiamForm(request.POST, request.user, meta={'csrf_context': request.session}) |
|
|
if request.method == 'POST' and miam_form.validate(): |
|
|
if request.method == 'POST' and miam_form.validate(): |
|
|
FicheSejour = Sejour.by_user(request.user.uid) |
|
|
|
|
|
|
|
|
FicheSejour = Sejour.by_user(request.user.uid, CurrentYear) |
|
|
if FicheSejour: |
|
|
if FicheSejour: |
|
|
Update=True |
|
|
Update=True |
|
|
else: |
|
|
else: |
|
@@ -846,7 +847,7 @@ def sejour(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.') |
|
|
if request.method == 'POST': |
|
|
if request.method == 'POST': |
|
|
FicheSejour = Sejour.by_user(request.user.uid) |
|
|
|
|
|
|
|
|
FicheSejour = Sejour.by_user(request.user.uid, CurrentYear) |
|
|
if FicheSejour: |
|
|
if FicheSejour: |
|
|
Update=True |
|
|
Update=True |
|
|
else: |
|
|
else: |
|
@@ -895,7 +896,7 @@ def orga(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.') |
|
|
if request.method == 'POST': |
|
|
if request.method == 'POST': |
|
|
FicheSejour = Sejour.by_user(request.user.uid) |
|
|
|
|
|
|
|
|
FicheSejour = Sejour.by_user(request.user.uid, CurrentYear) |
|
|
UpdateOrga=False |
|
|
UpdateOrga=False |
|
|
if FicheSejour: |
|
|
if FicheSejour: |
|
|
Update=True |
|
|
Update=True |
|
@@ -951,13 +952,23 @@ def vote_logo(request): |
|
|
|
|
|
|
|
|
@view_config(route_name='list_users', renderer="jm2l:templates/Participant/list_users.mako") |
|
|
@view_config(route_name='list_users', renderer="jm2l:templates/Participant/list_users.mako") |
|
|
def list_users(request): |
|
|
def list_users(request): |
|
|
|
|
|
for_year = int(request.matchdict.get('year', CurrentYear)) |
|
|
if request.user is None: |
|
|
if request.user is None: |
|
|
# 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.') |
|
|
if not request.user.Staff: |
|
|
if not request.user.Staff: |
|
|
raise HTTPForbidden(u'Vous n\'avez pas l\'autorité suffisante pour effectuer cette action.') |
|
|
raise HTTPForbidden(u'Vous n\'avez pas l\'autorité suffisante pour effectuer cette action.') |
|
|
Data = DBSession.query(User, Sejour).outerjoin(Sejour).all() |
|
|
|
|
|
Repas = DBSession.query(Sejour.repas).all() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stmt = (DBSession.query(Sejour).filter(Sejour.for_year==for_year)).subquery() |
|
|
|
|
|
adalias = aliased(Sejour, stmt) |
|
|
|
|
|
Data = DBSession.query(User, adalias ) \ |
|
|
|
|
|
.outerjoin(adalias)\ |
|
|
|
|
|
.all() |
|
|
|
|
|
|
|
|
|
|
|
Repas = DBSession.query(Sejour.repas) \ |
|
|
|
|
|
.filter(Sejour.for_year == for_year ) \ |
|
|
|
|
|
.all() |
|
|
|
|
|
|
|
|
DicRepas = {"Ven":0, "Midi":0, "Soir":0} |
|
|
DicRepas = {"Ven":0, "Midi":0, "Soir":0} |
|
|
for r in Repas: |
|
|
for r in Repas: |
|
|
if r[0] is None: |
|
|
if r[0] is None: |
|
@@ -965,16 +976,20 @@ def list_users(request): |
|
|
if (r[0] & 1 == 1): DicRepas["Ven"]+=1 |
|
|
if (r[0] & 1 == 1): DicRepas["Ven"]+=1 |
|
|
if (r[0] & 2 == 2): DicRepas["Midi"]+=1 |
|
|
if (r[0] & 2 == 2): DicRepas["Midi"]+=1 |
|
|
if (r[0] & 4 == 4): DicRepas["Soir"]+=1 |
|
|
if (r[0] & 4 == 4): DicRepas["Soir"]+=1 |
|
|
return { 'Users':Data, 'UserEvent' : User_Event, "DicRepas":DicRepas } |
|
|
|
|
|
|
|
|
return { 'Users':Data, 'UserEvent' : User_Event, "DicRepas":DicRepas, "for_year": for_year } |
|
|
|
|
|
|
|
|
@view_config(route_name='list_orga', renderer="jm2l:templates/Participant/list_orga.mako") |
|
|
@view_config(route_name='list_orga', renderer="jm2l:templates/Participant/list_orga.mako") |
|
|
def list_orga(request): |
|
|
def list_orga(request): |
|
|
|
|
|
for_year = int(request.matchdict.get('year', CurrentYear)) |
|
|
if request.user is None: |
|
|
if request.user is None: |
|
|
# 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.') |
|
|
if not request.user.Staff: |
|
|
if not request.user.Staff: |
|
|
raise HTTPForbidden(u'Vous n\'avez pas l\'autorité suffisante pour effectuer cette action.') |
|
|
raise HTTPForbidden(u'Vous n\'avez pas l\'autorité suffisante pour effectuer cette action.') |
|
|
Data = DBSession.query(User, Sejour).outerjoin(Sejour).all() |
|
|
|
|
|
|
|
|
Data = DBSession.query(User, Sejour)\ |
|
|
|
|
|
.outerjoin(Sejour)\ |
|
|
|
|
|
.filter(Sejour.for_year == for_year)\ |
|
|
|
|
|
.all() |
|
|
return { 'Users':Data } |
|
|
return { 'Users':Data } |
|
|
|
|
|
|
|
|
@view_config(route_name='jm2l', renderer="jm2l:templates/jm2l.mako") |
|
|
@view_config(route_name='jm2l', renderer="jm2l:templates/jm2l.mako") |
|
@@ -1002,7 +1017,7 @@ def jm2l_page(request): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Feed FicheSejour if any |
|
|
# Feed FicheSejour if any |
|
|
FicheSejour = Sejour.by_user(profil.uid) |
|
|
|
|
|
|
|
|
FicheSejour = Sejour.by_user(profil.uid, CurrentYear) |
|
|
if FicheSejour: |
|
|
if FicheSejour: |
|
|
if FicheSejour.repas is not None: |
|
|
if FicheSejour.repas is not None: |
|
|
for num, item in enumerate(['RepasVendredi', 'RepasSamediMidi', 'RepasSamediSoir']): |
|
|
for num, item in enumerate(['RepasVendredi', 'RepasSamediMidi', 'RepasSamediSoir']): |
|
|