Browse Source

Fix Display of program, Fix table ronde

tr4ck3ur 2 years ago
parent
commit
e958bf04cb
6 changed files with 183 additions and 310 deletions
  1. 1 2
      jm2l/__init__.py
  2. 111 293
      jm2l/badge.py
  3. 7 1
      jm2l/models.py
  4. 45 7
      jm2l/static/js/programme.js
  5. 11 3
      jm2l/templates/Public/Programme.mako
  6. 8 4
      jm2l/views.py

+ 1 - 2
jm2l/__init__.py

@@ -153,8 +153,7 @@ def main(global_config, **settings):
153 153
     config.add_route('pict_user', '/user_picture')
154 154
     config.add_route('show_user', '/user/{user_slug:([\w-]+)?}')
155 155
     config.add_route('badge_user', '/user/{user_slug:([\w-]+)?}/badge')
156
-    config.add_route('badge_user1', '/user/{user_slug:([\w-]+)?}/badge1')
157
-    config.add_route('badge_user2', '/user/{user_slug:([\w-]+)?}/badge2')
156
+    config.add_route('all_badges', '/badges')
158 157
     
159 158
     # HTML Routes - Logged
160 159
     #config.add_route('profil', 'MesJM2L')    

+ 111 - 293
jm2l/badge.py

@@ -1,9 +1,9 @@
1 1
 # -*- coding: utf8 -*-
2
-from pyramid.httpexceptions import HTTPNotFound
2
+from pyramid.httpexceptions import HTTPNotFound, HTTPForbidden
3 3
 from pyramid.response import Response
4 4
 import cStringIO as StringIO
5 5
 from pyramid.view import view_config
6
-from .models import User
6
+from .models import DBSession, User
7 7
 from reportlab.pdfgen import canvas
8 8
 from reportlab.pdfbase import pdfmetrics
9 9
 from reportlab.pdfbase.ttfonts import TTFont
@@ -11,12 +11,11 @@ from reportlab.lib.units import mm
11 11
 import qrcode
12 12
 import subprocess
13 13
 from .upload import MediaPath
14
-
15 14
 # Create PDF container
16 15
 EXPIRATION_TIME = 300 # seconds
17 16
 WIDTH = 85 * mm
18 17
 HEIGHT = 60 * mm
19
-ICONSIZE = 9 * mm  
18
+ICONSIZE = 10 * mm
20 19
 
21 20
 def Ribbon35(DispUser, canvas):
22 21
     canvas.saveState()
@@ -102,48 +101,27 @@ def Ribbon90(DispUser, canvas):
102 101
     canvas.restoreState()        
103 102
     return canvas
104 103
 
105
-def JM2L_Logo(canvas, Position="Up"):
106
-    # Import font
107
-    ttfFile_Logo = "jm2l/static/fonts/PWTinselLetters.ttf"
108
-    pdfmetrics.registerFont(TTFont("Logo", ttfFile_Logo))
104
+def JM2L_Logo(canvas, Offset=(0,0)):
105
+    OffX, OffY = Offset
106
+    logoobject = canvas.beginText()
107
+    logoobject.setFont('Logo', 32)
108
+    logoobject.setFillColorRGB(.83,0,.33)
109
+    logoobject.setTextOrigin(OffX+5, OffY+17)
110
+    logoobject.textLines("JM2L")
111
+    canvas.drawText(logoobject)
109 112
     
110
-    if Position=="Up":
111
-        logoobject = canvas.beginText()
112
-        logoobject.setFont('Logo', 52)
113
-        logoobject.setFillColorRGB(.83,0,.33)
114
-        logoobject.setTextOrigin(55, HEIGHT-50)
115
-        logoobject.textLines("JM2L")
116
-        canvas.drawText(logoobject)
117
-        
118
-        yearobject = canvas.beginText()
119
-        yearobject.setFont("Helvetica-Bold", 15)
120
-        yearobject.setFillColorRGB(1,1,1)
121
-        yearobject.setTextOrigin(67, HEIGHT-20)
122
-        yearobject.setWordSpace(21)
123
-        yearobject.textLines("2 0 1 5")
124
-        canvas.drawText(yearobject)
125
-    elif Position=="Down":
126
-        logoobject = canvas.beginText()
127
-        logoobject.setFont('Logo', 32)
128
-        logoobject.setFillColorRGB(.83,0,.33)
129
-        logoobject.setTextOrigin(2, 17)
130
-        logoobject.textLines("JM2L")
131
-        canvas.drawText(logoobject)
132
-        
133
-        yearobject = canvas.beginText()
134
-        yearobject.setFont("Helvetica-Bold", 10)
135
-        yearobject.setFillColorRGB(1,1,1)
136
-        #yearobject.setLineWidth(.1)
137
-        #yearobject.setStrokeColorRGB(.5,.5,.5)
138
-        yearobject.setTextRenderMode(0)
139
-        #yearobject.setStrokeOverprint(.2)
140
-        yearobject.setTextOrigin(9 , 35)
141
-        yearobject.setWordSpace(13)
142
-        yearobject.textLines("2 0 1 5")
143
-        canvas.drawText(yearobject)
113
+    yearobject = canvas.beginText()
114
+    yearobject.setFont("Helvetica-Bold", 10)
115
+    yearobject.setFillColorRGB(1,1,1)
116
+    yearobject.setTextRenderMode(0)
117
+    yearobject.setTextOrigin(OffX+12 , OffY+35)
118
+    yearobject.setWordSpace(13)
119
+    yearobject.textLines("2 0 1 5")
120
+    canvas.drawText(yearobject)
144 121
 
145
-def Tiers_Logo(canvas, DispUser, StartPos=None):
122
+def Tiers_Logo(canvas, DispUser, StartPos=None, Offset=(0,0)):
146 123
     Border = 0
124
+    OffX, OffY = Offset
147 125
     if StartPos is None:
148 126
         StartPos = ( 30 * mm, 2 )
149 127
     StartX, StartY = StartPos
@@ -173,11 +151,15 @@ def Tiers_Logo(canvas, DispUser, StartPos=None):
173 151
     for tiers in Logos:
174 152
         FileName = tiers.ThumbLinks.pop().split("/")[-1]
175 153
         ImagePath = "jm2l/upload/images/tiers/%s/%s" % (tiers.slug, FileName)        
176
-        PosX = StartX + DicPos[len(Logos)][num][0] * MaxX - (ICONSIZE+Border)/2
177
-        PosY = StartY + DicPos[len(Logos)][num][1] * MaxY - (ICONSIZE+Border)/2
154
+        PosX = OffX+StartX + DicPos[len(Logos)][num][0] * MaxX - (ICONSIZE+Border)/2
155
+        PosY = OffY+StartY + DicPos[len(Logos)][num][1] * MaxY - (ICONSIZE+Border)/2
178 156
         canvas.setLineWidth(.1)
157
+        if len(Logos)>1:
158
+            size = ICONSIZE
159
+        else:
160
+            size = ICONSIZE*1.5
179 161
         canvas.drawImage(ImagePath, 
180
-            PosX, PosY, ICONSIZE, ICONSIZE,\
162
+            PosX, PosY, size, size,\
181 163
             preserveAspectRatio=True, 
182 164
             anchor='c',
183 165
             mask='auto'
@@ -199,59 +181,40 @@ def QRCode(DispUser):
199 181
 
200 182
     return qr.make_image()
201 183
 
202
-
203
-@view_config(route_name='badge_user', http_cache = (EXPIRATION_TIME, {'public':True}))
204
-def badge_user(request):
205
-    isoutpng = request.params.get('png')    
206
-    user_slug = request.matchdict.get('user_slug', None)
207
-    if user_slug is None or len(user_slug)==0:
208
-        raise HTTPNotFound(u"Cet utilisateur n'a pas été reconnu")
209
-    # Query database
210
-    DispUser = User.by_slug(user_slug)
211
-    if DispUser is None:
212
-        raise HTTPNotFound()
213
-
214
-    # Ok let's generate a PDF Badge
215
-    
216
-    # Register LiberationMono font
217
-    ttfFile = "jm2l/static/fonts/LiberationMono-Regular.ttf"
218
-    pdfmetrics.registerFont(TTFont("Liberation", ttfFile))
219
-
220
-    pdf = StringIO.StringIO()
221
-    out_img = StringIO.StringIO()
222
-  
223
-    c = canvas.Canvas( pdf, pagesize=(WIDTH, HEIGHT) )
224
-    c.translate(mm, mm)
225
-    
226
-    # Feed some metadata
227
-    c.setCreator("linux-azur.org")
228
-    c.setTitle("Badge")
229
-
230
-    c.saveState()
184
+def one_badge(c, DispUser, Offset=(0,0)):
231 185
     # Logo on Top
232
-    JM2L_Logo(c, "Down")
233
-            
186
+    JM2L_Logo(c, Offset)
187
+    OffX, OffY = Offset
188
+    
189
+    c.rect(OffX-3, OffY-3, WIDTH+6, HEIGHT+6, fill=0, stroke=1)
234 190
     if DispUser.Staff:
235 191
         # Staff
236 192
         c.setFillColorRGB(.83,0,.33)
237
-        c.rect(-3, HEIGHT-30, WIDTH, HEIGHT, fill=1, stroke=0)
193
+        c.rect(OffX-3, OffY+HEIGHT-30, WIDTH+6, 33, fill=1, stroke=0)
238 194
         c.setFillColorRGB(1,1,1)
239 195
         c.setFont('Liberation', 30)
240
-        c.drawCentredString(WIDTH/2, HEIGHT-26, "STAFF")
196
+        c.drawCentredString(OffX+WIDTH/2, OffY+HEIGHT-24, "STAFF")
241 197
     elif DispUser.is_Intervenant:
242 198
         # Intervenant
243 199
         c.setFillColorRGB(.21,.67,.78)
244
-        c.rect(-3, HEIGHT-30, WIDTH, HEIGHT, fill=1, stroke=0)
200
+        c.rect(OffX-3, OffY+HEIGHT-30, WIDTH+6, 33, fill=1, stroke=0)
245 201
         c.setFillColorRGB(1,1,1)
246 202
         c.setFont('Liberation', 30)
247
-        c.drawCentredString(WIDTH/2, HEIGHT-26, "Intervenant")
203
+        c.drawCentredString(OffX+WIDTH/2, OffY+HEIGHT-24, "Intervenant")
204
+    elif DispUser.is_crew:
205
+        # Benevole
206
+        c.setFillColorRGB(.18,.76,.23)
207
+        c.rect(OffX-3, OffY+HEIGHT-30, WIDTH+6, 33, fill=1, stroke=0)
208
+        c.setFillColorRGB(1,1,1)
209
+        c.setFont('Liberation', 30)
210
+        c.drawCentredString(OffX+WIDTH/2, OffY+HEIGHT-24, "Bénévole")
248 211
     else:
249 212
         # Visiteur
250 213
         c.setFillColorRGB(.8,.8,.8)
251
-        c.rect(-3, HEIGHT-30, WIDTH, HEIGHT, fill=1, stroke=0)
214
+        c.rect(OffX-3, OffY+HEIGHT-30, WIDTH+6, 33, fill=1, stroke=0)
252 215
         c.setFillColorRGB(1,1,1)
253 216
         c.setFont('Liberation', 30)
254
-        c.drawCentredString(WIDTH/2, HEIGHT-26, "Visiteur")
217
+        c.drawCentredString(OffX+WIDTH/2, OffY+HEIGHT-24, "Visiteur")
255 218
 
256 219
     c.restoreState()
257 220
     
@@ -259,54 +222,35 @@ def badge_user(request):
259 222
     c.setStrokeColorRGB(0,0,0)
260 223
     c.setFillColorRGB(0,0,0)
261 224
     # Feed Name and SurName
262
-    if len(DispUser.prenom) + len(DispUser.nom)>18:
225
+    if DispUser.prenom and DispUser.nom and len(DispUser.prenom) + len(DispUser.nom)>18:
263 226
         if DispUser.pseudo:
264
-            c.drawCentredString(WIDTH/2, HEIGHT/2 + 0 * mm , "%s" % DispUser.prenom )
265
-            c.setFont('Courier', 17)
266
-            c.drawCentredString(WIDTH/2, HEIGHT/2 - 8 * mm , "%s" % DispUser.nom )
227
+            c.drawCentredString(OffX+WIDTH/2, OffY+HEIGHT/2 + 0 * mm , "%s" % DispUser.prenom )
228
+            #c.setFont('Courier', 17)
229
+            c.drawCentredString(OffX+WIDTH/2, OffY+HEIGHT/2 - 8 * mm , "%s" % DispUser.nom )
267 230
         else:
268
-            c.drawCentredString(WIDTH/2, HEIGHT/2 + 4 * mm , "%s" % DispUser.prenom )
269
-            c.setFont('Courier', 17)
270
-            c.drawCentredString(WIDTH/2, HEIGHT/2 - 8 * mm , "%s" % DispUser.nom )            
231
+            c.drawCentredString(OffX+WIDTH/2, OffY+HEIGHT/2 + 4 * mm , "%s" % DispUser.prenom )
232
+            #c.setFont('Courier', 17)
233
+            c.drawCentredString(OffX+WIDTH/2, OffY+HEIGHT/2 - 8 * mm , "%s" % DispUser.nom )            
271 234
     else:
272
-        c.drawCentredString(WIDTH/2, HEIGHT/2 + 0 * mm , "%s %s" % (DispUser.prenom, DispUser.nom) )
235
+        c.drawCentredString(OffX+WIDTH/2, OffY+HEIGHT/2 + 0 * mm , "%s %s" % (DispUser.prenom, DispUser.nom) )
273 236
 
274 237
     if DispUser.pseudo:
275 238
         c.setFont("Helvetica-Oblique", 18)
276
-        c.drawCentredString(WIDTH/2, HEIGHT/2 + 10 * mm , "%s" % DispUser.pseudo )
239
+        c.drawCentredString(OffX+WIDTH/2, OffY+HEIGHT/2 + 10 * mm , "%s" % DispUser.pseudo )
277 240
     
278 241
     # Put QR code to user profile 
279 242
     c.drawInlineImage(QRCode(DispUser), \
280
-            WIDTH - 20 * mm - 7, 0, \
243
+            OffX+WIDTH - 20 * mm -5, OffY+5, \
281 244
             20 * mm, 20 * mm, \
282 245
             preserveAspectRatio=True, \
283 246
             anchor='s')
284 247
     
285
-    Tiers_Logo(c, DispUser)   
286
-    
287
-    c.showPage()
288
-    c.save()
289
-    pdf.seek(0)
290
-    if isoutpng:
291
-        OutPDF = MediaPath().get_mediapath("badge", DispUser.uid, 'badge.pdf')
292
-        OutPNG = MediaPath().get_mediapath("badge", DispUser.uid, 'badge.png')
293
-        # Let's generate a png file for website
294
-        with open( OutPDF ,'wb') as pdff:
295
-            pdff.write(pdf.read())
248
+    Tiers_Logo(c, DispUser, None, Offset)   
296 249
     
297
-        Command = ["convert","-density","150x150", OutPDF, OutPNG]
298
-        subprocess.call(Command)
299
-        
300
-        with open( OutPNG, 'rb') as pngfile:
301
-            out_img.write(pngfile.read())
302
-        
303
-        out_img.seek(0)
304
-        return Response(app_iter=out_img, content_type = 'image/png' )
305
-    else:
306
-        return Response(app_iter=pdf, content_type = 'application/pdf' )
307 250
 
308
-@view_config(route_name='badge_user1')
309
-def badge_user1(request):
251
+@view_config(route_name='badge_user', http_cache = (EXPIRATION_TIME, {'public':True}))
252
+def badge_user(request):
253
+    isoutpng = request.params.get('png')
310 254
     user_slug = request.matchdict.get('user_slug', None)
311 255
     if user_slug is None or len(user_slug)==0:
312 256
         raise HTTPNotFound(u"Cet utilisateur n'a pas été reconnu")
@@ -316,11 +260,16 @@ def badge_user1(request):
316 260
         raise HTTPNotFound()
317 261
 
318 262
     # Ok let's generate a PDF Badge
263
+    
264
+    # Register LiberationMono font
319 265
     ttfFile = "jm2l/static/fonts/LiberationMono-Regular.ttf"
320
-    ttfFile_Logo = "jm2l/static/fonts/PWTinselLetters.ttf"
321 266
     pdfmetrics.registerFont(TTFont("Liberation", ttfFile))
267
+    # Import font
268
+    ttfFile_Logo = "jm2l/static/fonts/PWTinselLetters.ttf"
322 269
     pdfmetrics.registerFont(TTFont("Logo", ttfFile_Logo))
270
+
323 271
     pdf = StringIO.StringIO()
272
+    out_img = StringIO.StringIO()
324 273
   
325 274
     c = canvas.Canvas( pdf, pagesize=(WIDTH, HEIGHT) )
326 275
     c.translate(mm, mm)
@@ -330,201 +279,70 @@ def badge_user1(request):
330 279
     c.setTitle("Badge")
331 280
 
332 281
     c.saveState()
333
-
334
-    logoobject = c.beginText()
335
-    logoobject.setFont('Logo', 52)
336
-    logoobject.setFillColorRGB(.83,0,.33)
337
-    logoobject.setTextOrigin(55, HEIGHT-50)
338
-    logoobject.textLines("JM2L")
339
-    c.drawText(logoobject)
340 282
     
283
+    one_badge(c, DispUser)
284
+
285
+    c.showPage()
286
+    c.save()
287
+    pdf.seek(0)
288
+    if isoutpng:
289
+        OutPDF = MediaPath().get_mediapath("badge", DispUser.uid, 'badge.pdf')
290
+        OutPNG = MediaPath().get_mediapath("badge", DispUser.uid, 'badge.png')
291
+        # Let's generate a png file for website
292
+        with open( OutPDF ,'wb') as pdff:
293
+            pdff.write(pdf.read())
341 294
     
342
-    yearobject = c.beginText()
343
-    yearobject.setFont("Helvetica-Bold", 15)
344
-    yearobject.setFillColorRGB(1,1,1)
345
-    yearobject.setTextOrigin(67, HEIGHT-20)
346
-    yearobject.setWordSpace(21)
347
-    yearobject.textLines("2 0 1 5")
348
-    c.drawText(yearobject)
295
+        Command = ["convert","-density","150x150", OutPDF, OutPNG]
296
+        subprocess.call(Command)
349 297
         
350
-    Tiers_Logo(c, DispUser)
351
-    
352
-    if 1:
353
-        Ribbon90(DispUser, c)
298
+        with open( OutPNG, 'rb') as pngfile:
299
+            out_img.write(pngfile.read())
354 300
         
355
-    if 0:
356
-        c.rotate(90)
357
-        offset_u=111
358
-        if DispUser.Staff:
359
-            # Staff
360
-            c.setFillColorRGB(1,.2,.2)        
361
-            c.rect(-5, HEIGHT/2-offset_u, WIDTH, 10*mm, fill=1)
362
-            c.setFillColorRGB(1,1,1)
363
-            c.setFont('Liberation', 30)
364
-            c.drawCentredString(WIDTH/2-15, HEIGHT/2-offset_u+5, "STAFF")
365
-        elif DispUser.is_Intervenant: 
366
-            # Intervenant
367
-            c.setFillColorRGB(.3,.3,1)        
368
-            c.rect(0, HEIGHT/2-offset_u, WIDTH, 10*mm, fill=1)
369
-            c.setFillColorRGB(1,1,1)
370
-            c.setFont('Liberation', 15)
371
-            c.drawCentredString(WIDTH/2-15, HEIGHT/2-offset_u+10, "Intervenant")        
372
-        else:
373
-            # Visiteur
374
-            c.setFillColorRGB(.8,.8,.8)        
375
-            c.rect(-5, HEIGHT/2-offset_u, WIDTH, 10*mm, fill=1)
376
-            c.setFillColorRGB(0,0,0)
377
-            c.setFont('Liberation', 19)
378
-            c.drawCentredString(WIDTH/2, HEIGHT/2-offset_u+7, "Visiteur")            
379
-    c.restoreState()
380
-    
381
-    c.setFont('Courier', 18)
382
-    c.setStrokeColorRGB(0,0,0)
383
-    c.setFillColorRGB(0,0,0)
384
-    # Feed Name and SurName
385
-    if len(DispUser.prenom) + len(DispUser.nom)>18:
386
-        if DispUser.pseudo:
387
-            c.drawCentredString(WIDTH/2, HEIGHT/2 + 4 * mm , "%s" % DispUser.prenom )
388
-            c.setFont('Courier', 17)        
389
-            c.drawCentredString(WIDTH/2, HEIGHT/2 - 2 * mm , "%s" % DispUser.nom )
390
-        else:
391
-            c.drawCentredString(WIDTH/2, HEIGHT/2 + 2 * mm , "%s" % DispUser.prenom )
392
-            c.setFont('Courier', 17)        
393
-            c.drawCentredString(WIDTH/2, HEIGHT/2 - 6 * mm , "%s" % DispUser.nom )            
301
+        out_img.seek(0)
302
+        return Response(app_iter=out_img, content_type = 'image/png' )
394 303
     else:
395
-        c.drawCentredString(WIDTH/2, HEIGHT/2 + 0 * mm , "%s %s" % (DispUser.prenom, DispUser.nom) )
396
-    #c.drawCentredString(WIDTH/2, HEIGHT - 22 * mm, )
397
-    if DispUser.pseudo:
398
-        #c.setFont('Liberation', 14)
399
-        c.setFont("Helvetica-Oblique", 14)
400
-        c.drawCentredString(WIDTH/2, HEIGHT/2 - 8 * mm , "\"%s\"" % DispUser.pseudo )
401
-    #c.restoreState()  
402
-    
403
-    # Put QR code to user profile 
404
-    c.drawInlineImage(QRCode(DispUser), \
405
-            WIDTH - 20 * mm - 7, 0, \
406
-            20 * mm, 20 * mm, \
407
-            preserveAspectRatio=True, \
408
-            anchor='s')
409
-   
410
-    c.showPage()
411
-    c.save()
412
-    pdf.seek(0)    
413
-    return Response(app_iter=pdf, content_type = 'application/pdf' )
304
+        return Response(app_iter=pdf, content_type = 'application/pdf' )
414 305
 
415
-    
416
-@view_config(route_name='badge_user2')
417
-def badge_user2(request):
418
-    user_slug = request.matchdict.get('user_slug', None)
419
-    if user_slug is None or len(user_slug)==0:
420
-        raise HTTPNotFound(u"Cet utilisateur n'a pas été reconnu")
421
-    # Query database
422
-    DispUser = User.by_slug(user_slug)
423
-    if DispUser is None:
424
-        raise HTTPNotFound()
425 306
 
426
-    # Ok let's generate a PDF Badge
307
+@view_config(route_name='all_badges')
308
+def planche_badge(request):
309
+    if request.user is None:
310
+        # Don't answer to users that aren't logged
311
+        raise HTTPForbidden(u'Vous devez vous identifier pour obtenir une réponse.')
312
+    # Query database about selected Year.
313
+    Users = DBSession.query(User)
314
+    #            .join(User_Event)\
315
+    #            .filter(User_Event.year_uid == year)
316
+
317
+    # Register LiberationMono font
427 318
     ttfFile = "jm2l/static/fonts/LiberationMono-Regular.ttf"
428
-    ttfFile_Logo = "jm2l/static/fonts/PWTinselLetters.ttf"
429 319
     pdfmetrics.registerFont(TTFont("Liberation", ttfFile))
320
+    # Import font
321
+    ttfFile_Logo = "jm2l/static/fonts/PWTinselLetters.ttf"
430 322
     pdfmetrics.registerFont(TTFont("Logo", ttfFile_Logo))
323
+    
431 324
     pdf = StringIO.StringIO()
432 325
 
433
-    qr = qrcode.QRCode(
434
-        version=1,
435
-        error_correction=qrcode.constants.ERROR_CORRECT_L,
436
-        box_size=10,
437
-        border=2,
438
-    )
439
-    # Data of QR code
440
-    qr.add_data('http://jm2l.linux-azur.org/user/%s' % DispUser.slug)
441
-    qr.make(fit=True)
326
+    FULLWIDTH = 210 * mm
327
+    FULLHEIGHT = 297 * mm
442 328
 
443
-    img = qr.make_image()    
444
-    # Create PDF container
445
-    WIDTH = 85 * mm
446
-    HEIGHT = 60 * mm
447
-    ICONSIZE = 10 * mm    
448
-    c = canvas.Canvas( pdf, pagesize=(WIDTH, HEIGHT) )
329
+    c = canvas.Canvas( pdf, pagesize=(FULLWIDTH, FULLHEIGHT) )
449 330
     c.translate(mm, mm)
450 331
     
451 332
     # Feed some metadata
452 333
     c.setCreator("linux-azur.org")
453 334
     c.setTitle("Badge")
335
+    t=0
336
+    ListUser = filter(lambda x: x.is_Intervenant or x.Staff or x.is_crew, Users)
337
+    for num, DispUser in enumerate(ListUser):
338
+        c.saveState()
339
+        Offsets = (((num-t)%2)*(WIDTH+40)+40, ((num-t)/2)*(HEIGHT+25)+40)
340
+        one_badge(c, DispUser, Offsets)
341
+        if num%8==7:
342
+            t=num+1
343
+            c.showPage()
454 344
 
455
-    c.saveState()
456
-
457
-    logoobject = c.beginText()
458
-    logoobject.setFont('Logo', 52)
459
-    logoobject.setFillColorRGB(.83,0,.33)
460
-    logoobject.setTextOrigin(55, HEIGHT-50)
461
-    logoobject.textLines("JM2L")
462
-    c.drawText(logoobject)
463
-    
464
-    
465
-    yearobject = c.beginText()
466
-    yearobject.setFont("Helvetica-Bold", 15)
467
-    yearobject.setFillColorRGB(1,1,1)
468
-    yearobject.setTextOrigin(67, HEIGHT-20)
469
-    yearobject.setWordSpace(21)
470
-    yearobject.textLines("2 0 1 5")
471
-    c.drawText(yearobject)
472
-            
473
-    if 1:
474
-        c.rotate(-35)
475
-        c.translate(-100, -70)
476
-        offset_u=0
477
-        if DispUser.Staff:
478
-            # Staff
479
-            c.setFillColorRGB(1,.2,.2)        
480
-            c.rect(0, HEIGHT/2-offset_u, WIDTH, 10*mm, fill=1)
481
-            c.setFillColorRGB(1,1,1)
482
-            c.setFont('Liberation', 20)
483
-            c.drawCentredString(WIDTH/2-10, HEIGHT/2-offset_u+5, "STAFF")
484
-        elif DispUser.is_Intervenant: 
485
-            # Intervenant
486
-            c.setFillColorRGB(.21,.3,1)        
487
-            c.rect(0, HEIGHT/2-offset_u, WIDTH, 10*mm, fill=1)
488
-            c.setFillColorRGB(1,1,1)
489
-            c.setFont('Liberation', 15)
490
-            c.drawCentredString(WIDTH/2-15, HEIGHT/2-offset_u+10, "Intervenant")        
491
-        else:
492
-            # Visiteur
493
-            c.setFillColorRGB(.8,.8,.8)        
494
-            c.rect(0, HEIGHT/2-offset_u, WIDTH, 10*mm, fill=1)
495
-            c.setFillColorRGB(0,0,0)
496
-            c.setFont('Liberation', 12)
497
-            c.drawCentredString(WIDTH/2-10, HEIGHT/2-offset_u+7, "Visiteur")
498
-            
499
-    c.restoreState()
500
-    
501
-    c.setFont('Courier', 18)
502
-    c.setStrokeColorRGB(0,0,0)
503
-    c.setFillColorRGB(0,0,0)
504
-    # Feed Name and SurName
505
-    if len(DispUser.prenom) + len(DispUser.nom)>18:
506
-        if DispUser.pseudo:
507
-            c.drawCentredString(WIDTH/2, HEIGHT/2 + 4 * mm , "%s" % DispUser.prenom )
508
-            c.setFont('Courier', 17)        
509
-            c.drawCentredString(WIDTH/2, HEIGHT/2 - 2 * mm , "%s" % DispUser.nom )
510
-        else:
511
-            c.drawCentredString(WIDTH/2, HEIGHT/2 + 2 * mm , "%s" % DispUser.prenom )
512
-            c.setFont('Courier', 17)        
513
-            c.drawCentredString(WIDTH/2, HEIGHT/2 - 6 * mm , "%s" % DispUser.nom )            
514
-    else:
515
-        c.drawCentredString(WIDTH/2, HEIGHT/2 + 0 * mm , "%s %s" % (DispUser.prenom, DispUser.nom) )
516
-    #c.drawCentredString(WIDTH/2, HEIGHT - 22 * mm, )
517
-    if DispUser.pseudo:
518
-        #c.setFont('Liberation', 14)
519
-        c.setFont("Helvetica-Oblique", 14)
520
-        c.drawCentredString(WIDTH/2, HEIGHT/2 - 8 * mm , "\"%s\"" % DispUser.pseudo )
521
-    #c.restoreState()  
522
-    # Put Tiers logos
523
-    Tiers_Logo(c, DispUser)
524
-    # Put QR code to user profile 
525
-    c.drawInlineImage(img, WIDTH - 20 * mm - 7, 0, 20 * mm, 20 * mm, preserveAspectRatio=True, anchor='s')
526
-   
527 345
     c.showPage()
528 346
     c.save()
529
-    pdf.seek(0)    
347
+    pdf.seek(0)
530 348
     return Response(app_iter=pdf, content_type = 'application/pdf' )

+ 7 - 1
jm2l/models.py

@@ -175,7 +175,13 @@ class User(Base):
175 175
         return DBSession.query(Event).join(User_Event) \
176 176
             .filter(User_Event.user_uid==self.uid) \
177 177
             .filter(Event.for_year==year).count()
178
-            
178
+
179
+    @property
180
+    def is_crew(self, year=2015):
181
+        """ This property will return if User subscribe orga task on specified year """
182
+        return DBSession.query(User,Sejour.orga_part).outerjoin(Sejour).filter(User.uid == self.uid).one()[1]
183
+    
184
+    
179 185
     def year_events(self, EventType='All', year=2015):
180 186
         if EventType=='All':
181 187
             return filter(lambda e: e.for_year==year, self.events)

+ 45 - 7
jm2l/static/js/programme.js

@@ -74,7 +74,7 @@ d3.json("le-prog-json",
74 74
                 .attr("viewBox", "0 0 " + (width + margin.right + margin.left) + " " + (height + margin.top + margin.bottom) )
75 75
                 .attr("preserveAspectRatio", "xMidYMid meet");
76 76
             // Add some gradient
77
-			header(svg);
77
+			header(svg, Keys[k]);
78 78
 			// Create axis
79 79
             svg.append("g")
80 80
                 .attr("class", "xAxis axis");
@@ -90,11 +90,11 @@ d3.json("le-prog-json",
90 90
         }
91 91
 });
92 92
 
93
-function header(svg) {
93
+function header(svg, day) {
94 94
 	defs = svg.append("svg:defs");
95 95
 	
96 96
 	conf = defs.append("svg:linearGradient")
97
-	    .attr("id", "BoxGradient-Conference")
97
+	    .attr("id", "BoxGradient-Conference-"+day)
98 98
 	    .attr("x1", "100%")
99 99
 	    .attr("y1", "0%")
100 100
 	    .attr("x2", "50%")
@@ -112,7 +112,7 @@ function header(svg) {
112 112
 	    .attr("stop-opacity", .5);
113 113
 	    
114 114
 	atlier = defs.append("svg:linearGradient")
115
-	    .attr("id", "BoxGradient-Atelier")
115
+	    .attr("id", "BoxGradient-Atelier-"+day)
116 116
 	    .attr("x1", "100%")
117 117
 	    .attr("y1", "0%")
118 118
 	    .attr("x2", "50%")
@@ -129,9 +129,47 @@ function header(svg) {
129 129
 	    .attr("stop-color", "#FF856E")
130 130
 	    .attr("stop-opacity", .5);	    
131 131
 
132
+	tabler = defs.append("svg:linearGradient")
133
+	    .attr("id", "BoxGradient-Table-ronde-"+day)
134
+	    .attr("x1", "100%")
135
+	    .attr("y1", "0%")
136
+	    .attr("x2", "50%")
137
+	    .attr("y2", "100%")
138
+	    .attr("spreadMethod", "pad");
139
+
140
+	tabler.append("svg:stop")
141
+	    .attr("offset", "0%")
142
+	    .attr("stop-color", "#EEE")
143
+	    .attr("stop-opacity", 0);
144
+	
145
+	tabler.append("svg:stop")
146
+	    .attr("offset", "15%")
147
+	    .attr("stop-color", "#B59EFF")
148
+	    .attr("stop-opacity", .5);
149
+	    
150
+
151
+	undef = defs.append("svg:linearGradient")
152
+	    .attr("id", "BoxGradient-undefined-"+day)
153
+	    .attr("x1", "100%")
154
+	    .attr("y1", "0%")
155
+	    .attr("x2", "50%")
156
+	    .attr("y2", "100%")
157
+	    .attr("spreadMethod", "pad");
158
+
159
+	undef.append("svg:stop")
160
+	    .attr("offset", "0%")
161
+	    .attr("stop-color", "#EEE")
162
+	    .attr("stop-opacity", 0);
163
+	
164
+	undef.append("svg:stop")
165
+	    .attr("offset", "15%")
166
+	    .attr("stop-color", "#359E35")
167
+	    .attr("stop-opacity", .5);
168
+
169
+
132 170
 	// append filter element
133 171
 	var filter = defs.append( 'filter' )
134
-	    .attr( 'id', 'dropshadow' ); /// !!! important - define id to reference it later
172
+	    .attr( 'id', 'dropshadow-'+day ); /// !!! important - define id to reference it later
135 173
 	
136 174
 	// append gaussian blur to filter
137 175
 	filter.append( 'feGaussianBlur' )
@@ -245,9 +283,9 @@ function displayit(Set_of_Task, Set_of_Area, key) {
245 283
             .insert("rect")
246 284
             .attr("rx", 5)
247 285
             .attr("ry", 5)
248
-            .attr("filter", "url(#dropshadow)")
286
+            .attr("filter", "url(#dropshadow-" + key + ")")
249 287
             .style("fill", function(d){
250
-            	return "url(#BoxGradient-"+ taskStatus[d.status] +")";
288
+            	return "url(#BoxGradient-"+ taskStatus[d.status] + "-" + key + ")";
251 289
             })
252 290
             .attr("class", function(d){ 
253 291
                  if(taskStatus[d.status] == null)

+ 11 - 3
jm2l/templates/Public/Programme.mako

@@ -21,13 +21,14 @@ TabDisplay = [
21 21
 }
22 22
 .SvgBody {
23 23
     padding: 0px;
24
-    background-color: transparent;
24
+/*    background-color: transparent; */
25 25
 }
26 26
 .EvtBox {
27 27
     font-size: 0.7em;
28 28
     line-height: 1.2em;
29 29
     padding:5px;
30 30
     height:100%;
31
+    max-width: 100%;    
31 32
 }
32 33
 .EvtBox a {
33 34
     color: #666;
@@ -37,8 +38,15 @@ svg {
37 38
   shape-rendering: crispEdges;
38 39
 }
39 40
 
40
-rect {
41
-  stroke-width: 0px;
41
+rect{fill:red;
42
+     stroke:none;
43
+     shape-rendering:crispEdges;
44
+}
45
+
46
+svg {
47
+margin: 1.5em auto;
48
+max-width: 100%;
49
+display: block;
42 50
 }
43 51
 
44 52
 .axis path,

+ 8 - 4
jm2l/views.py

@@ -1340,6 +1340,8 @@ def edit_event(request):
1340 1340
     IntervLabel = intervention.replace('_',' ').lower()
1341 1341
     if intervention=='Conference': 
1342 1342
         IntervLabel = u'conférence'
1343
+    elif intervention=='Table_ronde':
1344
+        IntervLabel = u'Table ronde'
1343 1345
     # Check intervention
1344 1346
     if not intervention in ['Stand', 'Table_ronde', 'Atelier', 'Conference', 'Concert']:
1345 1347
         raise HTTPNotFound(u"Ce type d'évenement n'est pas reconnu")
@@ -1467,11 +1469,13 @@ def edit_event(request):
1467 1469
         TheEvent.end_time = TheEvent.start_time + datetime.timedelta(minutes=form.duration.data)
1468 1470
         # Ok, time to put in database
1469 1471
         if not form._fields.has_key("uid"):
1470
-            TheEvent.slug = slugify(TheEvent.name)
1472
+            TheEvent.slug = unicode(slugify(TheEvent.name))
1473
+            if intervention==u"Table_ronde":
1474
+                TheEvent.event_type = "Table ronde"            
1471 1475
             DBSession.add(TheEvent)
1472 1476
             # Append creator by default
1473 1477
             if request.user.uid!=1:
1474
-                uev = User_Event(year_uid=TheYear.year_uid, role="Animateur")
1478
+                uev = User_Event(year_uid=TheYear.year_uid, role=u"Animateur")
1475 1479
                 uev.user_uid = request.user.uid
1476 1480
                 TheEvent.interventions.append( uev )
1477 1481
             DBSession.flush()
@@ -1482,13 +1486,13 @@ def edit_event(request):
1482 1486
             if slugify(TheEvent.name)!=TheEvent.slug:
1483 1487
                 # We should move some file as slug have been changed
1484 1488
                 # First we ensure there is no related event that already exist with that slug
1485
-                CheckEvent = Event.by_slug( slugify(TheEvent.name), year)
1489
+                CheckEvent = Event.by_slug( unicode(slugify(TheEvent.name)), year)
1486 1490
                 if CheckEvent:
1487 1491
                     request.session.flash(('warning',u'Choisissez un autre titre pour votre évenement, il est en conflit avec un autre.'))
1488 1492
                     return {'event':TheEvent, 'form':form, 'formAdd':formAdd, 'formAddT':formAddT, 'Salles':Salles }
1489 1493
                 else:
1490 1494
                     SRCPath = path.join('jm2l/upload', *(IMAGEPATH + ['event'] + [ str(year) ] + [ TheEvent.slug ]) )
1491
-                    TheEvent.slug=slugify(TheEvent.name)
1495
+                    TheEvent.slug=unicode(slugify(TheEvent.name))
1492 1496
                     DSTPath = path.join('jm2l/upload', *(IMAGEPATH + ['event'] + [ str(year) ] + [ TheEvent.slug ]) )
1493 1497
                     if not path.isdir(path.dirname(DSTPath)):
1494 1498
                         makedirs(path.dirname(DSTPath))