client-barcode: Move from product ids to product barcodes
This commit is contained in:
parent
dd224f42f6
commit
83ac56d9e4
|
@ -132,12 +132,12 @@ class Status:
|
|||
# Logout
|
||||
self._reset()
|
||||
|
||||
def find(self, item_id):
|
||||
def find(self, barcode):
|
||||
try:
|
||||
return self.item_cache[item_id]
|
||||
return self.item_cache[barcode]
|
||||
except KeyError:
|
||||
item = net.get_item(item_id)
|
||||
self.item_cache[item_id] = item
|
||||
item = net.get_item(barcode)
|
||||
self.item_cache[barcode] = item
|
||||
return item
|
||||
|
||||
def buy(self, item):
|
||||
|
@ -178,9 +178,8 @@ def handle(line, status):
|
|||
params = call[1:]
|
||||
getattr(status, method)(*params)
|
||||
else:
|
||||
item_id = int(line) # TODO
|
||||
try:
|
||||
item = status.find(item_id)
|
||||
item = status.find(line)
|
||||
except urllib2.HTTPError as e:
|
||||
if e.code == 404: # URL not found == item not found with REST
|
||||
error_page('FEHLER: Aktion oder Ware "%s" nicht bekannt' % line)
|
||||
|
|
|
@ -60,11 +60,9 @@ def buy_item(item_id, user_name):
|
|||
raise ValueError('Server says "%s"' % content)
|
||||
|
||||
|
||||
def get_item(item_id):
|
||||
require_type(int, item_id)
|
||||
|
||||
content = _request('buyable/item/' + urllib.quote(str(item_id)),
|
||||
{}, method='GET')
|
||||
def get_item(barcode):
|
||||
content = _request('buyable/item/',
|
||||
{'barcode':barcode}, method='GET')
|
||||
d = json.loads(content)
|
||||
return Item(d)
|
||||
|
||||
|
|
Loading…
Reference in New Issue