Fix Display of program, Fix table ronde
This commit is contained in:
+1
-2
@@ -153,8 +153,7 @@ def main(global_config, **settings):
|
||||
config.add_route('pict_user', '/user_picture')
|
||||
config.add_route('show_user', '/user/{user_slug:([\w-]+)?}')
|
||||
config.add_route('badge_user', '/user/{user_slug:([\w-]+)?}/badge')
|
||||
config.add_route('badge_user1', '/user/{user_slug:([\w-]+)?}/badge1')
|
||||
config.add_route('badge_user2', '/user/{user_slug:([\w-]+)?}/badge2')
|
||||
config.add_route('all_badges', '/badges')
|
||||
|
||||
# HTML Routes - Logged
|
||||
#config.add_route('profil', 'MesJM2L')
|
||||
|
||||
+112
-294
@@ -1,9 +1,9 @@
|
||||
# -*- coding: utf8 -*-
|
||||
from pyramid.httpexceptions import HTTPNotFound
|
||||
from pyramid.httpexceptions import HTTPNotFound, HTTPForbidden
|
||||
from pyramid.response import Response
|
||||
import cStringIO as StringIO
|
||||
from pyramid.view import view_config
|
||||
from .models import User
|
||||
from .models import DBSession, User
|
||||
from reportlab.pdfgen import canvas
|
||||
from reportlab.pdfbase import pdfmetrics
|
||||
from reportlab.pdfbase.ttfonts import TTFont
|
||||
@@ -11,12 +11,11 @@ from reportlab.lib.units import mm
|
||||
import qrcode
|
||||
import subprocess
|
||||
from .upload import MediaPath
|
||||
|
||||
# Create PDF container
|
||||
EXPIRATION_TIME = 300 # seconds
|
||||
WIDTH = 85 * mm
|
||||
HEIGHT = 60 * mm
|
||||
ICONSIZE = 9 * mm
|
||||
ICONSIZE = 10 * mm
|
||||
|
||||
def Ribbon35(DispUser, canvas):
|
||||
canvas.saveState()
|
||||
@@ -102,48 +101,27 @@ def Ribbon90(DispUser, canvas):
|
||||
canvas.restoreState()
|
||||
return canvas
|
||||
|
||||
def JM2L_Logo(canvas, Position="Up"):
|
||||
# Import font
|
||||
ttfFile_Logo = "jm2l/static/fonts/PWTinselLetters.ttf"
|
||||
pdfmetrics.registerFont(TTFont("Logo", ttfFile_Logo))
|
||||
|
||||
if Position=="Up":
|
||||
logoobject = canvas.beginText()
|
||||
logoobject.setFont('Logo', 52)
|
||||
logoobject.setFillColorRGB(.83,0,.33)
|
||||
logoobject.setTextOrigin(55, HEIGHT-50)
|
||||
logoobject.textLines("JM2L")
|
||||
canvas.drawText(logoobject)
|
||||
|
||||
yearobject = canvas.beginText()
|
||||
yearobject.setFont("Helvetica-Bold", 15)
|
||||
yearobject.setFillColorRGB(1,1,1)
|
||||
yearobject.setTextOrigin(67, HEIGHT-20)
|
||||
yearobject.setWordSpace(21)
|
||||
yearobject.textLines("2 0 1 5")
|
||||
canvas.drawText(yearobject)
|
||||
elif Position=="Down":
|
||||
def JM2L_Logo(canvas, Offset=(0,0)):
|
||||
OffX, OffY = Offset
|
||||
logoobject = canvas.beginText()
|
||||
logoobject.setFont('Logo', 32)
|
||||
logoobject.setFillColorRGB(.83,0,.33)
|
||||
logoobject.setTextOrigin(2, 17)
|
||||
logoobject.setTextOrigin(OffX+5, OffY+17)
|
||||
logoobject.textLines("JM2L")
|
||||
canvas.drawText(logoobject)
|
||||
|
||||
yearobject = canvas.beginText()
|
||||
yearobject.setFont("Helvetica-Bold", 10)
|
||||
yearobject.setFillColorRGB(1,1,1)
|
||||
#yearobject.setLineWidth(.1)
|
||||
#yearobject.setStrokeColorRGB(.5,.5,.5)
|
||||
yearobject.setTextRenderMode(0)
|
||||
#yearobject.setStrokeOverprint(.2)
|
||||
yearobject.setTextOrigin(9 , 35)
|
||||
yearobject.setTextOrigin(OffX+12 , OffY+35)
|
||||
yearobject.setWordSpace(13)
|
||||
yearobject.textLines("2 0 1 5")
|
||||
canvas.drawText(yearobject)
|
||||
|
||||
def Tiers_Logo(canvas, DispUser, StartPos=None):
|
||||
def Tiers_Logo(canvas, DispUser, StartPos=None, Offset=(0,0)):
|
||||
Border = 0
|
||||
OffX, OffY = Offset
|
||||
if StartPos is None:
|
||||
StartPos = ( 30 * mm, 2 )
|
||||
StartX, StartY = StartPos
|
||||
@@ -173,11 +151,15 @@ def Tiers_Logo(canvas, DispUser, StartPos=None):
|
||||
for tiers in Logos:
|
||||
FileName = tiers.ThumbLinks.pop().split("/")[-1]
|
||||
ImagePath = "jm2l/upload/images/tiers/%s/%s" % (tiers.slug, FileName)
|
||||
PosX = StartX + DicPos[len(Logos)][num][0] * MaxX - (ICONSIZE+Border)/2
|
||||
PosY = StartY + DicPos[len(Logos)][num][1] * MaxY - (ICONSIZE+Border)/2
|
||||
PosX = OffX+StartX + DicPos[len(Logos)][num][0] * MaxX - (ICONSIZE+Border)/2
|
||||
PosY = OffY+StartY + DicPos[len(Logos)][num][1] * MaxY - (ICONSIZE+Border)/2
|
||||
canvas.setLineWidth(.1)
|
||||
if len(Logos)>1:
|
||||
size = ICONSIZE
|
||||
else:
|
||||
size = ICONSIZE*1.5
|
||||
canvas.drawImage(ImagePath,
|
||||
PosX, PosY, ICONSIZE, ICONSIZE,\
|
||||
PosX, PosY, size, size,\
|
||||
preserveAspectRatio=True,
|
||||
anchor='c',
|
||||
mask='auto'
|
||||
@@ -199,6 +181,72 @@ def QRCode(DispUser):
|
||||
|
||||
return qr.make_image()
|
||||
|
||||
def one_badge(c, DispUser, Offset=(0,0)):
|
||||
# Logo on Top
|
||||
JM2L_Logo(c, Offset)
|
||||
OffX, OffY = Offset
|
||||
|
||||
c.rect(OffX-3, OffY-3, WIDTH+6, HEIGHT+6, fill=0, stroke=1)
|
||||
if DispUser.Staff:
|
||||
# Staff
|
||||
c.setFillColorRGB(.83,0,.33)
|
||||
c.rect(OffX-3, OffY+HEIGHT-30, WIDTH+6, 33, fill=1, stroke=0)
|
||||
c.setFillColorRGB(1,1,1)
|
||||
c.setFont('Liberation', 30)
|
||||
c.drawCentredString(OffX+WIDTH/2, OffY+HEIGHT-24, "STAFF")
|
||||
elif DispUser.is_Intervenant:
|
||||
# Intervenant
|
||||
c.setFillColorRGB(.21,.67,.78)
|
||||
c.rect(OffX-3, OffY+HEIGHT-30, WIDTH+6, 33, fill=1, stroke=0)
|
||||
c.setFillColorRGB(1,1,1)
|
||||
c.setFont('Liberation', 30)
|
||||
c.drawCentredString(OffX+WIDTH/2, OffY+HEIGHT-24, "Intervenant")
|
||||
elif DispUser.is_crew:
|
||||
# Benevole
|
||||
c.setFillColorRGB(.18,.76,.23)
|
||||
c.rect(OffX-3, OffY+HEIGHT-30, WIDTH+6, 33, fill=1, stroke=0)
|
||||
c.setFillColorRGB(1,1,1)
|
||||
c.setFont('Liberation', 30)
|
||||
c.drawCentredString(OffX+WIDTH/2, OffY+HEIGHT-24, "Bénévole")
|
||||
else:
|
||||
# Visiteur
|
||||
c.setFillColorRGB(.8,.8,.8)
|
||||
c.rect(OffX-3, OffY+HEIGHT-30, WIDTH+6, 33, fill=1, stroke=0)
|
||||
c.setFillColorRGB(1,1,1)
|
||||
c.setFont('Liberation', 30)
|
||||
c.drawCentredString(OffX+WIDTH/2, OffY+HEIGHT-24, "Visiteur")
|
||||
|
||||
c.restoreState()
|
||||
|
||||
c.setFont('Liberation', 18)
|
||||
c.setStrokeColorRGB(0,0,0)
|
||||
c.setFillColorRGB(0,0,0)
|
||||
# Feed Name and SurName
|
||||
if DispUser.prenom and DispUser.nom and len(DispUser.prenom) + len(DispUser.nom)>18:
|
||||
if DispUser.pseudo:
|
||||
c.drawCentredString(OffX+WIDTH/2, OffY+HEIGHT/2 + 0 * mm , "%s" % DispUser.prenom )
|
||||
#c.setFont('Courier', 17)
|
||||
c.drawCentredString(OffX+WIDTH/2, OffY+HEIGHT/2 - 8 * mm , "%s" % DispUser.nom )
|
||||
else:
|
||||
c.drawCentredString(OffX+WIDTH/2, OffY+HEIGHT/2 + 4 * mm , "%s" % DispUser.prenom )
|
||||
#c.setFont('Courier', 17)
|
||||
c.drawCentredString(OffX+WIDTH/2, OffY+HEIGHT/2 - 8 * mm , "%s" % DispUser.nom )
|
||||
else:
|
||||
c.drawCentredString(OffX+WIDTH/2, OffY+HEIGHT/2 + 0 * mm , "%s %s" % (DispUser.prenom, DispUser.nom) )
|
||||
|
||||
if DispUser.pseudo:
|
||||
c.setFont("Helvetica-Oblique", 18)
|
||||
c.drawCentredString(OffX+WIDTH/2, OffY+HEIGHT/2 + 10 * mm , "%s" % DispUser.pseudo )
|
||||
|
||||
# Put QR code to user profile
|
||||
c.drawInlineImage(QRCode(DispUser), \
|
||||
OffX+WIDTH - 20 * mm -5, OffY+5, \
|
||||
20 * mm, 20 * mm, \
|
||||
preserveAspectRatio=True, \
|
||||
anchor='s')
|
||||
|
||||
Tiers_Logo(c, DispUser, None, Offset)
|
||||
|
||||
|
||||
@view_config(route_name='badge_user', http_cache = (EXPIRATION_TIME, {'public':True}))
|
||||
def badge_user(request):
|
||||
@@ -216,6 +264,9 @@ def badge_user(request):
|
||||
# Register LiberationMono font
|
||||
ttfFile = "jm2l/static/fonts/LiberationMono-Regular.ttf"
|
||||
pdfmetrics.registerFont(TTFont("Liberation", ttfFile))
|
||||
# Import font
|
||||
ttfFile_Logo = "jm2l/static/fonts/PWTinselLetters.ttf"
|
||||
pdfmetrics.registerFont(TTFont("Logo", ttfFile_Logo))
|
||||
|
||||
pdf = StringIO.StringIO()
|
||||
out_img = StringIO.StringIO()
|
||||
@@ -228,61 +279,8 @@ def badge_user(request):
|
||||
c.setTitle("Badge")
|
||||
|
||||
c.saveState()
|
||||
# Logo on Top
|
||||
JM2L_Logo(c, "Down")
|
||||
|
||||
if DispUser.Staff:
|
||||
# Staff
|
||||
c.setFillColorRGB(.83,0,.33)
|
||||
c.rect(-3, HEIGHT-30, WIDTH, HEIGHT, fill=1, stroke=0)
|
||||
c.setFillColorRGB(1,1,1)
|
||||
c.setFont('Liberation', 30)
|
||||
c.drawCentredString(WIDTH/2, HEIGHT-26, "STAFF")
|
||||
elif DispUser.is_Intervenant:
|
||||
# Intervenant
|
||||
c.setFillColorRGB(.21,.67,.78)
|
||||
c.rect(-3, HEIGHT-30, WIDTH, HEIGHT, fill=1, stroke=0)
|
||||
c.setFillColorRGB(1,1,1)
|
||||
c.setFont('Liberation', 30)
|
||||
c.drawCentredString(WIDTH/2, HEIGHT-26, "Intervenant")
|
||||
else:
|
||||
# Visiteur
|
||||
c.setFillColorRGB(.8,.8,.8)
|
||||
c.rect(-3, HEIGHT-30, WIDTH, HEIGHT, fill=1, stroke=0)
|
||||
c.setFillColorRGB(1,1,1)
|
||||
c.setFont('Liberation', 30)
|
||||
c.drawCentredString(WIDTH/2, HEIGHT-26, "Visiteur")
|
||||
|
||||
c.restoreState()
|
||||
|
||||
c.setFont('Liberation', 18)
|
||||
c.setStrokeColorRGB(0,0,0)
|
||||
c.setFillColorRGB(0,0,0)
|
||||
# Feed Name and SurName
|
||||
if len(DispUser.prenom) + len(DispUser.nom)>18:
|
||||
if DispUser.pseudo:
|
||||
c.drawCentredString(WIDTH/2, HEIGHT/2 + 0 * mm , "%s" % DispUser.prenom )
|
||||
c.setFont('Courier', 17)
|
||||
c.drawCentredString(WIDTH/2, HEIGHT/2 - 8 * mm , "%s" % DispUser.nom )
|
||||
else:
|
||||
c.drawCentredString(WIDTH/2, HEIGHT/2 + 4 * mm , "%s" % DispUser.prenom )
|
||||
c.setFont('Courier', 17)
|
||||
c.drawCentredString(WIDTH/2, HEIGHT/2 - 8 * mm , "%s" % DispUser.nom )
|
||||
else:
|
||||
c.drawCentredString(WIDTH/2, HEIGHT/2 + 0 * mm , "%s %s" % (DispUser.prenom, DispUser.nom) )
|
||||
|
||||
if DispUser.pseudo:
|
||||
c.setFont("Helvetica-Oblique", 18)
|
||||
c.drawCentredString(WIDTH/2, HEIGHT/2 + 10 * mm , "%s" % DispUser.pseudo )
|
||||
|
||||
# Put QR code to user profile
|
||||
c.drawInlineImage(QRCode(DispUser), \
|
||||
WIDTH - 20 * mm - 7, 0, \
|
||||
20 * mm, 20 * mm, \
|
||||
preserveAspectRatio=True, \
|
||||
anchor='s')
|
||||
|
||||
Tiers_Logo(c, DispUser)
|
||||
one_badge(c, DispUser)
|
||||
|
||||
c.showPage()
|
||||
c.save()
|
||||
@@ -305,224 +303,44 @@ def badge_user(request):
|
||||
else:
|
||||
return Response(app_iter=pdf, content_type = 'application/pdf' )
|
||||
|
||||
@view_config(route_name='badge_user1')
|
||||
def badge_user1(request):
|
||||
user_slug = request.matchdict.get('user_slug', None)
|
||||
if user_slug is None or len(user_slug)==0:
|
||||
raise HTTPNotFound(u"Cet utilisateur n'a pas été reconnu")
|
||||
# Query database
|
||||
DispUser = User.by_slug(user_slug)
|
||||
if DispUser is None:
|
||||
raise HTTPNotFound()
|
||||
|
||||
# Ok let's generate a PDF Badge
|
||||
@view_config(route_name='all_badges')
|
||||
def planche_badge(request):
|
||||
if request.user is None:
|
||||
# Don't answer to users that aren't logged
|
||||
raise HTTPForbidden(u'Vous devez vous identifier pour obtenir une réponse.')
|
||||
# Query database about selected Year.
|
||||
Users = DBSession.query(User)
|
||||
# .join(User_Event)\
|
||||
# .filter(User_Event.year_uid == year)
|
||||
|
||||
# Register LiberationMono font
|
||||
ttfFile = "jm2l/static/fonts/LiberationMono-Regular.ttf"
|
||||
ttfFile_Logo = "jm2l/static/fonts/PWTinselLetters.ttf"
|
||||
pdfmetrics.registerFont(TTFont("Liberation", ttfFile))
|
||||
# Import font
|
||||
ttfFile_Logo = "jm2l/static/fonts/PWTinselLetters.ttf"
|
||||
pdfmetrics.registerFont(TTFont("Logo", ttfFile_Logo))
|
||||
|
||||
pdf = StringIO.StringIO()
|
||||
|
||||
c = canvas.Canvas( pdf, pagesize=(WIDTH, HEIGHT) )
|
||||
FULLWIDTH = 210 * mm
|
||||
FULLHEIGHT = 297 * mm
|
||||
|
||||
c = canvas.Canvas( pdf, pagesize=(FULLWIDTH, FULLHEIGHT) )
|
||||
c.translate(mm, mm)
|
||||
|
||||
# Feed some metadata
|
||||
c.setCreator("linux-azur.org")
|
||||
c.setTitle("Badge")
|
||||
|
||||
t=0
|
||||
ListUser = filter(lambda x: x.is_Intervenant or x.Staff or x.is_crew, Users)
|
||||
for num, DispUser in enumerate(ListUser):
|
||||
c.saveState()
|
||||
|
||||
logoobject = c.beginText()
|
||||
logoobject.setFont('Logo', 52)
|
||||
logoobject.setFillColorRGB(.83,0,.33)
|
||||
logoobject.setTextOrigin(55, HEIGHT-50)
|
||||
logoobject.textLines("JM2L")
|
||||
c.drawText(logoobject)
|
||||
|
||||
|
||||
yearobject = c.beginText()
|
||||
yearobject.setFont("Helvetica-Bold", 15)
|
||||
yearobject.setFillColorRGB(1,1,1)
|
||||
yearobject.setTextOrigin(67, HEIGHT-20)
|
||||
yearobject.setWordSpace(21)
|
||||
yearobject.textLines("2 0 1 5")
|
||||
c.drawText(yearobject)
|
||||
|
||||
Tiers_Logo(c, DispUser)
|
||||
|
||||
if 1:
|
||||
Ribbon90(DispUser, c)
|
||||
|
||||
if 0:
|
||||
c.rotate(90)
|
||||
offset_u=111
|
||||
if DispUser.Staff:
|
||||
# Staff
|
||||
c.setFillColorRGB(1,.2,.2)
|
||||
c.rect(-5, HEIGHT/2-offset_u, WIDTH, 10*mm, fill=1)
|
||||
c.setFillColorRGB(1,1,1)
|
||||
c.setFont('Liberation', 30)
|
||||
c.drawCentredString(WIDTH/2-15, HEIGHT/2-offset_u+5, "STAFF")
|
||||
elif DispUser.is_Intervenant:
|
||||
# Intervenant
|
||||
c.setFillColorRGB(.3,.3,1)
|
||||
c.rect(0, HEIGHT/2-offset_u, WIDTH, 10*mm, fill=1)
|
||||
c.setFillColorRGB(1,1,1)
|
||||
c.setFont('Liberation', 15)
|
||||
c.drawCentredString(WIDTH/2-15, HEIGHT/2-offset_u+10, "Intervenant")
|
||||
else:
|
||||
# Visiteur
|
||||
c.setFillColorRGB(.8,.8,.8)
|
||||
c.rect(-5, HEIGHT/2-offset_u, WIDTH, 10*mm, fill=1)
|
||||
c.setFillColorRGB(0,0,0)
|
||||
c.setFont('Liberation', 19)
|
||||
c.drawCentredString(WIDTH/2, HEIGHT/2-offset_u+7, "Visiteur")
|
||||
c.restoreState()
|
||||
|
||||
c.setFont('Courier', 18)
|
||||
c.setStrokeColorRGB(0,0,0)
|
||||
c.setFillColorRGB(0,0,0)
|
||||
# Feed Name and SurName
|
||||
if len(DispUser.prenom) + len(DispUser.nom)>18:
|
||||
if DispUser.pseudo:
|
||||
c.drawCentredString(WIDTH/2, HEIGHT/2 + 4 * mm , "%s" % DispUser.prenom )
|
||||
c.setFont('Courier', 17)
|
||||
c.drawCentredString(WIDTH/2, HEIGHT/2 - 2 * mm , "%s" % DispUser.nom )
|
||||
else:
|
||||
c.drawCentredString(WIDTH/2, HEIGHT/2 + 2 * mm , "%s" % DispUser.prenom )
|
||||
c.setFont('Courier', 17)
|
||||
c.drawCentredString(WIDTH/2, HEIGHT/2 - 6 * mm , "%s" % DispUser.nom )
|
||||
else:
|
||||
c.drawCentredString(WIDTH/2, HEIGHT/2 + 0 * mm , "%s %s" % (DispUser.prenom, DispUser.nom) )
|
||||
#c.drawCentredString(WIDTH/2, HEIGHT - 22 * mm, )
|
||||
if DispUser.pseudo:
|
||||
#c.setFont('Liberation', 14)
|
||||
c.setFont("Helvetica-Oblique", 14)
|
||||
c.drawCentredString(WIDTH/2, HEIGHT/2 - 8 * mm , "\"%s\"" % DispUser.pseudo )
|
||||
#c.restoreState()
|
||||
|
||||
# Put QR code to user profile
|
||||
c.drawInlineImage(QRCode(DispUser), \
|
||||
WIDTH - 20 * mm - 7, 0, \
|
||||
20 * mm, 20 * mm, \
|
||||
preserveAspectRatio=True, \
|
||||
anchor='s')
|
||||
|
||||
c.showPage()
|
||||
c.save()
|
||||
pdf.seek(0)
|
||||
return Response(app_iter=pdf, content_type = 'application/pdf' )
|
||||
|
||||
|
||||
@view_config(route_name='badge_user2')
|
||||
def badge_user2(request):
|
||||
user_slug = request.matchdict.get('user_slug', None)
|
||||
if user_slug is None or len(user_slug)==0:
|
||||
raise HTTPNotFound(u"Cet utilisateur n'a pas été reconnu")
|
||||
# Query database
|
||||
DispUser = User.by_slug(user_slug)
|
||||
if DispUser is None:
|
||||
raise HTTPNotFound()
|
||||
|
||||
# Ok let's generate a PDF Badge
|
||||
ttfFile = "jm2l/static/fonts/LiberationMono-Regular.ttf"
|
||||
ttfFile_Logo = "jm2l/static/fonts/PWTinselLetters.ttf"
|
||||
pdfmetrics.registerFont(TTFont("Liberation", ttfFile))
|
||||
pdfmetrics.registerFont(TTFont("Logo", ttfFile_Logo))
|
||||
pdf = StringIO.StringIO()
|
||||
|
||||
qr = qrcode.QRCode(
|
||||
version=1,
|
||||
error_correction=qrcode.constants.ERROR_CORRECT_L,
|
||||
box_size=10,
|
||||
border=2,
|
||||
)
|
||||
# Data of QR code
|
||||
qr.add_data('http://jm2l.linux-azur.org/user/%s' % DispUser.slug)
|
||||
qr.make(fit=True)
|
||||
|
||||
img = qr.make_image()
|
||||
# Create PDF container
|
||||
WIDTH = 85 * mm
|
||||
HEIGHT = 60 * mm
|
||||
ICONSIZE = 10 * mm
|
||||
c = canvas.Canvas( pdf, pagesize=(WIDTH, HEIGHT) )
|
||||
c.translate(mm, mm)
|
||||
|
||||
# Feed some metadata
|
||||
c.setCreator("linux-azur.org")
|
||||
c.setTitle("Badge")
|
||||
|
||||
c.saveState()
|
||||
|
||||
logoobject = c.beginText()
|
||||
logoobject.setFont('Logo', 52)
|
||||
logoobject.setFillColorRGB(.83,0,.33)
|
||||
logoobject.setTextOrigin(55, HEIGHT-50)
|
||||
logoobject.textLines("JM2L")
|
||||
c.drawText(logoobject)
|
||||
|
||||
|
||||
yearobject = c.beginText()
|
||||
yearobject.setFont("Helvetica-Bold", 15)
|
||||
yearobject.setFillColorRGB(1,1,1)
|
||||
yearobject.setTextOrigin(67, HEIGHT-20)
|
||||
yearobject.setWordSpace(21)
|
||||
yearobject.textLines("2 0 1 5")
|
||||
c.drawText(yearobject)
|
||||
|
||||
if 1:
|
||||
c.rotate(-35)
|
||||
c.translate(-100, -70)
|
||||
offset_u=0
|
||||
if DispUser.Staff:
|
||||
# Staff
|
||||
c.setFillColorRGB(1,.2,.2)
|
||||
c.rect(0, HEIGHT/2-offset_u, WIDTH, 10*mm, fill=1)
|
||||
c.setFillColorRGB(1,1,1)
|
||||
c.setFont('Liberation', 20)
|
||||
c.drawCentredString(WIDTH/2-10, HEIGHT/2-offset_u+5, "STAFF")
|
||||
elif DispUser.is_Intervenant:
|
||||
# Intervenant
|
||||
c.setFillColorRGB(.21,.3,1)
|
||||
c.rect(0, HEIGHT/2-offset_u, WIDTH, 10*mm, fill=1)
|
||||
c.setFillColorRGB(1,1,1)
|
||||
c.setFont('Liberation', 15)
|
||||
c.drawCentredString(WIDTH/2-15, HEIGHT/2-offset_u+10, "Intervenant")
|
||||
else:
|
||||
# Visiteur
|
||||
c.setFillColorRGB(.8,.8,.8)
|
||||
c.rect(0, HEIGHT/2-offset_u, WIDTH, 10*mm, fill=1)
|
||||
c.setFillColorRGB(0,0,0)
|
||||
c.setFont('Liberation', 12)
|
||||
c.drawCentredString(WIDTH/2-10, HEIGHT/2-offset_u+7, "Visiteur")
|
||||
|
||||
c.restoreState()
|
||||
|
||||
c.setFont('Courier', 18)
|
||||
c.setStrokeColorRGB(0,0,0)
|
||||
c.setFillColorRGB(0,0,0)
|
||||
# Feed Name and SurName
|
||||
if len(DispUser.prenom) + len(DispUser.nom)>18:
|
||||
if DispUser.pseudo:
|
||||
c.drawCentredString(WIDTH/2, HEIGHT/2 + 4 * mm , "%s" % DispUser.prenom )
|
||||
c.setFont('Courier', 17)
|
||||
c.drawCentredString(WIDTH/2, HEIGHT/2 - 2 * mm , "%s" % DispUser.nom )
|
||||
else:
|
||||
c.drawCentredString(WIDTH/2, HEIGHT/2 + 2 * mm , "%s" % DispUser.prenom )
|
||||
c.setFont('Courier', 17)
|
||||
c.drawCentredString(WIDTH/2, HEIGHT/2 - 6 * mm , "%s" % DispUser.nom )
|
||||
else:
|
||||
c.drawCentredString(WIDTH/2, HEIGHT/2 + 0 * mm , "%s %s" % (DispUser.prenom, DispUser.nom) )
|
||||
#c.drawCentredString(WIDTH/2, HEIGHT - 22 * mm, )
|
||||
if DispUser.pseudo:
|
||||
#c.setFont('Liberation', 14)
|
||||
c.setFont("Helvetica-Oblique", 14)
|
||||
c.drawCentredString(WIDTH/2, HEIGHT/2 - 8 * mm , "\"%s\"" % DispUser.pseudo )
|
||||
#c.restoreState()
|
||||
# Put Tiers logos
|
||||
Tiers_Logo(c, DispUser)
|
||||
# Put QR code to user profile
|
||||
c.drawInlineImage(img, WIDTH - 20 * mm - 7, 0, 20 * mm, 20 * mm, preserveAspectRatio=True, anchor='s')
|
||||
Offsets = (((num-t)%2)*(WIDTH+40)+40, ((num-t)/2)*(HEIGHT+25)+40)
|
||||
one_badge(c, DispUser, Offsets)
|
||||
if num%8==7:
|
||||
t=num+1
|
||||
c.showPage()
|
||||
|
||||
c.showPage()
|
||||
c.save()
|
||||
|
||||
@@ -176,6 +176,12 @@ class User(Base):
|
||||
.filter(User_Event.user_uid==self.uid) \
|
||||
.filter(Event.for_year==year).count()
|
||||
|
||||
@property
|
||||
def is_crew(self, year=2015):
|
||||
""" 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]
|
||||
|
||||
|
||||
def year_events(self, EventType='All', year=2015):
|
||||
if EventType=='All':
|
||||
return filter(lambda e: e.for_year==year, self.events)
|
||||
|
||||
@@ -74,7 +74,7 @@ d3.json("le-prog-json",
|
||||
.attr("viewBox", "0 0 " + (width + margin.right + margin.left) + " " + (height + margin.top + margin.bottom) )
|
||||
.attr("preserveAspectRatio", "xMidYMid meet");
|
||||
// Add some gradient
|
||||
header(svg);
|
||||
header(svg, Keys[k]);
|
||||
// Create axis
|
||||
svg.append("g")
|
||||
.attr("class", "xAxis axis");
|
||||
@@ -90,11 +90,11 @@ d3.json("le-prog-json",
|
||||
}
|
||||
});
|
||||
|
||||
function header(svg) {
|
||||
function header(svg, day) {
|
||||
defs = svg.append("svg:defs");
|
||||
|
||||
conf = defs.append("svg:linearGradient")
|
||||
.attr("id", "BoxGradient-Conference")
|
||||
.attr("id", "BoxGradient-Conference-"+day)
|
||||
.attr("x1", "100%")
|
||||
.attr("y1", "0%")
|
||||
.attr("x2", "50%")
|
||||
@@ -112,7 +112,7 @@ function header(svg) {
|
||||
.attr("stop-opacity", .5);
|
||||
|
||||
atlier = defs.append("svg:linearGradient")
|
||||
.attr("id", "BoxGradient-Atelier")
|
||||
.attr("id", "BoxGradient-Atelier-"+day)
|
||||
.attr("x1", "100%")
|
||||
.attr("y1", "0%")
|
||||
.attr("x2", "50%")
|
||||
@@ -129,9 +129,47 @@ function header(svg) {
|
||||
.attr("stop-color", "#FF856E")
|
||||
.attr("stop-opacity", .5);
|
||||
|
||||
tabler = defs.append("svg:linearGradient")
|
||||
.attr("id", "BoxGradient-Table-ronde-"+day)
|
||||
.attr("x1", "100%")
|
||||
.attr("y1", "0%")
|
||||
.attr("x2", "50%")
|
||||
.attr("y2", "100%")
|
||||
.attr("spreadMethod", "pad");
|
||||
|
||||
tabler.append("svg:stop")
|
||||
.attr("offset", "0%")
|
||||
.attr("stop-color", "#EEE")
|
||||
.attr("stop-opacity", 0);
|
||||
|
||||
tabler.append("svg:stop")
|
||||
.attr("offset", "15%")
|
||||
.attr("stop-color", "#B59EFF")
|
||||
.attr("stop-opacity", .5);
|
||||
|
||||
|
||||
undef = defs.append("svg:linearGradient")
|
||||
.attr("id", "BoxGradient-undefined-"+day)
|
||||
.attr("x1", "100%")
|
||||
.attr("y1", "0%")
|
||||
.attr("x2", "50%")
|
||||
.attr("y2", "100%")
|
||||
.attr("spreadMethod", "pad");
|
||||
|
||||
undef.append("svg:stop")
|
||||
.attr("offset", "0%")
|
||||
.attr("stop-color", "#EEE")
|
||||
.attr("stop-opacity", 0);
|
||||
|
||||
undef.append("svg:stop")
|
||||
.attr("offset", "15%")
|
||||
.attr("stop-color", "#359E35")
|
||||
.attr("stop-opacity", .5);
|
||||
|
||||
|
||||
// append filter element
|
||||
var filter = defs.append( 'filter' )
|
||||
.attr( 'id', 'dropshadow' ); /// !!! important - define id to reference it later
|
||||
.attr( 'id', 'dropshadow-'+day ); /// !!! important - define id to reference it later
|
||||
|
||||
// append gaussian blur to filter
|
||||
filter.append( 'feGaussianBlur' )
|
||||
@@ -245,9 +283,9 @@ function displayit(Set_of_Task, Set_of_Area, key) {
|
||||
.insert("rect")
|
||||
.attr("rx", 5)
|
||||
.attr("ry", 5)
|
||||
.attr("filter", "url(#dropshadow)")
|
||||
.attr("filter", "url(#dropshadow-" + key + ")")
|
||||
.style("fill", function(d){
|
||||
return "url(#BoxGradient-"+ taskStatus[d.status] +")";
|
||||
return "url(#BoxGradient-"+ taskStatus[d.status] + "-" + key + ")";
|
||||
})
|
||||
.attr("class", function(d){
|
||||
if(taskStatus[d.status] == null)
|
||||
|
||||
@@ -21,13 +21,14 @@ TabDisplay = [
|
||||
}
|
||||
.SvgBody {
|
||||
padding: 0px;
|
||||
background-color: transparent;
|
||||
/* background-color: transparent; */
|
||||
}
|
||||
.EvtBox {
|
||||
font-size: 0.7em;
|
||||
line-height: 1.2em;
|
||||
padding:5px;
|
||||
height:100%;
|
||||
max-width: 100%;
|
||||
}
|
||||
.EvtBox a {
|
||||
color: #666;
|
||||
@@ -37,8 +38,15 @@ svg {
|
||||
shape-rendering: crispEdges;
|
||||
}
|
||||
|
||||
rect {
|
||||
stroke-width: 0px;
|
||||
rect{fill:red;
|
||||
stroke:none;
|
||||
shape-rendering:crispEdges;
|
||||
}
|
||||
|
||||
svg {
|
||||
margin: 1.5em auto;
|
||||
max-width: 100%;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.axis path,
|
||||
|
||||
+8
-4
@@ -1340,6 +1340,8 @@ def edit_event(request):
|
||||
IntervLabel = intervention.replace('_',' ').lower()
|
||||
if intervention=='Conference':
|
||||
IntervLabel = u'conférence'
|
||||
elif intervention=='Table_ronde':
|
||||
IntervLabel = u'Table ronde'
|
||||
# Check intervention
|
||||
if not intervention in ['Stand', 'Table_ronde', 'Atelier', 'Conference', 'Concert']:
|
||||
raise HTTPNotFound(u"Ce type d'évenement n'est pas reconnu")
|
||||
@@ -1467,11 +1469,13 @@ def edit_event(request):
|
||||
TheEvent.end_time = TheEvent.start_time + datetime.timedelta(minutes=form.duration.data)
|
||||
# Ok, time to put in database
|
||||
if not form._fields.has_key("uid"):
|
||||
TheEvent.slug = slugify(TheEvent.name)
|
||||
TheEvent.slug = unicode(slugify(TheEvent.name))
|
||||
if intervention==u"Table_ronde":
|
||||
TheEvent.event_type = "Table ronde"
|
||||
DBSession.add(TheEvent)
|
||||
# Append creator by default
|
||||
if request.user.uid!=1:
|
||||
uev = User_Event(year_uid=TheYear.year_uid, role="Animateur")
|
||||
uev = User_Event(year_uid=TheYear.year_uid, role=u"Animateur")
|
||||
uev.user_uid = request.user.uid
|
||||
TheEvent.interventions.append( uev )
|
||||
DBSession.flush()
|
||||
@@ -1482,13 +1486,13 @@ def edit_event(request):
|
||||
if slugify(TheEvent.name)!=TheEvent.slug:
|
||||
# We should move some file as slug have been changed
|
||||
# First we ensure there is no related event that already exist with that slug
|
||||
CheckEvent = Event.by_slug( slugify(TheEvent.name), year)
|
||||
CheckEvent = Event.by_slug( unicode(slugify(TheEvent.name)), year)
|
||||
if CheckEvent:
|
||||
request.session.flash(('warning',u'Choisissez un autre titre pour votre évenement, il est en conflit avec un autre.'))
|
||||
return {'event':TheEvent, 'form':form, 'formAdd':formAdd, 'formAddT':formAddT, 'Salles':Salles }
|
||||
else:
|
||||
SRCPath = path.join('jm2l/upload', *(IMAGEPATH + ['event'] + [ str(year) ] + [ TheEvent.slug ]) )
|
||||
TheEvent.slug=slugify(TheEvent.name)
|
||||
TheEvent.slug=unicode(slugify(TheEvent.name))
|
||||
DSTPath = path.join('jm2l/upload', *(IMAGEPATH + ['event'] + [ str(year) ] + [ TheEvent.slug ]) )
|
||||
if not path.isdir(path.dirname(DSTPath)):
|
||||
makedirs(path.dirname(DSTPath))
|
||||
|
||||
Reference in New Issue
Block a user