diff --git a/pandora/item/views.py b/pandora/item/views.py index 2c711f41d..a7b9d55c3 100644 --- a/pandora/item/views.py +++ b/pandora/item/views.py @@ -699,8 +699,21 @@ def lookup(request, data): } see: add, edit, find, get, remove, upload ''' + i = None if 'id' in data: i = models.Item.objects.get(public_id=data['id']) + elif not filter(None, [d not in ('title', 'year', 'director') for d in data.keys()]): + key = data.keys()[0] + value = data[key] + qs = models.Item.objects.find({'query': { + 'conditions': [ + {'key': key, 'value': data[key], 'operator': '=='} for key in data + ], + 'operator': '&' + }}, request.user) + if qs.count() == 1: + i = qs[0] + if i: r = {'id': i.public_id} for key in ('title', 'director', 'year'): r[key] = i.get(key)