From ee1667c537aa90a2dbb381dc6126941241cabcf2 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Wed, 2 Feb 2011 13:21:59 +0530 Subject: [PATCH] get name --- 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 b380079..0560d70 100644 --- a/pandora/archive/models.py +++ b/pandora/archive/models.py @@ -73,6 +73,8 @@ class File(models.Model): return self.name def save(self, *args, **kwargs): + self.name= self.get_name() + self.folder = self.get_folder() if self.name and not self.sort_name: self.sort_name = utils.sort_string(canonicalTitle(self.name)) if self.info: @@ -129,7 +131,7 @@ class File(models.Model): self.part = self.get_part() self.type = self.get_type() - self.folder = self.get_folder() + if self.type not in ('audio', 'video'): self.duration = None super(File, self).save(*args, **kwargs) @@ -281,6 +283,11 @@ class File(models.Model): return self.instances.all()[0].folder return '' + def get_name(self): + if self.instances.count() > 0: + return self.instances.all()[0].name + return '' + class Volume(models.Model): class Meta: