From 408af96aa2c5b3fd5519d236ecbc27e8156c8f8e Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Mon, 24 Oct 2011 23:41:55 +0200 Subject: [PATCH] rename items instead of merge --- pandora/item/models.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/pandora/item/models.py b/pandora/item/models.py index d7ccee7a..ea27a329 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -264,10 +264,19 @@ class Item(models.Model): if self.oxdbId != oxdbId: q = Item.objects.filter(oxdbId=oxdbId).exclude(id=self.id) if q.count() != 0: - self.oxdbId = None - q[0].merge_with(self, save=False) - else: - self.oxdbId = oxdbId + if len(self.itemId) == 7: + self.oxdbId = None + q[0].merge_with(self, save=False) + else: + n = 1 + key = 'episodeTitle' in self.data and 'episodeTitle' or 'title' + title = self.get(key, 'Untitled') + while q.count() != 0: + n += 1 + self.data[key] = u'%s [%d]' % (title, n) + oxdbId = self.oxdb_id() + q = Item.objects.filter(oxdbId=oxdbId).exclude(id=self.id) + self.oxdbId = oxdbId update_poster = True #id changed, what about existing item with new id?