update item on removing annotation

This commit is contained in:
j 2012-02-28 21:02:50 +01:00
parent 40dcee8e40
commit c9a623275d
2 changed files with 8 additions and 2 deletions

View file

@ -163,6 +163,14 @@ class Annotation(models.Model):
#update sort/find tables async #update sort/find tables async
update_item.delay(self.id) 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): def cleanup_undefined_relations(self):
layer = self.get_layer() layer = self.get_layer()
if layer.get('type') == 'place': if layer.get('type') == 'place':

View file

@ -166,8 +166,6 @@ def removeAnnotation(request):
if a.editable(request.user): if a.editable(request.user):
a.log() a.log()
a.delete() a.delete()
if a.clip.annotations.count() == 0:
a.clip.delete()
else: else:
response = json_response(status=403, text='permission denied') response = json_response(status=403, text='permission denied')
return render_to_json_response(response) return render_to_json_response(response)