store clip values in clip db, cleanup if all annotations are gone, add additionalSort

This commit is contained in:
j 2012-01-20 23:23:21 +05:30
commit 16cc495fb5
10 changed files with 109 additions and 99 deletions

View file

@ -133,10 +133,11 @@ class Annotation(models.Model):
self.sortvalue = None
#no clip or update clip
private = layer.get('private', False)
if not private:
if self.layer in settings.CONFIG['clipLayers']:
if not self.clip or self.start != self.clip.start or self.end != self.clip.end:
self.clip, created = Clip.get_or_create(self.item, self.start, self.end)
elif self.clip:
self.clip = None
super(Annotation, self).save(*args, **kwargs)
if set_public_id:
@ -147,6 +148,8 @@ class Annotation(models.Model):
'id': self.clip.id,
self.layer: False
}).update(**{self.layer: True})
#update clip.findvalue
self.clip.save()
if filter(lambda l: l['type'] == 'place' or l.get('hasPlaces'),
settings.CONFIG['layers']):

View file

@ -165,6 +165,8 @@ def removeAnnotation(request):
a = get_object_or_404_json(models.Annotation, public_id=data['id'])
if a.editable(request.user):
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)