@@ -126,8 +126,8 @@ def main(global_config, **settings): | |||||
config.add_route('action_salle', '/Salles/{action:(\w+)}/{salle_id:(\d+)}') | config.add_route('action_salle', '/Salles/{action:(\w+)}/{salle_id:(\d+)}') | ||||
config.add_route('pict_salle', '/salle_picture/{salle_id:(\d+)}') | config.add_route('pict_salle', '/salle_picture/{salle_id:(\d+)}') | ||||
config.add_route('list_users', '/ListParticipant') | |||||
config.add_route('list_orga', '/ListOrga') | |||||
config.add_route('list_users', '/{year:\d+}/ListParticipant') | |||||
config.add_route('list_orga', '/{year:\d+}/ListOrga') | |||||
# HTML Routes - Public | # HTML Routes - Public | ||||
config.add_route('home', '/{year:(\d+/)?}') | config.add_route('home', '/{year:(\d+/)?}') | ||||
@@ -11,6 +11,7 @@ from reportlab.lib.units import mm | |||||
import qrcode | import qrcode | ||||
import subprocess | import subprocess | ||||
from .upload import MediaPath | from .upload import MediaPath | ||||
from jm2l.const import CurrentYear | |||||
# Create PDF container | # Create PDF container | ||||
EXPIRATION_TIME = 300 # seconds | EXPIRATION_TIME = 300 # seconds | ||||
WIDTH = 85 * mm | WIDTH = 85 * mm | ||||
@@ -32,7 +33,7 @@ def JM2L_Logo(canvas, Offset=(0,0)): | |||||
yearobject.setTextRenderMode(0) | yearobject.setTextRenderMode(0) | ||||
yearobject.setTextOrigin(OffX+12 , OffY+35) | yearobject.setTextOrigin(OffX+12 , OffY+35) | ||||
yearobject.setWordSpace(13) | yearobject.setWordSpace(13) | ||||
yearobject.textLines("2 0 1 5") | |||||
yearobject.textLines(" ".join(str(CurrentYear))) | |||||
canvas.drawText(yearobject) | canvas.drawText(yearobject) | ||||
def Tiers_Logo(canvas, DispUser, StartPos=None, Offset=(0,0)): | def Tiers_Logo(canvas, DispUser, StartPos=None, Offset=(0,0)): | ||||
@@ -184,7 +184,13 @@ class User(Base): | |||||
return None | return None | ||||
@property | @property | ||||
def is_Intervenant(self, year=CurrentYear): | |||||
def is_Intervenant(self): | |||||
""" This property will return if User do an event on specified year """ | |||||
return DBSession.query(Event).join(User_Event) \ | |||||
.filter(User_Event.user_uid==self.uid) \ | |||||
.filter(Event.for_year==CurrentYear).count() | |||||
def is_IntervenantOnYear(self, year=CurrentYear): | |||||
""" This property will return if User do an event on specified year """ | """ This property will return if User do an event on specified year """ | ||||
return DBSession.query(Event).join(User_Event) \ | return DBSession.query(Event).join(User_Event) \ | ||||
.filter(User_Event.user_uid==self.uid) \ | .filter(User_Event.user_uid==self.uid) \ | ||||
@@ -193,7 +199,14 @@ class User(Base): | |||||
@property | @property | ||||
def is_crew(self, year=CurrentYear): | def is_crew(self, year=CurrentYear): | ||||
""" This property will return if User subscribe orga task on specified year """ | """ This property will return if User subscribe orga task on specified year """ | ||||
return DBSession.query(User,Sejour.orga_part).outerjoin(Sejour).filter(User.uid == self.uid).one()[1] | |||||
orga_checked = DBSession.query(User, Sejour.orga_part)\ | |||||
.outerjoin(Sejour) \ | |||||
.filter(Sejour.for_year == year)\ | |||||
.filter(User.uid == self.uid).first() | |||||
if orga_checked: | |||||
return orga_checked | |||||
else: | |||||
return False | |||||
def year_events(self, EventType='All', year=CurrentYear): | def year_events(self, EventType='All', year=CurrentYear): | ||||
@@ -591,8 +604,11 @@ class Sejour(Base): | |||||
last_change = Column(DateTime, default=datetime.datetime.now) | last_change = Column(DateTime, default=datetime.datetime.now) | ||||
@classmethod | @classmethod | ||||
def by_user(cls, uid): | |||||
return DBSession.query(cls).filter(cls.user_id == uid).first() | |||||
def by_user(cls, uid, year): | |||||
return DBSession.query(cls)\ | |||||
.filter(cls.user_id == uid)\ | |||||
.filter(cls.for_year == year)\ | |||||
.first() | |||||
class Event(Base): | class Event(Base): | ||||
__tablename__ = 'events' | __tablename__ = 'events' | ||||
@@ -23,8 +23,12 @@ now = datetime.datetime.now() | |||||
</tr> | </tr> | ||||
</thead> | </thead> | ||||
<tbody id="list"> | <tbody id="list"> | ||||
% for u, s in Users: | |||||
<tr> | |||||
% for u, s in Users: | |||||
% if u.is_IntervenantOnYear(for_year): | |||||
<tr> | |||||
% else: | |||||
<tr style="color:lightgray"> | |||||
% endif | |||||
<td style="text-align:center;"> | <td style="text-align:center;"> | ||||
<span class="data">${u.slug}</span> | <span class="data">${u.slug}</span> | ||||
<a href="/MesJM2L?user=${u.uid}">${u.nom} ${u.prenom}</a><br /> | <a href="/MesJM2L?user=${u.uid}">${u.nom} ${u.prenom}</a><br /> | ||||
@@ -38,7 +42,7 @@ now = datetime.datetime.now() | |||||
<i class="icon-star"></i> | <i class="icon-star"></i> | ||||
</a> | </a> | ||||
% endif | % endif | ||||
% if u.Staff==0: | |||||
% if u.is_IntervenantOnYear(for_year): | |||||
<a href="javascript:alert('${u.nom}, ${u.prenom}\nIntervenant');"> | <a href="javascript:alert('${u.nom}, ${u.prenom}\nIntervenant');"> | ||||
<i class="icon-user"></i> | <i class="icon-user"></i> | ||||
</a> | </a> | ||||
@@ -4,15 +4,21 @@ | |||||
##<form id="ProfilForm" action="javascript:DoPost('/2015/modal/Place/${form.place_id.data}');"> | ##<form id="ProfilForm" action="javascript:DoPost('/2015/modal/Place/${form.place_id.data}');"> | ||||
% if uprofil!=request.user and request.user.uid==1: | % if uprofil!=request.user and request.user.uid==1: | ||||
<form id="ProfilForm" action="/MesJM2L?user=${uprofil.uid}" method="POST"> | |||||
<form id="ProfilForm" action="#" method="POST"> | |||||
% else: | % else: | ||||
<form id="ProfilForm" action="/MesJM2L" method="POST"> | <form id="ProfilForm" action="/MesJM2L" method="POST"> | ||||
% endif | % endif | ||||
<div class="row-fluid"> | <div class="row-fluid"> | ||||
<div class="span8"> | <div class="span8"> | ||||
% if uprofil!=request.user and request.user.Staff==1: | |||||
<a href="/sign/jm2l/${uprofil.my_hash}">Se connecter "en tant que" ${uprofil.nom} ${uprofil.prenom}</a> - | |||||
<a href="/user/${uprofil.slug}">Son profil public</a><br> | |||||
% else: | |||||
<a href="/sign/jm2l/${uprofil.my_hash}">Mon lien de connection</a> - | <a href="/sign/jm2l/${uprofil.my_hash}">Mon lien de connection</a> - | ||||
<a href="/user/${request.user.slug}">Mon profil public</a><br> | <a href="/user/${request.user.slug}">Mon profil public</a><br> | ||||
% endif | |||||
<h3>${profil_form.prenom.data} ${profil_form.nom.data}</h3> | <h3>${profil_form.prenom.data} ${profil_form.nom.data}</h3> | ||||
<% | <% | ||||
DicFormA = { | DicFormA = { | ||||
@@ -69,10 +75,14 @@ DicForm2 = { | |||||
<dl> | <dl> | ||||
<dt>SSID</dt> | <dt>SSID</dt> | ||||
<dd>Unice-HotSpot</dd> | <dd>Unice-HotSpot</dd> | ||||
<dt>Votre utilisateur:</dt> | |||||
<!-- | |||||
<dt>Votre utilisateur:</dt> | |||||
<dd>${uprofil.wifi_user}</dd> | <dd>${uprofil.wifi_user}</dd> | ||||
<dt>Le mot de passe:</dt> | <dt>Le mot de passe:</dt> | ||||
<dd>${uprofil.wifi_pass}</dd> | <dd>${uprofil.wifi_pass}</dd> | ||||
--> | |||||
<dt>Vos identifiants:</dt> | |||||
<dd>Nous n'avons pas encore l'information</dd> | |||||
</dl> | </dl> | ||||
<a href="https://wifi.unice.fr/">Plus de détails ...</a> | <a href="https://wifi.unice.fr/">Plus de détails ...</a> | ||||
</div> | </div> | ||||
@@ -158,7 +168,9 @@ ${helpers.DisplayRespForm(profil_form, DicFormB)} | |||||
<tfoot> | <tfoot> | ||||
<tr> | <tr> | ||||
<td colspan="5" style="text-align:center;line-height: 3em;"> | <td colspan="5" style="text-align:center;line-height: 3em;"> | ||||
<span class="add btn btn-mini btn-primary"><i class="icon-plus-sign icon-white"></i> Je fais partie de ...</span> | |||||
% if uprofil==request.user: | |||||
<span class="add btn btn-mini btn-primary"><i class="icon-plus-sign icon-white"></i> Je fais partie de ...</span> | |||||
% endif | |||||
</td> | </td> | ||||
</tr> | </tr> | ||||
</tfoot> | </tfoot> | ||||
@@ -167,7 +179,14 @@ ${helpers.DisplayRespForm(profil_form, DicFormB)} | |||||
</fieldset> | </fieldset> | ||||
<div class="span2 offset5"> | <div class="span2 offset5"> | ||||
% if uprofil!=request.user and request.user.Staff==1: | |||||
En tant que Staff des JM2L, <br /> | |||||
Je me connecte "en tant que" <br /> | |||||
<a href="/sign/jm2l/${uprofil.my_hash}"> ${uprofil.nom} ${uprofil.prenom}</a><br /> | |||||
pour modifier sa fiche ... | |||||
% else: | |||||
<input class="btn btn-primary" type="submit" value="Enregistrer !" /> | <input class="btn btn-primary" type="submit" value="Enregistrer !" /> | ||||
% endif | |||||
</div> | </div> | ||||
</form> | </form> | ||||
@@ -126,7 +126,7 @@ ${helpers.uploader_js()} | |||||
% if request.user: | % if request.user: | ||||
% if request.user.Staff: | % if request.user.Staff: | ||||
<li><a href="/${DisplayYear}/Staff">Partie Staff</a></li> | <li><a href="/${DisplayYear}/Staff">Partie Staff</a></li> | ||||
<li><a href="/ListParticipant">Gérer les intervenants</a></li> | |||||
<li><a href="/${DisplayYear}/ListParticipant">Gérer les intervenants</a></li> | |||||
<li><a href="/ListSalles">Gérer les salles</a></li> | <li><a href="/ListSalles">Gérer les salles</a></li> | ||||
<li><a href="/entities">Gérer les entités</a></li> | <li><a href="/entities">Gérer les entités</a></li> | ||||
<li><a href="/${DisplayYear}/ListOrga">Participations à l'orga</a></li> | <li><a href="/${DisplayYear}/ListOrga">Participations à l'orga</a></li> | ||||
@@ -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']): | ||||