+ parts_count = 1 + BookMedia.objects.filter(book=self.book, type=self.type).exclude(pk=self.pk).count()
+ if parts_count == 1:
+ self.name = self.book.pretty_title()
+ else:
+ no = ('%02d' if parts_count < 100 else '%03d') % self.index
+ self.name = '%s. %s' % (no, self.book.pretty_title())
+ if self.part_name:
+ self.name += ', ' + self.part_name
+