Files
@ 1a5441ba7518
Branch filter:
Location: website/conservancy/podjango/models.py - annotation
1a5441ba7518
3.9 KiB
text/x-python
Fix tests
These were failing due to pytest defaulting to `DEBUG = False` (and then getting
`ValueError: Missing staticfiles manifest entry for ...`).
These were failing due to pytest defaulting to `DEBUG = False` (and then getting
`ValueError: Missing staticfiles manifest entry for ...`).
c0acfde9c303 c0acfde9c303 c0acfde9c303 c0acfde9c303 c0acfde9c303 c0acfde9c303 c0acfde9c303 c0acfde9c303 c0acfde9c303 c0acfde9c303 c0acfde9c303 c0acfde9c303 c0acfde9c303 c0acfde9c303 c0acfde9c303 c0acfde9c303 c0acfde9c303 c0acfde9c303 47a30a750ad1 47a30a750ad1 47a30a750ad1 7fa679f795c0 c0acfde9c303 d9d28cf439d7 956f8c6fdaad 956f8c6fdaad 956f8c6fdaad 956f8c6fdaad 956f8c6fdaad 1a05c6391c1c 956f8c6fdaad 956f8c6fdaad 956f8c6fdaad 956f8c6fdaad 956f8c6fdaad c0acfde9c303 c0acfde9c303 c0acfde9c303 c0acfde9c303 c0acfde9c303 c0acfde9c303 c0acfde9c303 6ce976e63a9b 956f8c6fdaad 956f8c6fdaad 956f8c6fdaad c0acfde9c303 d9d28cf439d7 c0acfde9c303 c0acfde9c303 d9d28cf439d7 6ce976e63a9b 6ce976e63a9b 6ce976e63a9b 6ce976e63a9b 6ce976e63a9b 6ce976e63a9b c0acfde9c303 956f8c6fdaad c0acfde9c303 c0acfde9c303 c0acfde9c303 c0acfde9c303 c0acfde9c303 c0acfde9c303 956f8c6fdaad c0acfde9c303 75e3ab4d35f0 75e3ab4d35f0 75e3ab4d35f0 75e3ab4d35f0 75e3ab4d35f0 75e3ab4d35f0 c0acfde9c303 c0acfde9c303 c0acfde9c303 c0acfde9c303 c0acfde9c303 c0acfde9c303 6ce976e63a9b 6ce976e63a9b c0acfde9c303 6ce976e63a9b 956f8c6fdaad 956f8c6fdaad c0acfde9c303 c0acfde9c303 c0acfde9c303 d9d28cf439d7 c0acfde9c303 c0acfde9c303 956f8c6fdaad 956f8c6fdaad c0acfde9c303 c0acfde9c303 c0acfde9c303 c0acfde9c303 | # Copyright (C) 2008 Bradley M. Kuhn <bkuhn@ebb.org>
# Copyright (C) 2006, 2007 Software Freedom Law Center, Inc.
#
# This software's license gives you freedom; you can copy, convey,
# propogate, redistribute and/or modify this program under the terms of
# the GNU Affero General Public License (AGPL) as published by the Free
# Software Foundation (FSF), either version 3 of the License, or (at your
# option) any later version of the AGPL published by the FSF.
#
# 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.db import models
from django.urls import reverse
class Podcast(models.Model):
"""An ongoing series of episodes."""
title = models.CharField(max_length=50)
slug = models.SlugField(unique=True)
long_description = models.TextField(blank=True)
icon = models.ImageField(null=True)
def __str__(self):
return self.title
class CastTag(models.Model):
"""Tagging for casts"""
label = models.CharField(max_length=100)
slug = models.SlugField()
class Meta:
db_table = 'cast_tags' # legacy
verbose_name = 'episode tag'
verbose_name_plural = 'episode tags'
def __str__(self):
return self.label
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):
"""A podcast episode."""
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()
podcast = models.ManyToManyField(Podcast)
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
verbose_name = 'episode'
verbose_name_plural = 'episodes'
ordering = ('-pub_date',)
get_latest_by = 'pub_date'
def __str__(self):
return self.title
def month_str(self):
return self.pub_date.strftime("%b").lower()
def is_recent(self):
return self.pub_date > (datetime.now() - timedelta(days=14))
# question: does datetime.now() do a syscall each time is it called?
|