diff --git a/oml/item/api.py b/oml/item/api.py index 4bf1fb6..44162b2 100644 --- a/oml/item/api.py +++ b/oml/item/api.py @@ -217,8 +217,7 @@ actions.register(autocomplete) def findMetadata(data): ''' takes { - key: string, - value: string + key: value, } returns { items: [{ @@ -231,20 +230,21 @@ def findMetadata(data): 'items': [] } logger.debug('findMetadata %s', data) - if data['key'] == 'isbn': - r = meta.lookup(data['key'], data['value']) + key = ','.join(sorted(data)) + if key == 'isbn': + r = meta.lookup(key, data[key]) if r: response['items'].append(r) - elif data['key'] == 'title': - r = meta.find(data['value']) - for isbn in meta.find(data['value']): + elif key == 'author,title': + value = ' '.join(data.values()) + for isbn in meta.find(value): r = meta.lookup('isbn', isbn) if r: response['items'].append(r) - elif data['key'] == 'id': + elif key == 'id': import user.models items = {} - for m in user.models.Metadata.query.filter_by(item_id=data['value']): + for m in user.models.Metadata.query.filter_by(item_id=data[key]): if m.data_hash not in items: items[m.data_hash] = m.data items[m.data_hash]['users'] = [m.user_id]