Glemte å legge til pdf.py
This commit is contained in:
parent
8621e07dcf
commit
c4e2178c03
29
otime/pdf.py
29
otime/pdf.py
@ -1,22 +1,31 @@
|
|||||||
|
import datetime
|
||||||
from fpdf import FPDF
|
from fpdf import FPDF
|
||||||
|
|
||||||
def create_start_list(event, file_path):
|
def create_result_list(event, file_path, o_classes=[]):
|
||||||
pdf = FPDF()
|
results = event.get_result(o_classes)
|
||||||
|
|
||||||
|
pdf = FPDF()
|
||||||
pdf.add_page()
|
pdf.add_page()
|
||||||
pdf.add_font("LiberationSans", fname="../../otime/data/fonts/LiberationSans-Regular.ttf")
|
pdf.add_font("LiberationSans", fname="../../otime/data/fonts/LiberationSans-Regular.ttf")
|
||||||
pdf.set_font("LiberationSans", size=10)
|
pdf.set_font("LiberationSans", size=10)
|
||||||
line_height = pdf.font_size * 1.5
|
line_height = pdf.font_size * 1.5
|
||||||
col_width = pdf.epw / 4 # distribute content evenly
|
col_width = pdf.epw / 4 # distribute content evenly
|
||||||
for runner in event.runners:
|
|
||||||
pdf.multi_cell(col_width, line_height, runner.fullname(), border=1, ln=3, max_line_height=pdf.font_size, align='L')
|
for class_result in results:
|
||||||
pdf.multi_cell(col_width, line_height, runner.o_class, border=1, ln=3, max_line_height=pdf.font_size)
|
pdf.write(txt=class_result.name)
|
||||||
pdf.multi_cell(col_width, line_height, str(runner.card_id), border=1, ln=3, max_line_height=pdf.font_size)
|
|
||||||
if runner.start_time is not None:
|
|
||||||
pdf.multi_cell(col_width, line_height, str(runner.start_time), border=1, ln=3, max_line_height=pdf.font_size)
|
|
||||||
else:
|
|
||||||
pdf.multi_cell(col_width, line_height, '', border=1, ln=3, max_line_height=pdf.font_size)
|
|
||||||
pdf.ln(line_height)
|
pdf.ln(line_height)
|
||||||
|
for runner in class_result.runner_results:
|
||||||
|
if runner.status == 'OK':
|
||||||
|
pdf.multi_cell(col_width, line_height, str(runner.place), border=1, ln=3, max_line_height=pdf.font_size, align='L')
|
||||||
|
else:
|
||||||
|
pdf.multi_cell(col_width, line_height, runner.status, border=1, ln=3, max_line_height=pdf.font_size, align='L')
|
||||||
|
pdf.multi_cell(col_width, line_height, runner.fullname(), border=1, ln=3, max_line_height=pdf.font_size, align='L')
|
||||||
|
pdf.multi_cell(col_width, line_height, runner.club, border=1, ln=3, max_line_height=pdf.font_size)
|
||||||
|
if runner.status == 'OK':
|
||||||
|
pdf.multi_cell(col_width, line_height, str(datetime.timedelta(seconds = runner.total_time)), border=1, ln=3, max_line_height=pdf.font_size)
|
||||||
|
else:
|
||||||
|
pdf.multi_cell(col_width, line_height, '', border=1, ln=3, max_line_height=pdf.font_size)
|
||||||
|
pdf.ln(line_height)
|
||||||
pdf.output(file_path)
|
pdf.output(file_path)
|
||||||
|
|
||||||
def create_all_invoices(self, filename_prefix):
|
def create_all_invoices(self, filename_prefix):
|
||||||
|
Loading…
Reference in New Issue
Block a user