From 27dca66a0f71e5ac8ee52ebdaecac64cbdab64cb Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sun, 24 Sep 2023 17:45:33 -0500 Subject: [PATCH] Cleanup the dev startup logic a bit --- wuttapos/app.py | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/wuttapos/app.py b/wuttapos/app.py index dd4b410..e0139b6 100644 --- a/wuttapos/app.py +++ b/wuttapos/app.py @@ -65,18 +65,31 @@ def main(page: ft.Page): handler = app.get_batch_handler('pos') session = app.make_session() user = session.get(model.User, page.shared['user_uuid']) - # TODO: should also filter this by terminal - batch = handler.get_current_batch(user, create=False) - if batch: - page.shared['txn_display'] = batch.id_str - page.shared['cust_uuid'] = batch.customer_uuid - if batch.customer: - key = app.get_customer_key_field() - value = getattr(batch.customer, key) - page.shared['cust_display'] = str(value or '') or None + if user: + # TODO: should also filter this by terminal + batch = handler.get_current_batch(user, create=False) + if batch: + page.shared['txn_display'] = batch.id_str + page.shared['cust_uuid'] = batch.customer_uuid + if batch.customer: + key = app.get_customer_key_field() + value = getattr(batch.customer, key) + page.shared['cust_display'] = str(value or '') or None + else: + page.shared['cust_display'] = None else: + page.shared['txn_display'] = None + page.shared['cust_uuid'] = None page.shared['cust_display'] = None + else: + page.shared['user_uuid'] = None + page.shared['user_display'] = None + page.shared['txn_display'] = None + page.shared['cust_uuid'] = None + page.shared['cust_display'] = None session.close() + else: + page.shared['user_display'] = None def clean_exit(): if not config.production():