use name sort for entities if sortType is person
This commit is contained in:
parent
15fb864d74
commit
536834a03c
1 changed files with 7 additions and 1 deletions
|
@ -15,6 +15,8 @@ from django.conf import settings
|
||||||
import ox
|
import ox
|
||||||
from ox.django import fields
|
from ox.django import fields
|
||||||
|
|
||||||
|
from person.models import get_name_sort
|
||||||
|
from item.utils import get_by_id
|
||||||
import managers
|
import managers
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,6 +44,10 @@ class Entity(models.Model):
|
||||||
|
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
|
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_sort = ox.sort_string(self.name or u'')[:255].lower()
|
||||||
self.name_find = '||' + self.name + '||'.join(self.alternativeNames) + '||'
|
self.name_find = '||' + self.name + '||'.join(self.alternativeNames) + '||'
|
||||||
super(Entity, self).save(*args, **kwargs)
|
super(Entity, self).save(*args, **kwargs)
|
||||||
|
|
Loading…
Reference in a new issue