From 9f6be94ea8d8a710ec0eea97c9be901e635c45e9 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sat, 4 Jun 2011 18:15:38 +0200 Subject: [PATCH] lookup --- pandora/item/views.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/pandora/item/views.py b/pandora/item/views.py index 6fea29ba6..da4116e0f 100644 --- a/pandora/item/views.py +++ b/pandora/item/views.py @@ -464,6 +464,36 @@ def setPoster(request): #parse path and return info return render_to_json_response(response) actions.register(setPoster, cache=False) +def lookup(request): + ''' + param data { + title: string, + director: [string], + year: string, + id: string + } + return { + status: {'code': int, 'text': string}, + data: { + title: string, + director: [string], + year: string, + id: string + } + } + ''' + data = json.loads(request.POST['data']) + if 'id' in data: + i = models.Item.objects.get(itemId=data['id']) + r = {'id': i.itemId} + for key in ('title', 'director', 'year'): + r[key] = i.get(key) + response = json_response(r) + else: + response = json_response(status=404, text='not found') + return render_to_json_response(response) +actions.register(lookup) + def getImdbId(request): ''' param data {