Changeset - 6ce976e63a9b
[Not reviewed]
0 1 0
Ben Sturmfels (bsturmfels) - 3 months ago 2024-02-07 00:03:56
ben@sturm.com.au
podjango: Temporarily filter out episodes prior to 2024
1 file changed with 10 insertions and 3 deletions:
0 comments (0 inline, 0 general)
conservancy/podjango/models.py
Show inline comments
...
 
@@ -9,66 +9,73 @@
 
#
 
# This program is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero
 
# General Public License for more details.
 
#
 
# You should have received a copy of the GNU Affero General Public License
 
# along with this program in a file in the toplevel directory called
 
# "AGPLv3".  If not, see <http://www.gnu.org/licenses/>.
 
#
 
from datetime import datetime, timedelta
 

	
 
from django.conf import settings
 
from django.db import models
 
from django.urls import reverse
 

	
 

	
 
class CastTag(models.Model):
 
    """Tagging for casts"""
 

	
 
    label = models.CharField(max_length=100)
 
    slug = models.SlugField()
 

	
 
    class Meta:
 
        db_table = 'cast_tags' # legacy
 
        db_table = 'cast_tags'  # legacy
 

	
 
    def __str__(self):
 
        return self.label
 

	
 
    def get_absolute_url(self):
 
        return reverse('podjango:cast') + "?tag=%s" % self.slug
 

	
 

	
 
class CastManager(models.Manager):
 
    def get_queryset(self):
 
        # Temporarily filter out old FaiF episodes we've imported.
 
        return super().get_queryset().filter(pub_date__year__gte=2024)
 

	
 

	
 
class Cast(models.Model):
 
    """Cast"""
 

	
 
    title = models.CharField(max_length=200)
 
    slug = models.SlugField(unique=True)
 
    summary = models.TextField(help_text="Use raw HTML.  This summary is not included at the beginning of the body when the entry is displayed.  It used only for the material on the front page.")
 
    body = models.TextField(help_text="Use raw HTML.  Include the full body of any show notes or other information about this episode.  It will be labelled on the site as Show Notes.  It is included on the detail entry, and in the description data on the cast RSS feed.")
 
    pub_date = models.DateTimeField()
 
    tags = models.ManyToManyField(CastTag, blank=True)
 
    ogg_path = models.CharField(max_length=300, blank=True,
 
                             help_text="Local filename of the Ogg file, relative to webroot.  File should be uploaded into the static media area for casts.")
 
    mp3_path = models.CharField(max_length=300, blank=True,
 
                             help_text="Local filename of the mp3 file, relative to webroot.  File should be uploaded into the static media area for casts.")
 
    ogg_length = models.IntegerField(blank=False, help_text="size in bytes of ogg file")
 
    mp3_length = models.IntegerField(blank=False, help_text="size in bytes of mp3 file")
 
    duration = models.CharField(max_length=8, blank=False, help_text="length in hh:mm:ss of mp3 file")
 
    date_created = models.DateTimeField(auto_now_add=True)
 
    date_last_modified = models.DateTimeField(auto_now=True)
 

	
 
    objects = CastManager()
 

	
 
    class Meta:
 
        db_table = 'casts_entries' # legacy
 
        db_table = 'casts_entries'  # legacy
 
        verbose_name_plural = 'casts'
 
        ordering = ('-pub_date',)
 
        get_latest_by = 'pub_date'
 

	
 
    def __str__(self):
 
        return self.title
 

	
 
    def get_absolute_url(self):
 
        return reverse(
 
            'podjango:detail',
 
            kwargs={
 
                'year': self.pub_date.year,
0 comments (0 inline, 0 general)