pad ids to len 7 for storage

This commit is contained in:
j 2011-12-27 00:06:58 +05:30
parent 28a577d69f
commit d070cb616b
3 changed files with 4 additions and 3 deletions

View file

@ -111,7 +111,7 @@ def findClips(request):
Annotation.objects.filter(layer=layer, clip__in=ids)) Annotation.objects.filter(layer=layer, clip__in=ids))
elif 'position' in query: elif 'position' in query:
qs = order_query(qs, query['sort']) qs = order_query(qs, query['sort'])
ids = [i.public_id for i in qs] ids = [i['public_id'] for i in qs.values('public_id')]
data['conditions'] = data['conditions'] + { data['conditions'] = data['conditions'] + {
'value': data['position'], 'value': data['position'],
'key': query['sort'][0]['key'], 'key': query['sort'][0]['key'],
@ -123,7 +123,7 @@ def findClips(request):
response['data']['position'] = utils.get_positions(ids, [qs[0].itemId])[0] response['data']['position'] = utils.get_positions(ids, [qs[0].itemId])[0]
elif 'positions' in data: elif 'positions' in data:
qs = order_query(qs, query['sort']) qs = order_query(qs, query['sort'])
ids = [i.public_id for i in qs] ids = [i['public_id'] for i in qs.values('public_id')]
response['data']['positions'] = utils.get_positions(ids, data['positions']) response['data']['positions'] = utils.get_positions(ids, data['positions'])
else: else:
response['data']['items'] = qs.count() response['data']['items'] = qs.count()

View file

@ -772,6 +772,7 @@ class Item(models.Model):
def path(self, name=''): def path(self, name=''):
h = self.itemId h = self.itemId
h = (7-len(h))*'0' + h
return os.path.join('items', h[:2], h[2:4], h[4:6], h[6:], name) return os.path.join('items', h[:2], h[2:4], h[4:6], h[6:], name)
''' '''

View file

@ -122,7 +122,7 @@ class List(models.Model):
return response return response
def path(self, name=''): def path(self, name=''):
h = "%06d" % self.id h = "%07d" % self.id
return os.path.join('lists', h[:2], h[2:4], h[4:6], h[6:], name) return os.path.join('lists', h[:2], h[2:4], h[4:6], h[6:], name)
def update_icon(self): def update_icon(self):