From bfb7bd88ba3bb9658095dffb81f7d3616bb5f882 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Tue, 11 Oct 2011 19:44:45 +0200 Subject: [PATCH] sort sort --- README | 2 ++ pandora/person/models.py | 5 +++++ pandora/person/views.py | 1 + pandora/title/models.py | 4 ++++ pandora/title/views.py | 1 + 5 files changed, 13 insertions(+) diff --git a/README b/README index 70003b9a8..e2e9576a3 100644 --- a/README +++ b/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 diff --git a/pandora/person/models.py b/pandora/person/models.py index fc604acc5..1384e74d9 100644 --- a/pandora/person/models.py +++ b/pandora/person/models.py @@ -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) diff --git a/pandora/person/views.py b/pandora/person/views.py index bda9a0fe6..ad02d46a2 100644 --- a/pandora/person/views.py +++ b/pandora/person/views.py @@ -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) diff --git a/pandora/title/models.py b/pandora/title/models.py index 63c04740d..c3b36aca3 100644 --- a/pandora/title/models.py +++ b/pandora/title/models.py @@ -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): diff --git a/pandora/title/views.py b/pandora/title/views.py index 43eab0252..0a43c9ac4 100644 --- a/pandora/title/views.py +++ b/pandora/title/views.py @@ -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)