forked from 0x2620/pandora
title refinement
This commit is contained in:
parent
04acc3c6f3
commit
2692300f3b
5 changed files with 19 additions and 10 deletions
|
@ -619,7 +619,7 @@ class Item(models.Model):
|
|||
if name not in base_keys:
|
||||
if sort_type == 'title':
|
||||
value = get_title_sort(self.get(source, u'Untitled'))
|
||||
value = utils.sort_string(value)[:955]
|
||||
value = utils.sort_title(value)[:955]
|
||||
set_value(s, name, value)
|
||||
elif sort_type == 'person':
|
||||
value = sortNames(self.get(source, []))
|
||||
|
|
|
@ -201,14 +201,14 @@ def sort_string(string):
|
|||
|
||||
|
||||
def sort_title(title):
|
||||
#title
|
||||
title = re.sub(u'[\'!¿¡,\.;\-"\:\*\[\]]', '', title)
|
||||
|
||||
#title = title.replace(u'Æ', 'Ae')
|
||||
if isinstance(title, str):
|
||||
title = unicode(title)
|
||||
title = sort_string(title)
|
||||
|
||||
#title
|
||||
title = re.sub(u'[\'!¿¡,\.;\-"\:\*\[\]]', '', title)
|
||||
return title.strip()
|
||||
|
||||
def get_positions(ids, pos):
|
||||
|
|
|
@ -15,9 +15,12 @@ import managers
|
|||
|
||||
|
||||
def get_name_sort(name):
|
||||
name = unicodedata.normalize('NFKD', name)
|
||||
name = unicodedata.normalize('NFKD', name).strip()
|
||||
if name:
|
||||
person, created = Person.objects.get_or_create(name=name)
|
||||
sortname = unicodedata.normalize('NFKD', person.sortname)
|
||||
else:
|
||||
sortname = u''
|
||||
return sortname
|
||||
|
||||
class Person(models.Model):
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
import unicodedata
|
||||
from django.db.models import Q, Manager
|
||||
from ox.django.query import QuerySet
|
||||
import ox
|
||||
|
@ -41,6 +42,8 @@ def parseCondition(condition, user):
|
|||
return q
|
||||
if k == 'id':
|
||||
v = ox.from26(v)
|
||||
elif isinstance(v, unicode):
|
||||
v = unicodedata.normalize('NFKD', v)
|
||||
if isinstance(v, bool): #featured and public flag
|
||||
key = k
|
||||
elif k in ('lat', 'lng', 'area', 'south', 'west', 'north', 'east', 'matches', 'id'):
|
||||
|
|
|
@ -13,9 +13,12 @@ from item import utils
|
|||
import managers
|
||||
|
||||
def get_title_sort(title):
|
||||
title = unicodedata.normalize('NFKD', title)
|
||||
title = unicodedata.normalize('NFKD', title).strip()
|
||||
if title:
|
||||
title, created = Title.objects.get_or_create(title=title)
|
||||
sorttitle = unicodedata.normalize('NFKD', title.sorttitle)
|
||||
else:
|
||||
sorttitle = u''
|
||||
return sorttitle
|
||||
|
||||
class Title(models.Model):
|
||||
|
@ -35,7 +38,7 @@ class Title(models.Model):
|
|||
if not self.sorttitle:
|
||||
self.sorttitle = ox.get_sort_title(self.title)
|
||||
self.sorttitle = unicodedata.normalize('NFKD', self.sorttitle)
|
||||
self.sortsorttitle = utils.sort_string(self.sorttitle)
|
||||
self.sortsorttitle = utils.sort_title(self.sorttitle)
|
||||
super(Title, self).save(*args, **kwargs)
|
||||
|
||||
def get_or_create(model, title, imdbId=None):
|
||||
|
|
Loading…
Reference in a new issue