From c9a623275d29648d1e1924f17166283ed1a94657 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Tue, 28 Feb 2012 21:02:50 +0100 Subject: [PATCH] update item on removing annotation --- pandora/annotation/models.py | 8 ++++++++ pandora/annotation/views.py | 2 -- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pandora/annotation/models.py b/pandora/annotation/models.py index fc0e5d98..cb2bdb4b 100644 --- a/pandora/annotation/models.py +++ b/pandora/annotation/models.py @@ -163,6 +163,14 @@ class Annotation(models.Model): #update sort/find tables async update_item.delay(self.id) + def delete(self, *args, **kwargs): + super(Annotation, self).delete(*args, **kwargs) + if self.clip.annotations.count() == 0: + self.clip.delete() + self.item.update_find() + self.item.update_sort() + self.item.update_facets() + def cleanup_undefined_relations(self): layer = self.get_layer() if layer.get('type') == 'place': diff --git a/pandora/annotation/views.py b/pandora/annotation/views.py index b2219a1b..a59d800e 100644 --- a/pandora/annotation/views.py +++ b/pandora/annotation/views.py @@ -166,8 +166,6 @@ def removeAnnotation(request): if a.editable(request.user): a.log() a.delete() - if a.clip.annotations.count() == 0: - a.clip.delete() else: response = json_response(status=403, text='permission denied') return render_to_json_response(response)