You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
2.5 KiB
71 lines
2.5 KiB
from django.db import models
|
|
|
|
|
|
|
|
|
|
|
|
class PodcastCollection(models.Model):
|
|
title = models.CharField(max_length=255, help_text="This title will not be displayed anywhere")
|
|
created_at = models.DateTimeField(auto_now_add=True, verbose_name=_('created at'))
|
|
updated_at = models.DateTimeField(auto_now=True, verbose_name=_('updated at'))
|
|
videos = models.ManyToManyField(
|
|
Video,
|
|
through='PodcastInCollection',
|
|
related_name='collections',
|
|
verbose_name=_('podcasts'),
|
|
)
|
|
def __str__(self):
|
|
return f'Collection #{self.id}/{self.title}'
|
|
|
|
class Meta:
|
|
verbose_name = _('Podcast Collection')
|
|
verbose_name_plural = _('Podcasts Collections')
|
|
|
|
|
|
class PodcastInCollection(models.Model):
|
|
video_collection = models.ForeignKey(
|
|
VideoCollection, on_delete=models.CASCADE, related_name='podcasts_in_collection', verbose_name=_('podcast collection')
|
|
)
|
|
podcast = models.ForeignKey(
|
|
Podcast, on_delete=models.CASCADE, related_name='collections_podcasts', verbose_name=_('podcasts')
|
|
)
|
|
priority = models.PositiveIntegerField(default=0, verbose_name=_('priority'))
|
|
|
|
def __str__(self):
|
|
return f"{self.podcast_collection.title} - {self.podcast.title} (Priority: {self.priority})"
|
|
|
|
class Meta:
|
|
verbose_name = _('Podcast in Collection')
|
|
verbose_name_plural = _('Podcasts in Collection')
|
|
ordering = ['priority']
|
|
|
|
|
|
|
|
class Podcast(models.Model):
|
|
|
|
title = models.CharField(max_length=255, null=True)
|
|
slug = models.SlugField(allow_unicode=True, unique=True)
|
|
thumbnail = FilerImageField(related_name="+", on_delete=models.SET_NULL, null=True, blank=True, help_text=_(
|
|
'image allowed'
|
|
))
|
|
description = models.TextField(null=True)
|
|
|
|
audio_file = models.FileField(upload_to='podcast/audio/', null=True, blank=True)
|
|
audio_url = models.CharField(max_length=655, null=True, blank=True)
|
|
audio_time = models.TimeField()
|
|
|
|
view_count = models.PositiveBigIntegerField(default=0, verbose_name=_('view count'))
|
|
download_count = models.PositiveBigIntegerField(default=0, verbose_name=_('view count'))
|
|
|
|
status = models.BooleanField(default=True, verbose_name=_('status'))
|
|
|
|
created_at = models.DateTimeField(auto_now_add=True, verbose_name=_('created at'))
|
|
updated_at = models.DateTimeField(auto_now=True, verbose_name=_('updated at'))
|
|
|
|
def __str__(self):
|
|
return self.title
|
|
|
|
class Meta:
|
|
verbose_name = _('Podcast')
|
|
verbose_name_plural = _('Podcasts')
|
|
|