From 9570b10f9db9f14c489090bb1349363ba7c4a8af Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 10 Jun 2021 01:32:05 -0400 Subject: [PATCH] Shortened code for check in/out. Swapped key/item values in barcode dictionary. --- main.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/main.py b/main.py index 3167a36..d62e91f 100644 --- a/main.py +++ b/main.py @@ -100,7 +100,7 @@ async def checkin(BookCase: str = Form(...), Shelf: str = Form(...)): @app.post('/barcodes') async def barcodes(userid: int = Form(...)): - barcode = {'CheckIn': 'Check In', 'CheckOut': 'Check Out'} + barcode = {'Check In': 'CI', 'Check Out': 'CO'} pdf = FPDF() try: @@ -113,17 +113,17 @@ async def barcodes(userid: int = Form(...)): result = session.query(Location).filter(Location.userid == userid) for each in result: - code = (each.Bookcase + each.Shelf).replace(' ','') + code = str(each.id) display = each.Bookcase + ' - ' + each.Shelf - barcode['Loc.' + code] = display + barcode[display] = 'Loc.' + code for each in barcode: pdf.set_font('barcode', '', 25) - pdf.cell(0, 5, '*'+each+'$M*') - w = pdf.get_string_width('*'+each+'$M*') + pdf.cell(0, 5, '*'+barcode[each]+'$M*') + w = pdf.get_string_width('*'+barcode[each]+'$M*') pdf.ln() pdf.set_font('Arial', '', 5) - pdf.cell(w, 5, barcode[each], align='C') + pdf.cell(w, 5, each, align='C') pdf.ln() pdf.ln()