diff --git a/jm2l/__init__.py b/jm2l/__init__.py index 0b26a78..8931d02 100644 --- a/jm2l/__init__.py +++ b/jm2l/__init__.py @@ -126,8 +126,8 @@ def main(global_config, **settings): config.add_route('action_salle', '/Salles/{action:(\w+)}/{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 config.add_route('home', '/{year:(\d+/)?}') diff --git a/jm2l/badge.py b/jm2l/badge.py index c4e723d..1b19e90 100644 --- a/jm2l/badge.py +++ b/jm2l/badge.py @@ -11,6 +11,7 @@ from reportlab.lib.units import mm import qrcode import subprocess from .upload import MediaPath +from jm2l.const import CurrentYear # Create PDF container EXPIRATION_TIME = 300 # seconds WIDTH = 85 * mm @@ -32,7 +33,7 @@ def JM2L_Logo(canvas, Offset=(0,0)): yearobject.setTextRenderMode(0) yearobject.setTextOrigin(OffX+12 , OffY+35) yearobject.setWordSpace(13) - yearobject.textLines("2 0 1 5") + yearobject.textLines(" ".join(str(CurrentYear))) canvas.drawText(yearobject) def Tiers_Logo(canvas, DispUser, StartPos=None, Offset=(0,0)): diff --git a/jm2l/models.py b/jm2l/models.py index e5c83b0..930a4f5 100644 --- a/jm2l/models.py +++ b/jm2l/models.py @@ -184,7 +184,13 @@ class User(Base): return None @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 """ return DBSession.query(Event).join(User_Event) \ .filter(User_Event.user_uid==self.uid) \ @@ -193,7 +199,14 @@ class User(Base): @property def is_crew(self, year=CurrentYear): """ 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): @@ -591,8 +604,11 @@ class Sejour(Base): last_change = Column(DateTime, default=datetime.datetime.now) @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): __tablename__ = 'events' diff --git a/jm2l/templates/Participant/list_users.mako b/jm2l/templates/Participant/list_users.mako index 590d4c3..2922cdf 100644 --- a/jm2l/templates/Participant/list_users.mako +++ b/jm2l/templates/Participant/list_users.mako @@ -23,8 +23,12 @@ now = datetime.datetime.now()
- % for u, s in Users: -