"list staffers pdf"
This commit is contained in:
parent
1cf5300441
commit
3dc909efe0
168
participate.py
168
participate.py
@ -1057,92 +1057,92 @@ def list_users():
|
|||||||
@check_session
|
@check_session
|
||||||
def print_users():
|
def print_users():
|
||||||
""" Print user list """
|
""" Print user list """
|
||||||
message = ''
|
message = check_user_info()
|
||||||
try:
|
#~ try:
|
||||||
if session['is_admin']:
|
if session['is_admin']:
|
||||||
page = str(request.url_rule)
|
page = str(request.url_rule)
|
||||||
menu = get_menu(page)
|
menu = get_menu(page)
|
||||||
staffers = Tetawebapp_users.query.filter(Tetawebapp_users.is_admin==0, Tetawebapp_users.link_id==None).order_by(Tetawebapp_users.name).all()
|
staffers = Tetawebapp_users.query.filter(Tetawebapp_users.is_admin==0, Tetawebapp_users.link_id==None).order_by(Tetawebapp_users.name).all()
|
||||||
pdf = cStringIO.StringIO()
|
pdf = cStringIO.StringIO()
|
||||||
cols_width = 585
|
cols_width = 585
|
||||||
doc = SimpleDocTemplate(pdf, pagesize=A4, rightMargin=3,leftMargin=3, topMargin=3,bottomMargin=3)
|
doc = SimpleDocTemplate(pdf, pagesize=A4, rightMargin=3,leftMargin=3, topMargin=3,bottomMargin=3)
|
||||||
elements = []
|
elements = []
|
||||||
styles = getSampleStyleSheet()
|
styles = getSampleStyleSheet()
|
||||||
styles.add(ParagraphStyle(name='master_title',
|
styles.add(ParagraphStyle(name='master_title',
|
||||||
alignment=TA_LEFT,
|
alignment=TA_LEFT,
|
||||||
fontSize=20,
|
fontSize=20,
|
||||||
leading=25,
|
leading=25,
|
||||||
spaceBefore=10,
|
spaceBefore=10,
|
||||||
spaceAfter=10,
|
spaceAfter=10,
|
||||||
))
|
))
|
||||||
styles.add(ParagraphStyle(name='day_title',
|
styles.add(ParagraphStyle(name='day_title',
|
||||||
alignment=TA_LEFT,
|
alignment=TA_LEFT,
|
||||||
backColor=orange,
|
backColor=orange,
|
||||||
borderWidth=1,
|
borderWidth=1,
|
||||||
borderColor=black,
|
borderColor=black,
|
||||||
borderPadding=5,
|
borderPadding=5,
|
||||||
spaceBefore=10,
|
spaceBefore=10,
|
||||||
spaceAfter=10
|
spaceAfter=10
|
||||||
))
|
))
|
||||||
styles.add(ParagraphStyle(name='role_title',
|
styles.add(ParagraphStyle(name='role_title',
|
||||||
alignment=TA_LEFT,
|
alignment=TA_LEFT,
|
||||||
backColor=lightsalmon,
|
backColor=lightsalmon,
|
||||||
borderWidth=1,
|
borderWidth=1,
|
||||||
borderColor=black,
|
borderColor=black,
|
||||||
borderPadding=5,
|
borderPadding=5,
|
||||||
spaceBefore=10,
|
spaceBefore=10,
|
||||||
spaceAfter=10
|
spaceAfter=10
|
||||||
))
|
))
|
||||||
styles.add(ParagraphStyle(name='turn',
|
styles.add(ParagraphStyle(name='turn',
|
||||||
alignment=TA_LEFT,
|
alignment=TA_LEFT,
|
||||||
backColor=white,
|
backColor=white,
|
||||||
borderWidth=1,
|
borderWidth=1,
|
||||||
borderColor=black,
|
borderColor=black,
|
||||||
borderPadding=5,
|
borderPadding=5,
|
||||||
spaceBefore=10,
|
spaceBefore=10,
|
||||||
spaceAfter=0
|
spaceAfter=0
|
||||||
))
|
))
|
||||||
styles.add(ParagraphStyle(name='basic_text',
|
styles.add(ParagraphStyle(name='basic_text',
|
||||||
alignment=TA_LEFT,
|
alignment=TA_LEFT,
|
||||||
spaceBefore=5,
|
spaceBefore=5,
|
||||||
spaceAfter=5
|
spaceAfter=5
|
||||||
))
|
))
|
||||||
styles.add(ParagraphStyle(name='row1',
|
styles.add(ParagraphStyle(name='row1',
|
||||||
alignment=TA_LEFT,
|
alignment=TA_LEFT,
|
||||||
backColor=white,
|
backColor=white,
|
||||||
spaceBefore=10,
|
spaceBefore=10,
|
||||||
spaceAfter=10
|
spaceAfter=10
|
||||||
))
|
))
|
||||||
styles.add(ParagraphStyle(name='row2',
|
styles.add(ParagraphStyle(name='row2',
|
||||||
alignment=TA_CENTER,
|
alignment=TA_CENTER,
|
||||||
backColor=white,
|
backColor=white,
|
||||||
spaceBefore=10,
|
spaceBefore=10,
|
||||||
spaceAfter=10
|
spaceAfter=10
|
||||||
))
|
))
|
||||||
|
|
||||||
rows = []
|
rows = []
|
||||||
for staffer in staffers:
|
for staffer in staffers:
|
||||||
row = (Paragraph(staffer.name, styles['row2']), Paragraph(staffer.phone, styles['row2']), Paragraph(staffer.diet, styles['row2']))
|
row = (Paragraph(staffer.name, styles['row2']), Paragraph(staffer.phone, styles['row2']), Paragraph(staffer.diet, styles['row2']))
|
||||||
rows.append(row)
|
rows.append(row)
|
||||||
|
|
||||||
table = Table(rows, colWidths=cols_width, rowHeights=23)
|
table = Table(rows, colWidths=cols_width, rowHeights=23)
|
||||||
table.setStyle(TableStyle( [('GRID', (0,0), (-1,-1), 0.25, colors.black),
|
table.setStyle(TableStyle( [('GRID', (0,0), (-1,-1), 0.25, colors.black),
|
||||||
('ALIGN', (1,1), (-1,-1), 'RIGHT')]))
|
('ALIGN', (1,1), (-1,-1), 'RIGHT')]))
|
||||||
elements.append(table)
|
elements.append(table)
|
||||||
styles.wordWrap = 'CJK'
|
styles.wordWrap = 'CJK'
|
||||||
doc.build(elements)
|
doc.build(elements)
|
||||||
pdf_out = pdf.getvalue()
|
pdf_out = pdf.getvalue()
|
||||||
pdf.close()
|
pdf.close()
|
||||||
response = app.make_response(pdf_out)
|
response = app.make_response(pdf_out)
|
||||||
response.headers['Content-Disposition'] = "attachment; filename=feuille_staff_thsf.pdf"
|
response.headers['Content-Disposition'] = "attachment; filename=feuille_staff_thsf.pdf"
|
||||||
response.mimetype = 'application/pdf'
|
response.mimetype = 'application/pdf'
|
||||||
return response
|
return response
|
||||||
# User is not admin
|
#~ # User is not admin
|
||||||
return render_template('login_or_register.html', message="Utilisateur ou mot de passe invalide")
|
#~ return render_template('login_or_register.html', message="Utilisateur ou mot de passe invalide")
|
||||||
except Exception as e:
|
#~ except Exception as e:
|
||||||
raise e
|
#~ raise e
|
||||||
# User is not logged in
|
#~ # User is not logged in
|
||||||
return render_template('login_or_register.html', message="%s" % e)
|
#~ return render_template('login_or_register.html', message="%s" % e)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/account/<ID>", methods=['GET', 'POST'])
|
@app.route("/account/<ID>", methods=['GET', 'POST'])
|
||||||
|
Loading…
Reference in New Issue
Block a user