From e21484af1c3486fa98e51ee126718288c2baf8f0 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Fri, 15 Jun 2012 22:32:15 +0200 Subject: [PATCH] make sequence ids same as clip ids --- pandora/sequence/models.py | 11 +++++++---- pandora/sequence/views.py | 2 ++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/pandora/sequence/models.py b/pandora/sequence/models.py index 9b487f466..e8676e08a 100644 --- a/pandora/sequence/models.py +++ b/pandora/sequence/models.py @@ -18,12 +18,15 @@ from changelog.models import Changelog from django.db import models class Sequence(models.Model): - public_id = models.CharField(max_length=128, unique=True) + class Meta: + unique_together = ("public_id", "mode") + + mode = models.CharField(max_length=128) + public_id = models.CharField(max_length=128) item = models.ForeignKey(Item, null=True, related_name='sequences') sort = models.ForeignKey(ItemSort, null=True, related_name='sequences') user = models.IntegerField(db_index=True, null=True) - mode = models.CharField(max_length=255) hash = models.CharField(db_index=True, max_length=16, default='') start = models.FloatField(default=-1, db_index=True) end = models.FloatField(default=-1) @@ -31,8 +34,8 @@ class Sequence(models.Model): objects = managers.SequenceManager() def save(self, *args, **kwargs): - self.public_id = u"%s/%s/%s-%s" % ( - self.item.itemId, self.mode, float(self.start), float(self.end) + self.public_id = u"%s/%s-%s" % ( + self.item.itemId, float(self.start), float(self.end) ) if self.item: self.user = self.item.user and self.item.user.id diff --git a/pandora/sequence/views.py b/pandora/sequence/views.py index a1e1c1bf0..aa6242e95 100644 --- a/pandora/sequence/views.py +++ b/pandora/sequence/views.py @@ -55,6 +55,8 @@ def findSequences(request): itemsQuery: ... } + one of your conditions has to be key: 'mode', value: [shape,color], operator: '==' + return { 'status': {'code': int, 'text': string} 'data': {