update item sort after changing person sort value, fixes #30
This commit is contained in:
parent
2cf7c56115
commit
6bdbd729a7
2 changed files with 20 additions and 1 deletions
|
@ -13,7 +13,7 @@ from item import utils
|
||||||
import item.models
|
import item.models
|
||||||
|
|
||||||
import managers
|
import managers
|
||||||
|
import tasks
|
||||||
|
|
||||||
def get_name_sort(name):
|
def get_name_sort(name):
|
||||||
name = unicodedata.normalize('NFKD', name).strip()
|
name = unicodedata.normalize('NFKD', name).strip()
|
||||||
|
@ -51,6 +51,9 @@ class Person(models.Model):
|
||||||
self.sortsortname = utils.sort_string(self.sortname)
|
self.sortsortname = utils.sort_string(self.sortname)
|
||||||
self.numberofnames = len(self.name.split(' '))
|
self.numberofnames = len(self.name.split(' '))
|
||||||
super(Person, self).save(*args, **kwargs)
|
super(Person, self).save(*args, **kwargs)
|
||||||
|
tasks.update_itemsort.delay(self.id)
|
||||||
|
|
||||||
|
def update_itemsort(self):
|
||||||
item.models.Facet.objects.filter(
|
item.models.Facet.objects.filter(
|
||||||
key__in=item.models.Item.person_keys + ['name'],
|
key__in=item.models.Item.person_keys + ['name'],
|
||||||
value=self.name
|
value=self.name
|
||||||
|
@ -59,6 +62,11 @@ class Person(models.Model):
|
||||||
).update(
|
).update(
|
||||||
sortvalue=self.sortname
|
sortvalue=self.sortname
|
||||||
)
|
)
|
||||||
|
for i in item.models.Item.objects.filter(facets__in=item.models.Facet.objects.filter(
|
||||||
|
key__in=item.models.Item.person_keys + ['name'],
|
||||||
|
value=self.name)
|
||||||
|
).distinct():
|
||||||
|
i.update_sort()
|
||||||
|
|
||||||
def get_or_create(model, name, imdbId=None):
|
def get_or_create(model, name, imdbId=None):
|
||||||
if imdbId:
|
if imdbId:
|
||||||
|
|
11
pandora/person/tasks.py
Normal file
11
pandora/person/tasks.py
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vi:si:et:sw=4:sts=4:ts=4
|
||||||
|
from celery.task import task
|
||||||
|
|
||||||
|
import models
|
||||||
|
|
||||||
|
|
||||||
|
@task(ignore_resulsts=True, queue='default')
|
||||||
|
def update_itemsort(id):
|
||||||
|
p = models.Person.objects.get(pk=id)
|
||||||
|
p.update_itemsort()
|
Loading…
Reference in a new issue