Skip to content

Commit

Permalink
#136 add cover image to post
Browse files Browse the repository at this point in the history
  • Loading branch information
ephes committed May 7, 2024
1 parent 301a346 commit 4c389ff
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
27 changes: 27 additions & 0 deletions cast/migrations/0056_add_cover_image_for_post.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Generated by Django 5.0.4 on 2024-05-07 16:18

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("cast", "0055_alter_podcast_itunes_artwork"),
("wagtailimages", "0026_delete_uploadedimage"),
]

operations = [
migrations.AddField(
model_name="post",
name="cover",
field=models.ForeignKey(
blank=True,
help_text="An optional cover image.",
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="+",
to="wagtailimages.image",
),
),
]
10 changes: 10 additions & 0 deletions cast/models/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,14 @@ class Post(Page):
default=True,
help_text=_("Whether comments are enabled for this post."),
)
cover = models.ForeignKey(
Image,
help_text=_("An optional cover image."),
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name="+",
)

images: models.ManyToManyField = models.ManyToManyField(Image, blank=True) # FIXME mypy are you ok?
videos: models.ManyToManyField = models.ManyToManyField("cast.Video", blank=True)
Expand Down Expand Up @@ -180,6 +188,7 @@ class Post(Page):
APIField("uuid"),
APIField("visible_date"),
APIField("comments_are_enabled"),
APIField("cover"),
APIField("body"),
APIField("html_overview", serializer=HtmlField(source="*", render_detail=False)),
APIField("html_detail", serializer=HtmlField(source="*", render_detail=True)),
Expand All @@ -192,6 +201,7 @@ class Post(Page):
FieldPanel("visible_date"),
FieldPanel("categories", widget=forms.CheckboxSelectMultiple),
FieldPanel("tags"),
FieldPanel("cover", classname="collapsed"),
FieldPanel("body"),
]
parent_page_types = ["cast.Blog", "cast.Podcast"]
Expand Down
4 changes: 4 additions & 0 deletions docs/releases/0.2.32.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
0.2.32 (2024-05-12)
-------------------

Added an optional cover image to post.

Some ideas:

- fix cover image for twitter player cards
- add subtitle for posts
- add cover images for posts

- #56 Added some documentation for post and related models
- #136 Added cover image to post
- #139 Fixed codecov upload

0 comments on commit 4c389ff

Please sign in to comment.