+ @property
+ def url(self):
+ return f'https://wolnelektury.pl/katalog/lektura/{self.slug}/'
+
+ @property
+ def parts_count(self):
+ return type(self).objects.filter(slug=self.slug).count()
+
+ @property
+ def youtube_volume_count(self):
+ total = 0
+ prev_volume = None
+ for a in type(self).objects.filter(slug=self.slug).order_by("index"):
+ if not a.youtube_volume or a.youtube_volume != prev_volume:
+ total += 1
+ prev_volume = a.youtube_volume
+ return total
+
+ @property
+ def youtube_volume_index(self):
+ index = 0
+ prev_volume = None
+ for a in type(self).objects.filter(slug=self.slug, index__lte=self.index).order_by("index"):
+ if not a.youtube_volume or a.youtube_volume != prev_volume:
+ index += 1
+ prev_volume = a.youtube_volume
+ return index
+
+ @property
+ def is_youtube_publishable(self):
+ return (
+ not self.youtube_volume
+ or not type(self)
+ .objects.filter(youtube_volume=self.youtube_volume, index__lt=self.index)
+ .exists()
+ )
+