From ebcd4198549a33c8e5b8af3b65dedf932c1a3249 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Mon, 22 Dec 2014 10:29:27 +0000 Subject: [PATCH] rename api, sortName->getSortName; add getSortTitle: fixes #2605 --- pandora/person/views.py | 4 ++-- pandora/title/views.py | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/pandora/person/views.py b/pandora/person/views.py index fb6081f97..0dff6abc4 100644 --- a/pandora/person/views.py +++ b/pandora/person/views.py @@ -43,7 +43,7 @@ def editName(request, data): return render_to_json_response(response) actions.register(editName, cache=False) -def sortName(request, data): +def getSortName(request, data): ''' Gets the sort name for one or more names takes { @@ -64,7 +64,7 @@ def sortName(request, data): for name in names: response['data'][name] = models.get_name_sort(name) return render_to_json_response(response) -actions.register(sortName, cache=False) +actions.register(getSortName, cache=False) def parse_query(data, user): query = {} diff --git a/pandora/title/views.py b/pandora/title/views.py index e9bdd581d..3f9df607c 100644 --- a/pandora/title/views.py +++ b/pandora/title/views.py @@ -43,6 +43,29 @@ def editTitle(request, data): return render_to_json_response(response) actions.register(editTitle, cache=False) +def getSortTitle(request, data): + ''' + Gets the sort title for one or more titles + takes { + title: string, // either title + titles: [string] // or list of titles + } + returns { + title: sortTitle, // sort title for this title + ... // more results + } + see: editTitle, findTitles + ''' + titles = data.get('titles', []) + if 'title' in data: + titles.append(data['title']) + response = json_response() + response['data'] = {} + for title in titles: + response['data'][title] = models.get_title_sort(title) + return render_to_json_response(response) +actions.register(getSortTitle, cache=False) + def parse_query(data, user): query = {} query['range'] = [0, 100]