client-barcode: Allow showing product info without log-in (bug #202)
Log-in is tried first so if someone's code matches a product he can still log in
This commit is contained in:
parent
0aad574f60
commit
d468585069
|
@ -263,6 +263,30 @@ def error_page(error_message, hint_message=None):
|
|||
delay('Weiter', delay_seconds)
|
||||
|
||||
|
||||
def item_info_page(item):
|
||||
indent = 4 * ' '
|
||||
|
||||
clear()
|
||||
print('Diese Ware heißt')
|
||||
print()
|
||||
print(indent + COLOR_SOME + item.name + COLOR_RESET)
|
||||
print()
|
||||
print('und kostet')
|
||||
print()
|
||||
if item.deposit > 0:
|
||||
print(indent + '%s%4.2f Euro%s (plus %4.2f Euro Pfand) .' \
|
||||
% (COLOR_MUCH, item.price, COLOR_RESET, item.deposit))
|
||||
else:
|
||||
print(indent + '%s%4.2f Euro%s .' \
|
||||
% (COLOR_MUCH, item.price, COLOR_RESET))
|
||||
print()
|
||||
print()
|
||||
print(COLOR_MUCH + 'Zum Kaufen bitte einloggen.' + COLOR_RESET)
|
||||
print()
|
||||
|
||||
delay('Weiter', 3)
|
||||
|
||||
|
||||
class Status:
|
||||
def __init__(self):
|
||||
self._reset()
|
||||
|
@ -552,12 +576,22 @@ def handle(line, status):
|
|||
status.login(line)
|
||||
except urllib2.HTTPError as e:
|
||||
if e.code == 404: # URL not found == user unknown
|
||||
# Try same code as a product
|
||||
item = None
|
||||
try:
|
||||
item = status.find(line)
|
||||
except urllib2.HTTPError as e:
|
||||
pass
|
||||
|
||||
if item is None:
|
||||
display_screen("FEHLER","Nutzer ist unbekannt: '%s' *** " % line)
|
||||
|
||||
error_page('FEHLER: Benutzer "%s" nicht bekannt' % line,
|
||||
error_page('FEHLER: Produkt oder Nutzer "%s" nicht bekannt' % line,
|
||||
hint_message='Ist in der WebApp unter "Einstellungen" ' \
|
||||
'für Ihren Account Plugin "BarcodePlugin" ' \
|
||||
'als erlaubt markiert?')
|
||||
else:
|
||||
item_info_page(item)
|
||||
else:
|
||||
print_display('\x0cFEHLER: Server Error%20s' % str(e)[:20])
|
||||
error_page('FEHLER bei Kommunikation mit Server "%s"' % str(e))
|
||||
|
|
Loading…
Reference in New Issue