findvalue can be Null, clip random sort

This commit is contained in:
j 2012-03-08 19:56:31 +01:00
parent be6652f1c9
commit 26c6987178
4 changed files with 18 additions and 3 deletions

View file

@ -84,7 +84,7 @@ class Annotation(models.Model):
layer = models.CharField(max_length=255, db_index=True) layer = models.CharField(max_length=255, db_index=True)
value = models.TextField() value = models.TextField()
findvalue = models.TextField() findvalue = models.TextField(null=True)
sortvalue = models.CharField(max_length=1000, null=True, blank=True, db_index=True) sortvalue = models.CharField(max_length=1000, null=True, blank=True, db_index=True)
def editable(self, user): def editable(self, user):
@ -133,6 +133,7 @@ class Annotation(models.Model):
else: else:
self.sortvalue = None self.sortvalue = None
else: else:
self.findvalue = None
self.sortvalue = None self.sortvalue = None
#no clip or update clip #no clip or update clip

View file

@ -115,12 +115,14 @@ attrs = {
'aspect_ratio': models.FloatField(default=0), 'aspect_ratio': models.FloatField(default=0),
'item': models.ForeignKey('item.Item', related_name='clips'), 'item': models.ForeignKey('item.Item', related_name='clips'),
'random': models.BigIntegerField(default=0, db_index=True),
#seconds #seconds
'start': models.FloatField(default=-1, db_index=True), 'start': models.FloatField(default=-1, db_index=True),
'end': models.FloatField(default=-1), 'end': models.FloatField(default=-1),
'duration': models.FloatField(default=0, db_index=True), 'duration': models.FloatField(default=0, db_index=True),
#get from annotation #get from annotation
'hue': models.FloatField(default=0, db_index=True), 'hue': models.FloatField(default=0, db_index=True),
'saturation': models.FloatField(default=0, db_index=True), 'saturation': models.FloatField(default=0, db_index=True),
@ -130,7 +132,7 @@ attrs = {
'director': models.CharField(max_length=1000, null=True, db_index=True), 'director': models.CharField(max_length=1000, null=True, db_index=True),
'title': models.CharField(max_length=1000, db_index=True), 'title': models.CharField(max_length=1000, db_index=True),
'sortvalue': models.CharField(max_length=1000, null=True, db_index=True), 'sortvalue': models.CharField(max_length=1000, null=True, db_index=True),
'findvalue': models.TextField(), 'findvalue': models.TextField(null=True),
} }
for name in settings.CONFIG['clipLayers']: for name in settings.CONFIG['clipLayers']:
attrs[name] = models.BooleanField(default=False, db_index=True) attrs[name] = models.BooleanField(default=False, db_index=True)

View file

@ -41,7 +41,8 @@ def order_query(qs, sort):
operator = '' operator = ''
clip_keys = ('public_id', 'start', 'end', 'hue', 'saturation', 'lightness', 'volume', clip_keys = ('public_id', 'start', 'end', 'hue', 'saturation', 'lightness', 'volume',
'duration', 'sortvalue', 'videoRatio', 'duration', 'sortvalue', 'videoRatio',
'director', 'title') 'director', 'title',
'random')
key = { key = {
'id': 'public_id', 'id': 'public_id',
'in': 'start', 'in': 'start',

View file

@ -27,6 +27,17 @@ def update_random_sort():
models.ItemSort.objects.filter(pk=i).update(random=n) models.ItemSort.objects.filter(pk=i).update(random=n)
n += 1 n += 1
def update_random_clip_sort():
if filter(lambda f: f['id'] == 'random', settings.CONFIG['itemKeys']):
random.seed()
from clip.models import Clip
ids = [f['id'] for f in Clip.objects.values('id')]
random.shuffle(ids)
n = 1
for i in ids:
Clip.objects.filter(pk=i).update(random=n)
n += 1
@task(ignore_resulsts=True, queue='default') @task(ignore_resulsts=True, queue='default')
def update_poster(itemId): def update_poster(itemId):
item = models.Item.objects.get(itemId=itemId) item = models.Item.objects.get(itemId=itemId)