sort sort
This commit is contained in:
parent
31ca407a17
commit
bfb7bd88ba
5 changed files with 13 additions and 0 deletions
2
README
2
README
|
@ -33,6 +33,8 @@ you need python, bazaar, pip and virtualenv and several other python modules:
|
|||
and run ./manage.py syncdb to populate the database
|
||||
you might want to load example configurations from fixutes.
|
||||
|
||||
createdb --locale=C --encoding=UTF8 pandora
|
||||
|
||||
* RabbitMQ
|
||||
For background tasks we use RabbitMQ, to install rabbitmq:
|
||||
sudo apt-get install rabbitmq-server
|
||||
|
|
|
@ -9,8 +9,11 @@ from django.db import models
|
|||
from ox.django import fields
|
||||
import ox
|
||||
|
||||
from item import utils
|
||||
|
||||
import managers
|
||||
|
||||
|
||||
def get_name_sort(name):
|
||||
person, created = Person.objects.get_or_create(name=name)
|
||||
sortname = unicodedata.normalize('NFKD', person.sortname)
|
||||
|
@ -19,6 +22,7 @@ def get_name_sort(name):
|
|||
class Person(models.Model):
|
||||
name = models.CharField(max_length=200, unique=True)
|
||||
sortname = models.CharField(max_length=200)
|
||||
sortsortname = models.CharField(max_length=200)
|
||||
edited = models.BooleanField(default=False)
|
||||
numberofnames = models.IntegerField(default=0)
|
||||
|
||||
|
@ -37,6 +41,7 @@ class Person(models.Model):
|
|||
if not self.sortname:
|
||||
self.sortname = ox.get_sort_name(self.name)
|
||||
self.sortname = unicodedata.normalize('NFKD', self.sortname)
|
||||
self.sortsortname = utils.sort_string(self.sortname)
|
||||
self.numberofnames = len(self.name.split(' '))
|
||||
super(Person, self).save(*args, **kwargs)
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@ def order_query(qs, sort):
|
|||
if operator != '-':
|
||||
operator = ''
|
||||
key = {
|
||||
'sortname': 'sortsortname'
|
||||
}.get(e['key'], e['key'])
|
||||
order = '%s%s' % (operator, key)
|
||||
order_by.append(order)
|
||||
|
|
|
@ -8,6 +8,8 @@ from django.db import models
|
|||
|
||||
import ox
|
||||
|
||||
from item import utils
|
||||
|
||||
import managers
|
||||
|
||||
def get_title_sort(title):
|
||||
|
@ -18,6 +20,7 @@ def get_title_sort(title):
|
|||
class Title(models.Model):
|
||||
title = models.CharField(max_length=1000, unique=True)
|
||||
sorttitle = models.CharField(max_length=1000)
|
||||
sortsorttitle = models.CharField(max_length=1000)
|
||||
edited = models.BooleanField(default=False)
|
||||
|
||||
imdbId = models.CharField(max_length=7, blank=True)
|
||||
|
@ -31,6 +34,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)
|
||||
super(Title, self).save(*args, **kwargs)
|
||||
|
||||
def get_or_create(model, title, imdbId=None):
|
||||
|
|
|
@ -57,6 +57,7 @@ def order_query(qs, sort):
|
|||
if operator != '-':
|
||||
operator = ''
|
||||
key = {
|
||||
'sorttitle': 'sortsorttitle'
|
||||
}.get(e['key'], e['key'])
|
||||
order = '%s%s' % (operator, key)
|
||||
order_by.append(order)
|
||||
|
|
Loading…
Reference in a new issue