merge
This commit is contained in:
commit
d7affcb0fe
5 changed files with 44 additions and 8 deletions
|
@ -18,7 +18,7 @@ from changelog.models import Changelog
|
||||||
from item.utils import sort_string
|
from item.utils import sort_string
|
||||||
import managers
|
import managers
|
||||||
import utils
|
import utils
|
||||||
from tasks import update_matching_events, update_matching_places
|
from tasks import update_matching_events, update_matching_places, update_item
|
||||||
|
|
||||||
|
|
||||||
def get_matches(obj, model, layer_type):
|
def get_matches(obj, model, layer_type):
|
||||||
|
@ -160,9 +160,8 @@ class Annotation(models.Model):
|
||||||
if layer.get('type') == 'event' or layer.get('hasEvents'):
|
if layer.get('type') == 'event' or layer.get('hasEvents'):
|
||||||
update_matching_events(self.id)
|
update_matching_events(self.id)
|
||||||
|
|
||||||
#update facets if needed
|
#update sort/find tables async
|
||||||
if filter(lambda f: f['id'] == self.layer, settings.CONFIG['filters']):
|
update_item.delay(self.id)
|
||||||
self.item.update_layer_facet(self.layer)
|
|
||||||
|
|
||||||
def cleanup_undefined_relations(self):
|
def cleanup_undefined_relations(self):
|
||||||
layer = self.get_layer()
|
layer = self.get_layer()
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# vi:si:et:sw=4:sts=4:ts=4
|
# vi:si:et:sw=4:sts=4:ts=4
|
||||||
|
from django.conf import settings
|
||||||
from celery.task import task
|
from celery.task import task
|
||||||
|
|
||||||
import models
|
import models
|
||||||
|
@ -44,3 +45,16 @@ def update_matching_places(id):
|
||||||
if name.lower() in a.value.lower():
|
if name.lower() in a.value.lower():
|
||||||
e.update_matches()
|
e.update_matches()
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@task(ignore_resulsts=True, queue='default')
|
||||||
|
def update_item(id):
|
||||||
|
from item.models import Item
|
||||||
|
a = models.Annotation.objects.get(pk=id)
|
||||||
|
#update facets if needed
|
||||||
|
if filter(lambda f: f['id'] == a.layer, settings.CONFIG['filters']):
|
||||||
|
a.item.update_layer_facet(a.layer)
|
||||||
|
Item.objects.filter(id=a.item.id).update(modified=a.modified)
|
||||||
|
a.item.modified = a.modified
|
||||||
|
a.item.update_find()
|
||||||
|
a.item.update_sort()
|
||||||
|
a.item.update_facets()
|
||||||
|
|
|
@ -104,10 +104,14 @@ def update(request):
|
||||||
response['data']['data'] += [f.file.oshash for f in files.filter(file__is_audio=True,
|
response['data']['data'] += [f.file.oshash for f in files.filter(file__is_audio=True,
|
||||||
file__available=False,
|
file__available=False,
|
||||||
file__wanted=True)]
|
file__wanted=True)]
|
||||||
response['data']['file'] = [f.file.oshash for f in files.filter(file__is_subtitle=True,
|
|
||||||
file__available=False,
|
|
||||||
path__endswith='.srt')]
|
|
||||||
|
|
||||||
|
if filter(lambda l: l['id'] == 'subtitles', settings.CONFIG['layers']):
|
||||||
|
response['data']['file'] = [f.file.oshash
|
||||||
|
for f in files.filter(file__is_subtitle=True,
|
||||||
|
file__available=False,
|
||||||
|
path__endswith='.srt')]
|
||||||
|
else:
|
||||||
|
response['data']['file'] = []
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
actions.register(update, cache=False)
|
actions.register(update, cache=False)
|
||||||
|
|
||||||
|
|
|
@ -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