Minor template refactor and cli.py user interface enhancement #5
13
web.py
13
web.py
|
@ -119,23 +119,28 @@ def sell_page():
|
|||
title='Sell', event=event, products=products)
|
||||
|
||||
|
||||
def print_orders(event, orders):
|
||||
def print_orders(transaction, cat, orders):
|
||||
printer.open()
|
||||
|
||||
printer.set(align='CENTER')
|
||||
printer.image('static/img/macao-logo-printer.png', impl='bitImageColumn')
|
||||
|
||||
printer.set(align='CENTER', text_type='B')
|
||||
printer.text(event.name.upper())
|
||||
printer.text(transaction.event.name.upper())
|
||||
printer.text("\n\n")
|
||||
|
||||
for o in orders:
|
||||
printer.set(align='LEFT', width=2, height=2)
|
||||
printer.text("{} x {}".format(o.quantity, o.product.name.upper()))
|
||||
printer.text("\n")
|
||||
|
||||
printer.text("\n")
|
||||
|
||||
printer.set(align='RIGHT')
|
||||
printer.text("{} #{}-{}-{}"
|
||||
.format(datetime.strftime(transaction.created_at,
|
||||
"%Y-%m-%d %H:%M"),
|
||||
transaction.event.uid, transaction.uid, cat))
|
||||
|
||||
printer.cut()
|
||||
printer.close()
|
||||
sleep(0.7)
|
||||
|
@ -153,7 +158,7 @@ def print_transaction(transaction):
|
|||
categorized_orders[uid].append(o)
|
||||
|
||||
for cat, orders in categorized_orders.items():
|
||||
print_orders(transaction.event, orders)
|
||||
print_orders(transaction, cat, orders)
|
||||
|
||||
|
||||
@app.route('/sell', methods=['POST'])
|
||||
|
|
Loading…
Reference in New Issue
Block a user