This commit is contained in:
j 2011-02-02 13:21:59 +05:30
parent 5001e9a808
commit 58b30dc671

View file

@ -73,6 +73,8 @@ class File(models.Model):
return self.name return self.name
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
self.name= self.get_name()
self.folder = self.get_folder()
if self.name and not self.sort_name: if self.name and not self.sort_name:
self.sort_name = utils.sort_string(canonicalTitle(self.name)) self.sort_name = utils.sort_string(canonicalTitle(self.name))
if self.info: if self.info:
@ -129,7 +131,7 @@ class File(models.Model):
self.part = self.get_part() self.part = self.get_part()
self.type = self.get_type() self.type = self.get_type()
self.folder = self.get_folder()
if self.type not in ('audio', 'video'): if self.type not in ('audio', 'video'):
self.duration = None self.duration = None
super(File, self).save(*args, **kwargs) super(File, self).save(*args, **kwargs)
@ -281,6 +283,11 @@ class File(models.Model):
return self.instances.all()[0].folder return self.instances.all()[0].folder
return '' return ''
def get_name(self):
if self.instances.count() > 0:
return self.instances.all()[0].name
return ''
class Volume(models.Model): class Volume(models.Model):
class Meta: class Meta: