From 80cb9c8fafab4531e9c5b06f341547b09209d898 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sat, 10 Mar 2012 01:23:44 +0100 Subject: [PATCH] fix name duplicating Foo [2] fixes #535 copy all items not just first 100 duplicating a static list --- pandora/itemlist/views.py | 9 ++++++--- static/js/pandora/utils.js | 9 +++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/pandora/itemlist/views.py b/pandora/itemlist/views.py index 1051ca05..d1408e05 100644 --- a/pandora/itemlist/views.py +++ b/pandora/itemlist/views.py @@ -2,6 +2,7 @@ # vi:si:et:sw=4:sts=4:ts=4 from __future__ import division import os +import re import ox @@ -210,7 +211,8 @@ def addList(request): } ''' data = json.loads(request.POST['data']) - name = data['name'].strip() + data['name'] = re.sub(' \[\d+\]$', '', data['name']).strip() + name = data['name'] if not name: name = "Untitled" num = 1 @@ -349,13 +351,14 @@ def editList(request): list.status = value elif key == 'name': - name = data['name'].strip() + data['name'] = re.sub(' \[\d+\]$', '', data['name']).strip() + name = data['name'] if not name: name = "Untitled" num = 1 while models.List.objects.filter(name=name, user=list.user).exclude(id=list.id).count()>0: num += 1 - name = data['name'] + ' (%d)' % num + name = data['name'] + ' [%d]' % num list.name = name elif key == 'description': list.description = ox.parse_html(data['description']) diff --git a/static/js/pandora/utils.js b/static/js/pandora/utils.js index 2e57e0bd..133d6518 100644 --- a/static/js/pandora/utils.js +++ b/static/js/pandora/utils.js @@ -46,17 +46,18 @@ pandora.addList = function() { pandora.api.find({ query: query, keys: ['id'], - sort: [{key: 'id', operator: ''}] + sort: [{key: 'id', operator: ''}], + range: [0, result.data.items] }, function(result) { var items = result.data.items.map(function(item) { return item.id; }); addList(items); - }) + }); } else { addList(); } - }) + }); } else { addList(); } @@ -69,7 +70,7 @@ pandora.addList = function() { items: items }, function() { getPosterFrames(newList); - }) + }); } else { getPosterFrames(newList); }