From 9fc7fd2f0541994053af6262d708660a3774a556 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Thu, 1 Jul 2010 14:44:18 +0200 Subject: [PATCH] better director grouping --- pandora/backend/views.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pandora/backend/views.py b/pandora/backend/views.py index 525534b..9d9d120 100644 --- a/pandora/backend/views.py +++ b/pandora/backend/views.py @@ -188,9 +188,13 @@ Positions 'country': models.Country.objects, 'genre': models.Genre.objects, 'language': models.Language.objects, - 'director': models.Person.objects.filter(cast__role='directors'), + 'director': models.Cast.objects.filter(role='directors'), } - if query['group'] in _objects: + if query['group'] == "director": + qs = _objects[query['group']].filter(movie__id__in=movie_qs).values('person__name').annotate(movies=Count('person__id')).order_by() + name = 'person__name' + + elif query['group'] in _objects: qs = _objects[query['group']].filter(movies__id__in=movie_qs).values('name').annotate(movies=Count('movies')) elif query['group'] == "year": qs = models.MovieSort.objects.filter(movie__id__in=movie_qs).values('year').annotate(movies=Count('year')) @@ -199,7 +203,7 @@ Positions for i in range(0, len(query['sort'])): if query['sort'][i]['key'] == 'name': if query['group'] in ('director', ): - query['sort'][i]['key'] = name+'_sort' + query['sort'][i]['key'] = 'person__name_sort' else: query['sort'][i]['key'] = name if query['sort'][i]['key'] == 'items':