podjango: Upload icon per podcast

This commit is contained in:
Ben Sturmfels 2024-04-26 16:06:48 +10:00
parent 956f8c6fda
commit 1a05c6391c
Signed by: bsturmfels
GPG key ID: 023C05E2C9C068F0
7 changed files with 34 additions and 6 deletions

View file

@ -61,13 +61,13 @@ class CastFeedBase(Feed):
def for_podcast_feed_extra_kwargs(self, obj): def for_podcast_feed_extra_kwargs(self, obj):
return { return {
'managingEditorNames': 'Bradley and Karen', 'managingEditorNames': 'Bradley and Karen',
'rssImage': {'url': 'https://sfconservancy.org/static/podjango/img/cast/tcs_300x300.jpg', 'rssImage': {'url': add_domain(self.current_site.domain, obj.icon.url, self.is_secure),
'width': '144', 'height': '144'}, 'width': '300', 'height': '300'},
'webMaster': 'oggcast@faif.us (Bradley and Karen)', 'webMaster': 'oggcast@faif.us (Bradley and Karen)',
'dcCreator': 'oggcast@faif.us (Bradley and Karen)', 'dcCreator': 'oggcast@faif.us (Bradley and Karen)',
'iTunesExplicit': 'No', 'iTunesExplicit': 'No',
'iTunesBlock': 'No', 'iTunesBlock': 'No',
'iTunesImage': {'url': 'https://sfconservancy.org/static/podjango/img/cast/tcs_300x300.jpg', 'iTunesImage': {'url': add_domain(self.current_site.domain, obj.icon.url, self.is_secure),
'title': 'The Corresponding Source (formerly Free as in Freedom)', 'title': 'The Corresponding Source (formerly Free as in Freedom)',
'link': self.author_link, 'link': self.author_link,
'type': 'video/jpg'}, 'type': 'video/jpg'},
@ -192,8 +192,8 @@ class CastFeed(CastFeedBase):
author_email = "podcast@faif.us" author_email = "podcast@faif.us"
author_link = "https://sfconservancy.org/" author_link = "https://sfconservancy.org/"
author_name = "Software Freedom Conservancy" author_name = "Software Freedom Conservancy"
title_template = "feeds/podcast_title.html" title_template = "feed_title.html"
description_template = "feeds/podcast_description.html" description_template = "feed_description.html"
def get_feed(self, obj, request): def get_feed(self, obj, request):
# Enclosure (media) URLs don't automatically get the protocol and # Enclosure (media) URLs don't automatically get the protocol and

View file

@ -0,0 +1,18 @@
# Generated by Django 4.2.11 on 2024-04-26 01:40
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('podjango', '0005_podcast_long_description'),
]
operations = [
migrations.AddField(
model_name='podcast',
name='icon',
field=models.ImageField(null=True, upload_to=''),
),
]

View file

@ -27,6 +27,7 @@ class Podcast(models.Model):
title = models.CharField(max_length=50) title = models.CharField(max_length=50)
slug = models.SlugField(unique=True) slug = models.SlugField(unique=True)
long_description = models.TextField(blank=True) long_description = models.TextField(blank=True)
icon = models.ImageField(null=True)
def __str__(self): def __str__(self):
return self.title return self.title

View file

@ -17,8 +17,10 @@
# along with this program in a file in the toplevel directory called # along with this program in a file in the toplevel directory called
# "AGPLv3". If not, see <http://www.gnu.org/licenses/>. # "AGPLv3". If not, see <http://www.gnu.org/licenses/>.
from django.urls import include, path, re_path from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin from django.contrib import admin
from django.urls import include, path, re_path
from . import feeds, frontpage, sponsors from . import feeds, frontpage, sponsors
from .fundgoal import views as fundgoal_views from .fundgoal import views as fundgoal_views
@ -59,3 +61,9 @@ urlpatterns = [
re_path(r'^projects/', static_views.index), re_path(r'^projects/', static_views.index),
re_path(r'^sustainer/', static_views.index), re_path(r'^sustainer/', static_views.index),
] ]
# Serve uploaded media. Works only when DEBUG == True. Using '/media/'
# explicitly here because MEDIA_URL include scheme/host/port, which would
# otherwise break debug media serving.
# https://docs.djangoproject.com/en/4.0/howto/static-files/#serving-files-uploaded-by-a-user-during-development
urlpatterns += static('/media/', document_root=settings.MEDIA_ROOT)

View file

@ -4,3 +4,4 @@ Django==4.2.11
beautifulsoup4==4.11.2 beautifulsoup4==4.11.2
html5lib==1.1 html5lib==1.1
django-countries==7.3.2 django-countries==7.3.2
Pillow==9.4.0