fix name duplicating Foo [2] fixes #535

copy all items not just first 100 duplicating a static list
This commit is contained in:
j 2012-03-10 01:23:44 +01:00
parent 69cbee4bd5
commit 80cb9c8faf
2 changed files with 11 additions and 7 deletions

View file

@ -2,6 +2,7 @@
# vi:si:et:sw=4:sts=4:ts=4 # vi:si:et:sw=4:sts=4:ts=4
from __future__ import division from __future__ import division
import os import os
import re
import ox import ox
@ -210,7 +211,8 @@ def addList(request):
} }
''' '''
data = json.loads(request.POST['data']) data = json.loads(request.POST['data'])
name = data['name'].strip() data['name'] = re.sub(' \[\d+\]$', '', data['name']).strip()
name = data['name']
if not name: if not name:
name = "Untitled" name = "Untitled"
num = 1 num = 1
@ -349,13 +351,14 @@ def editList(request):
list.status = value list.status = value
elif key == 'name': elif key == 'name':
name = data['name'].strip() data['name'] = re.sub(' \[\d+\]$', '', data['name']).strip()
name = data['name']
if not name: if not name:
name = "Untitled" name = "Untitled"
num = 1 num = 1
while models.List.objects.filter(name=name, user=list.user).exclude(id=list.id).count()>0: while models.List.objects.filter(name=name, user=list.user).exclude(id=list.id).count()>0:
num += 1 num += 1
name = data['name'] + ' (%d)' % num name = data['name'] + ' [%d]' % num
list.name = name list.name = name
elif key == 'description': elif key == 'description':
list.description = ox.parse_html(data['description']) list.description = ox.parse_html(data['description'])

View file

@ -46,17 +46,18 @@ pandora.addList = function() {
pandora.api.find({ pandora.api.find({
query: query, query: query,
keys: ['id'], keys: ['id'],
sort: [{key: 'id', operator: ''}] sort: [{key: 'id', operator: ''}],
range: [0, result.data.items]
}, function(result) { }, function(result) {
var items = result.data.items.map(function(item) { var items = result.data.items.map(function(item) {
return item.id; return item.id;
}); });
addList(items); addList(items);
}) });
} else { } else {
addList(); addList();
} }
}) });
} else { } else {
addList(); addList();
} }
@ -69,7 +70,7 @@ pandora.addList = function() {
items: items items: items
}, function() { }, function() {
getPosterFrames(newList); getPosterFrames(newList);
}) });
} else { } else {
getPosterFrames(newList); getPosterFrames(newList);
} }