Shortened code for check in/out. Swapped key/item values in barcode dictionary.
This commit is contained in:
12
main.py
12
main.py
@@ -100,7 +100,7 @@ async def checkin(BookCase: str = Form(...), Shelf: str = Form(...)):
|
|||||||
|
|
||||||
@app.post('/barcodes')
|
@app.post('/barcodes')
|
||||||
async def barcodes(userid: int = Form(...)):
|
async def barcodes(userid: int = Form(...)):
|
||||||
barcode = {'CheckIn': 'Check In', 'CheckOut': 'Check Out'}
|
barcode = {'Check In': 'CI', 'Check Out': 'CO'}
|
||||||
pdf = FPDF()
|
pdf = FPDF()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -113,17 +113,17 @@ async def barcodes(userid: int = Form(...)):
|
|||||||
result = session.query(Location).filter(Location.userid == userid)
|
result = session.query(Location).filter(Location.userid == userid)
|
||||||
|
|
||||||
for each in result:
|
for each in result:
|
||||||
code = (each.Bookcase + each.Shelf).replace(' ','')
|
code = str(each.id)
|
||||||
display = each.Bookcase + ' - ' + each.Shelf
|
display = each.Bookcase + ' - ' + each.Shelf
|
||||||
barcode['Loc.' + code] = display
|
barcode[display] = 'Loc.' + code
|
||||||
|
|
||||||
for each in barcode:
|
for each in barcode:
|
||||||
pdf.set_font('barcode', '', 25)
|
pdf.set_font('barcode', '', 25)
|
||||||
pdf.cell(0, 5, '*'+each+'$M*')
|
pdf.cell(0, 5, '*'+barcode[each]+'$M*')
|
||||||
w = pdf.get_string_width('*'+each+'$M*')
|
w = pdf.get_string_width('*'+barcode[each]+'$M*')
|
||||||
pdf.ln()
|
pdf.ln()
|
||||||
pdf.set_font('Arial', '', 5)
|
pdf.set_font('Arial', '', 5)
|
||||||
pdf.cell(w, 5, barcode[each], align='C')
|
pdf.cell(w, 5, each, align='C')
|
||||||
pdf.ln()
|
pdf.ln()
|
||||||
pdf.ln()
|
pdf.ln()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user