forked from 0x2620/pandora
layer is string now
This commit is contained in:
parent
07d5c9c79e
commit
798a56af73
1 changed files with 12 additions and 6 deletions
|
@ -4,6 +4,7 @@ from __future__ import division, with_statement
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
|
from django.conf import settings
|
||||||
import ox
|
import ox
|
||||||
|
|
||||||
from archive import extract
|
from archive import extract
|
||||||
|
@ -58,8 +59,14 @@ class Annotation(models.Model):
|
||||||
set_public_id = not self.id or not self.public_id
|
set_public_id = not self.id or not self.public_id
|
||||||
|
|
||||||
#no clip or update clip
|
#no clip or update clip
|
||||||
if not self.clip and not self.layer.private or \
|
def get_layer(id):
|
||||||
(self.clip and not self.layer.private and \
|
for l in settings.CONFIG['layers']:
|
||||||
|
if l['id'] == id:
|
||||||
|
return l
|
||||||
|
return {}
|
||||||
|
private = get_layer(self.layer).get('private')
|
||||||
|
if not self.clip and not private or \
|
||||||
|
(self.clip and not private and \
|
||||||
self.start != self.clip.start or self.end != self.clip.end):
|
self.start != self.clip.start or self.end != self.clip.end):
|
||||||
self.clip, created = Clip.get_or_create(self.item, self.start, self.end)
|
self.clip, created = Clip.get_or_create(self.item, self.start, self.end)
|
||||||
|
|
||||||
|
@ -69,8 +76,8 @@ class Annotation(models.Model):
|
||||||
|
|
||||||
Clip.objects.filter(**{
|
Clip.objects.filter(**{
|
||||||
'id': self.clip.id,
|
'id': self.clip.id,
|
||||||
self.layer.name: False
|
self.layer: False
|
||||||
}).update(**{self.layer.name: True})
|
}).update(**{self.layer: True})
|
||||||
|
|
||||||
#how expensive is this?
|
#how expensive is this?
|
||||||
#update_matching_events.delay(self.value)
|
#update_matching_events.delay(self.value)
|
||||||
|
@ -81,7 +88,6 @@ class Annotation(models.Model):
|
||||||
'user': self.user.username,
|
'user': self.user.username,
|
||||||
}
|
}
|
||||||
for field in ('id', 'in', 'out', 'value', 'created', 'modified'):
|
for field in ('id', 'in', 'out', 'value', 'created', 'modified'):
|
||||||
|
|
||||||
j[field] = getattr(self, {
|
j[field] = getattr(self, {
|
||||||
'duration': 'clip__duration',
|
'duration': 'clip__duration',
|
||||||
'hue': 'clip__hue',
|
'hue': 'clip__hue',
|
||||||
|
@ -93,7 +99,7 @@ class Annotation(models.Model):
|
||||||
'volume': 'clip__volume',
|
'volume': 'clip__volume',
|
||||||
}.get(field, field))
|
}.get(field, field))
|
||||||
if layer or (keys and 'layer' in keys):
|
if layer or (keys and 'layer' in keys):
|
||||||
j['layer'] = self.layer.name
|
j['layer'] = self.layer
|
||||||
if keys:
|
if keys:
|
||||||
_j = {}
|
_j = {}
|
||||||
for key in keys:
|
for key in keys:
|
||||||
|
|
Loading…
Reference in a new issue