keep a log of changes

This commit is contained in:
j 2012-01-31 22:36:10 +05:30
commit 82c83c1309
12 changed files with 61 additions and 3 deletions

View file

@ -11,6 +11,7 @@ import ox
from archive import extract
from clip.models import Clip
from changelog.models import Changelog
from item.utils import sort_string
import managers
@ -202,6 +203,11 @@ class Annotation(models.Model):
j['videoRatio'] = streams[0].aspect_ratio
return j
def log(self):
c = Changelog(type='annotation')
c.value = self.json()
c.save()
def __unicode__(self):
return u"%s %s-%s" %(self.public_id, self.start, self.end)

View file

@ -164,6 +164,7 @@ def removeAnnotation(request):
data = json.loads(request.POST['data'])
a = get_object_or_404_json(models.Annotation, public_id=data['id'])
if a.editable(request.user):
a.log()
a.delete()
if a.clip.annotations.count() == 0:
a.clip.delete()
@ -193,6 +194,7 @@ def editAnnotation(request):
data = json.loads(request.POST['data'])
a = get_object_or_404_json(models.Annotation, public_id=data['id'])
if a.editable(request.user):
a.log()
for key in ('value', 'in', 'out'):
if key in data:
setattr(a, {