From 536834a03c7aaa7c384186b9722ef91ab232be33 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Tue, 16 Dec 2014 15:46:04 +0000 Subject: [PATCH] use name sort for entities if sortType is person --- pandora/entity/models.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pandora/entity/models.py b/pandora/entity/models.py index f49768e1..527f7790 100644 --- a/pandora/entity/models.py +++ b/pandora/entity/models.py @@ -15,6 +15,8 @@ from django.conf import settings import ox from ox.django import fields +from person.models import get_name_sort +from item.utils import get_by_id import managers @@ -42,7 +44,11 @@ class Entity(models.Model): def save(self, *args, **kwargs): - self.name_sort = ox.sort_string(self.name or u'')[:255].lower() + entity = get_by_id(settings.CONFIG['entities']) + 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_find = '||' + self.name + '||'.join(self.alternativeNames) + '||' super(Entity, self).save(*args, **kwargs) self.update_matches()