Shortened code for check in/out. Swapped key/item values in barcode dictionary.

This commit is contained in:
dan
2021-06-10 01:32:05 -04:00
parent 135a1c474b
commit 9570b10f9d

12
main.py
View File

@@ -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()