From 34506d5b9916337cd4e571783049e185a432ac76 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Tue, 16 Dec 2014 17:44:05 +0000 Subject: [PATCH] entity sort name --- pandora/entity/models.py | 5 ++++- pandora/entity/views.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pandora/entity/models.py b/pandora/entity/models.py index c9168680d..041ba46a0 100644 --- a/pandora/entity/models.py +++ b/pandora/entity/models.py @@ -48,7 +48,7 @@ class Entity(models.Model): if entity.get('sortType') == 'person' and self.name: self.name_sort = get_name_sort(self.name)[:255].lower() else: - self.name_sort = ox.sort_string(self.name or u'')[:255].lower() + self.name_sort = ox.sort_string(self.name or u'')[:255].lower() or None self.name_find = '||' + self.name + '||'.join(self.alternativeNames) + '||' super(Entity, self).save(*args, **kwargs) self.update_matches() @@ -123,6 +123,7 @@ class Entity(models.Model): 'editable', 'id', 'name', + 'sortName', 'type', 'user', ] + self.data.keys() @@ -136,6 +137,8 @@ class Entity(models.Model): response[key] = self.user and self.user.username elif key in ('name', 'alternativeNames', 'type'): response[key] = getattr(self, key) + elif key == 'sortName': + response[key] = self.name_sort elif key in self.data: response[key] = self.data[key] return response diff --git a/pandora/entity/views.py b/pandora/entity/views.py index 6f21c7f6c..3b299ec83 100644 --- a/pandora/entity/views.py +++ b/pandora/entity/views.py @@ -184,7 +184,7 @@ def _order_query(qs, sort, item=None): def parse_query(data, user): query = {} query['range'] = [0, 100] - query['sort'] = [{'key':'name', 'operator':'+'}, {'key':'type', 'operator':'+'}] + query['sort'] = [{'key':'name', 'operator':'+'}] for key in ('keys', 'group', 'range', 'position', 'positions', 'sort'): if key in data: query[key] = data[key]