diff --git a/pandora/annotation/models.py b/pandora/annotation/models.py index cb2bdb4b..3b572cb8 100644 --- a/pandora/annotation/models.py +++ b/pandora/annotation/models.py @@ -84,7 +84,7 @@ class Annotation(models.Model): layer = models.CharField(max_length=255, db_index=True) value = models.TextField() - findvalue = models.TextField() + findvalue = models.TextField(null=True) sortvalue = models.CharField(max_length=1000, null=True, blank=True, db_index=True) def editable(self, user): @@ -133,6 +133,7 @@ class Annotation(models.Model): else: self.sortvalue = None else: + self.findvalue = None self.sortvalue = None #no clip or update clip diff --git a/pandora/clip/models.py b/pandora/clip/models.py index d4ced3a2..d7a8fca6 100644 --- a/pandora/clip/models.py +++ b/pandora/clip/models.py @@ -115,12 +115,14 @@ attrs = { 'aspect_ratio': models.FloatField(default=0), 'item': models.ForeignKey('item.Item', related_name='clips'), + 'random': models.BigIntegerField(default=0, db_index=True), #seconds 'start': models.FloatField(default=-1, db_index=True), 'end': models.FloatField(default=-1), 'duration': models.FloatField(default=0, db_index=True), + #get from annotation 'hue': 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), 'title': models.CharField(max_length=1000, 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']: attrs[name] = models.BooleanField(default=False, db_index=True) diff --git a/pandora/clip/views.py b/pandora/clip/views.py index 28e6df91..0b63539e 100644 --- a/pandora/clip/views.py +++ b/pandora/clip/views.py @@ -41,7 +41,8 @@ def order_query(qs, sort): operator = '' clip_keys = ('public_id', 'start', 'end', 'hue', 'saturation', 'lightness', 'volume', 'duration', 'sortvalue', 'videoRatio', - 'director', 'title') + 'director', 'title', + 'random') key = { 'id': 'public_id', 'in': 'start', diff --git a/pandora/item/tasks.py b/pandora/item/tasks.py index ab22eaf6..02fabd44 100644 --- a/pandora/item/tasks.py +++ b/pandora/item/tasks.py @@ -27,6 +27,17 @@ def update_random_sort(): models.ItemSort.objects.filter(pk=i).update(random=n) 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') def update_poster(itemId): item = models.Item.objects.get(itemId=itemId)