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