From 8520c0668028d9ef379d1fcc83b6081a412064e8 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Wed, 15 Feb 2012 17:57:42 +0530 Subject: [PATCH] sync find/sort table saving annotations, fixes #401 --- pandora/annotation/models.py | 7 +++---- pandora/annotation/tasks.py | 13 +++++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/pandora/annotation/models.py b/pandora/annotation/models.py index 618759d1..412cdc18 100644 --- a/pandora/annotation/models.py +++ b/pandora/annotation/models.py @@ -18,7 +18,7 @@ from changelog.models import Changelog from item.utils import sort_string import managers 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): @@ -160,9 +160,8 @@ class Annotation(models.Model): if layer.get('type') == 'event' or layer.get('hasEvents'): update_matching_events(self.id) - #update facets if needed - if filter(lambda f: f['id'] == self.layer, settings.CONFIG['filters']): - self.item.update_layer_facet(self.layer) + #update sort/find tables async + update_item.delay(self.id) def cleanup_undefined_relations(self): layer = self.get_layer() diff --git a/pandora/annotation/tasks.py b/pandora/annotation/tasks.py index 6d568019..3036e916 100644 --- a/pandora/annotation/tasks.py +++ b/pandora/annotation/tasks.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # vi:si:et:sw=4:sts=4:ts=4 +from django.conf import settings from celery.task import task import models @@ -44,3 +45,15 @@ def update_matching_places(id): if name.lower() in a.value.lower(): e.update_matches() 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.update_find() + a.item.update_sort() + a.item.update_facets()