diff --git a/conservancy/podjango/admin.py b/conservancy/podjango/admin.py index a1c200a9..ef4674b3 100644 --- a/conservancy/podjango/admin.py +++ b/conservancy/podjango/admin.py @@ -18,7 +18,12 @@ # from django.contrib import admin -from .models import Cast, CastTag +from .models import Cast, CastTag, Podcast + + +@admin.register(Podcast) +class PodcastAdmin(admin.ModelAdmin): + prepopulated_fields = {'slug': ('title',)} @admin.register(CastTag) @@ -26,12 +31,10 @@ class CastTagAdmin(admin.ModelAdmin): prepopulated_fields = {'slug': ('label',)} - - @admin.register(Cast) class CastAdmin(admin.ModelAdmin): list_display = ('pub_date', 'title') - list_filter = ['pub_date'] + list_filter = ['pub_date', 'podcast'] date_hierarchy = 'pub_date' search_fields = ['title', 'summary', 'body'] prepopulated_fields = {'slug': ("title",)} diff --git a/conservancy/podjango/feeds.py b/conservancy/podjango/feeds.py index 672f7c49..1f75a40a 100644 --- a/conservancy/podjango/feeds.py +++ b/conservancy/podjango/feeds.py @@ -21,10 +21,12 @@ from datetime import datetime from django.contrib.sites.shortcuts import get_current_site from django.contrib.syndication.views import Feed, add_domain -from django.shortcuts import render +from django.shortcuts import get_object_or_404, render +from django.urls import reverse from django.utils.feedgenerator import Rss201rev2Feed -from .models import Cast +from .models import Cast, Podcast +from .templatetags.podjango import episode_url # FIXME: Settings here should not be hard-coded for given casts, but # should instead have settings from the main screen. @@ -103,7 +105,7 @@ def podcast_helper_add_root_elements(self, handler): # handler.addQuickElement('dc:creator', self.feed['dcCreator']) handler.addQuickElement('itunes:explicit', self.feed['iTunesExplicit']) handler.addQuickElement('itunes:block', self.feed['iTunesBlock']) - handler.addQuickElement('generator', 'http://www.faif.us/code') + handler.addQuickElement('generator', 'https://sfconservancy.org/') handler.addQuickElement('media:thumbnail', '' , { 'url' : self.feed['rssImage']['url'] }) handler.addQuickElement('itunes:image', '' , { 'href' : self.feed['iTunesImage']['url']}) @@ -188,7 +190,7 @@ class CastFeed(CastFeedBase): link = "/cast/" description = "A bi-weekly discussion of legal, policy, and other issues in the open source and software freedom community (including occasional interviews) from Brooklyn, New York, USA. Presented by Karen Sandler and Bradley M. Kuhn." author_email = "podcast@faif.us" - author_link = "http://www.faif.us/" + author_link = "https://sfconservancy.org/" author_name = "Software Freedom Conservancy" title_template = "feeds/podcast_title.html" description_template = "feeds/podcast_description.html" @@ -202,14 +204,18 @@ class CastFeed(CastFeedBase): self.is_secure = request.is_secure() return super().get_feed(obj, request) - def items(self): - return Cast.objects.filter(pub_date__lte=datetime.now()).order_by('-pub_date') + def get_object(self, request, podcast_slug): + self.podcast = Podcast.objects.get(slug=podcast_slug) + return self.podcast + + def items(self, obj): + return Cast.objects.filter(podcast=obj, pub_date__lte=datetime.now()).order_by('-pub_date') def item_pubdate(self, item): return item.pub_date def item_link(self, item): - return item.get_absolute_url() + return episode_url(self.podcast, item) def item_author_email(self, obj): return "oggcast@faif.us" @@ -218,7 +224,7 @@ class CastFeed(CastFeedBase): return "Software Freedom Conservancy" def item_author_link(self, obj): - return "http://faif.us" + return "https://sfconservancy.org" def item_categories(self, item): return ('Technology',) @@ -264,19 +270,17 @@ class OggCastFeed(CastFeed): return item.ogg_length -feed_dict = { - 'cast-ogg': OggCastFeed, - 'cast-mp3': Mp3CastFeed, -} - -# make each feed know its canonical url -for k, v in feed_dict.items(): - v.get_absolute_url = '/feeds/%s/' % k - - -def view(request): +def view(request, podcast_slug): """Listing of all available feeds """ - + feed_dict = { + 'feed-ogg': OggCastFeed, + 'feed-mp3': Mp3CastFeed, + } + podcast = get_object_or_404(Podcast, slug=podcast_slug) + # make each feed know its canonical url + for k, v in feed_dict.items(): + v.get_absolute_url = reverse(f'podjango:{k}', kwargs={'podcast_slug': podcast.slug}) feeds = feed_dict.values() - return render(request, "feeds.html", {'feeds': feeds}) + return render(request, "feeds.html", {'podcast': podcast, + 'feeds': feeds}) diff --git a/conservancy/podjango/frontpage.py b/conservancy/podjango/frontpage.py index d21dec32..cbf0e724 100644 --- a/conservancy/podjango/frontpage.py +++ b/conservancy/podjango/frontpage.py @@ -19,19 +19,19 @@ from datetime import datetime -from django.shortcuts import render +from django.shortcuts import get_object_or_404, render -from .models import Cast +from .models import Cast, Podcast -def view(request): +def view(request, podcast_slug): """Cast front page view Performs all object queries necessary to render the front page. """ - - cast = Cast.objects.all().filter(pub_date__lte=datetime.now())[:3] - + podcast = get_object_or_404(Podcast, slug=podcast_slug) + cast = Cast.objects.filter(podcast=podcast, pub_date__lte=datetime.now())[:3] c = { 'cast': cast, + 'podcast': podcast, } return render(request, "podjango/frontpage.html", c) diff --git a/conservancy/podjango/migrations/0003_podcast_cast_podcast.py b/conservancy/podjango/migrations/0003_podcast_cast_podcast.py new file mode 100644 index 00000000..38d33041 --- /dev/null +++ b/conservancy/podjango/migrations/0003_podcast_cast_podcast.py @@ -0,0 +1,33 @@ +# Generated by Django 4.2.11 on 2024-04-24 04:03 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('podjango', '0002_alter_cast_tags'), + ] + + operations = [ + migrations.CreateModel( + name='Podcast', + fields=[ + ( + 'id', + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name='ID', + ), + ), + ('title', models.CharField(max_length=50)), + ], + ), + migrations.AddField( + model_name='cast', + name='podcast', + field=models.ManyToManyField(to='podjango.podcast'), + ), + ] diff --git a/conservancy/podjango/migrations/0004_alter_cast_options_alter_casttag_options_and_more.py b/conservancy/podjango/migrations/0004_alter_cast_options_alter_casttag_options_and_more.py new file mode 100644 index 00000000..199228d1 --- /dev/null +++ b/conservancy/podjango/migrations/0004_alter_cast_options_alter_casttag_options_and_more.py @@ -0,0 +1,35 @@ +# Generated by Django 4.2.11 on 2024-04-24 04:10 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('podjango', '0003_podcast_cast_podcast'), + ] + + operations = [ + migrations.AlterModelOptions( + name='cast', + options={ + 'get_latest_by': 'pub_date', + 'ordering': ('-pub_date',), + 'verbose_name': 'episode', + 'verbose_name_plural': 'episodes', + }, + ), + migrations.AlterModelOptions( + name='casttag', + options={ + 'verbose_name': 'episode tag', + 'verbose_name_plural': 'episode tags', + }, + ), + migrations.AddField( + model_name='podcast', + name='slug', + field=models.SlugField(default='', unique=True), + preserve_default=False, + ), + ] diff --git a/conservancy/podjango/migrations/0005_podcast_long_description.py b/conservancy/podjango/migrations/0005_podcast_long_description.py new file mode 100644 index 00000000..0ffa0551 --- /dev/null +++ b/conservancy/podjango/migrations/0005_podcast_long_description.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.11 on 2024-04-25 01:21 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('podjango', '0004_alter_cast_options_alter_casttag_options_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='podcast', + name='long_description', + field=models.TextField(blank=True), + ), + ] diff --git a/conservancy/podjango/models.py b/conservancy/podjango/models.py index edfc8c5b..ad33cb2b 100644 --- a/conservancy/podjango/models.py +++ b/conservancy/podjango/models.py @@ -22,6 +22,16 @@ 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) + + def __str__(self): + return self.title + + class CastTag(models.Model): """Tagging for casts""" @@ -30,13 +40,13 @@ class CastTag(models.Model): class Meta: db_table = 'cast_tags' # legacy + verbose_name = 'episode tag' + verbose_name_plural = 'episode tags' + 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): @@ -45,13 +55,14 @@ class CastManager(models.Manager): class Cast(models.Model): - """Cast""" + """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, @@ -69,23 +80,16 @@ class Cast(models.Model): class Meta: db_table = 'casts_entries' # legacy - verbose_name_plural = 'casts' + verbose_name = 'episode' + verbose_name_plural = 'episodes' 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, - 'month': self.pub_date.strftime("%b").lower(), - 'day': self.pub_date.day, - 'slug': self.slug, - } - ) + def month_str(self): + return self.pub_date.strftime("%b").lower() def is_recent(self): return self.pub_date > (datetime.now() - timedelta(days=14)) diff --git a/conservancy/podjango/templates/podjango/base_podcast.html b/conservancy/podjango/templates/podjango/base_podcast.html index c042699a..b3bee58a 100644 --- a/conservancy/podjango/templates/podjango/base_podcast.html +++ b/conservancy/podjango/templates/podjango/base_podcast.html @@ -17,19 +17,4 @@ } a.feedlink img { margin-left: 0.5rem } - - {% endblock %} - -{% comment %} -{% block internal_navigate %} -
{{ object.pub_date|date:"F j, Y" }}
- {{ object.summary|safe }} - -Released on {{ object.pub_date|date:"F j, Y" }}; its running time is {{ object.duration }}
- {% if object.tags.all %}{% endif %} -{{ object.pub_date|date:"F j, Y" }}
- {{ object.summary|safe }} - -Released on {{ object.pub_date|date:"F j, Y" }}; its running time is {{ object.duration }}
- {% if object.tags.all %}{% endif %} -Displaying casts -tagged {% for tag in tags %}{% if not forloop.last %}{% if not forloop.first %}, {% endif %}{% endif %}{{ tag.label }}{% if forloop.revcounter == 2 %} or {% endif %}{% endfor %} +tagged: {% for tag in tags %}{% if not forloop.last %}{% if not forloop.first %}, {% endif %}{% endif %}{{ tag.label }}{% if forloop.revcounter == 2 %} or {% endif %}{% endfor %}
{% endif %} @@ -22,7 +30,7 @@ tagged {% for tag in tags %}{% if not forloop.last %}{% if not forloop.first %}, {% include 'podjango/audio_ogg_button.inc.html' %} {% include 'podjango/audio_mp3_button.inc.html' %} -{{ object.title|safe }} +{{ object.title|safe }}{{ object.pub_date|date:"F j, Y" }}
-
+
diff --git a/conservancy/podjango/templates/podjango/frontpage.html b/conservancy/podjango/templates/podjango/frontpage.html
index e99a4a7a..8711c224 100644
--- a/conservancy/podjango/templates/podjango/frontpage.html
+++ b/conservancy/podjango/templates/podjango/frontpage.html
@@ -1,37 +1,35 @@
{% extends "podjango/base_podcast.html" %}
-{% block content %}
+{% block header %}
+ {{ block.super }}
+
+
+{% endblock %}
+{% block content %}
The Corresponding Source (formerly Free as in Freedom) is a bi-weekly oggcast, hosted and presented by -Bradley M. Kuhn and Karen Sandler. -The discussion includes legal, policy, and many other issues in the Free, Libre, -and Open Source Software (FLOSS) world. Occasionally, guests join -Bradley and Karen to discuss various topics regarding FLOSS.
- -{% include "podjango/credits.inc.html" %} -{% include "podjango/feedback.inc.html" %} +{{ podcast.long_description|safe }}There is RSS for both ogg format - and mp3 format.
+There is RSS for both ogg format + and mp3 format.
-{{ cc.pub_date|date:"F j, Y" }}
{{ cc.summary|safe }}