From 15e0d9a633f0f6d87d8bd353644f0a6d99cb9385 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Mon, 22 Apr 2013 12:22:02 +0000 Subject: [PATCH] add all files in one folder to one item --- pandora/archive/models.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pandora/archive/models.py b/pandora/archive/models.py index 05282478..b7fbefb3 100644 --- a/pandora/archive/models.py +++ b/pandora/archive/models.py @@ -178,7 +178,14 @@ class File(models.Model): if info.get('director') and info.get('directorSort'): for name, sortname in zip(info['director'], info['directorSort']): get_name_sort(name, sortname) - self.item = item.models.get_item(info, user) + #add all files in one folder to same item + if self.instances.all().count(): + folder = os.path.dirname(self.instances.all()[0].path) + qs = item.models.Item.objects.filter(files__instances__path__startswith=folder) + if qs.exists(): + self.item = qs[0] + if not self.item: + self.item = item.models.get_item(info, user) for key in self.AV_INFO + self.PATH_INFO: if key in info: self.info[key] = info[key]