"list staffers pdf"

This commit is contained in:
Doug Le Tough 2018-05-09 11:05:01 +02:00
parent 0c9187d6e2
commit 5b152a3341
1 changed files with 1 additions and 53 deletions

View File

@ -1063,14 +1063,6 @@ def print_users():
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()
#~ data = render_template('list_users_txt.html', staffers=staffers)
#~ data = [line for line in data.split('\n') if len(line) > 0]
#~ data = '\n'.join(data)
#~ data = [line for line in data.split('",\n') if len(line) > 0]
#~ data = '", '.join(data)
#~ ddata = [ast.literal_eval(line) for line in data.split('\n')]
pdf = cStringIO.StringIO()
cols_width = 585
doc = SimpleDocTemplate(pdf, pagesize=A4, rightMargin=3,leftMargin=3, topMargin=3,bottomMargin=3)
@ -1137,39 +1129,6 @@ def print_users():
table.setStyle(TableStyle( [('GRID', (0,0), (-1,-1), 0.25, colors.black),
('ALIGN', (1,1), (-1,-1), 'RIGHT')]))
elements.append(table)
#~ wday = day[0]
#~ day_turns = day[1]
#~ cur_role = ''
#~ if wday not in ['Mardi', 'Mercredi']:
#~ elements.append(PageBreak())
#~ elements.append(Paragraph("<b>%s</b>" % wday, styles['day_title']))
#~ for turn in day_turns:
#~ rows = []
#~ role = turn[1]
#~ start_time = turn[0].start_time
#~ end_time = turn[0].end_time
#~ num_slot = turn[0].num_slot
#~ role_id = turn[0].role_id
#~ turn_id = turn[0].id
#~ if role != cur_role:
#~ cur_role = role
#~ elements.append(Paragraph("<b>%s</b>" % role, styles['role_title']))
#~ row = (Paragraph("<b>%s / %s</b>" % (start_time.strftime('%HH%M'), end_time.strftime('%HH%M')), styles['row1']),)
#~ for slot in range(0, num_slot):
#~ cols_width = [100] + [485/num_slot] * num_slot
#~ allocated_slot = []
#~ for sslot in staffs:
#~ if sslot[0].turn_id == turn_id and sslot[0].slot_num == slot:
#~ allocated_slot.append(sslot[0].slot_num)
#~ row += (Paragraph(sslot[1], styles['row2']),)
#~ if slot not in allocated_slot:
#~ row += (Paragraph("&nbsp;", 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()
@ -1178,21 +1137,10 @@ def print_users():
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)