From 917695a1dad5374c6d6e552b8824ce2aca174356 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Sat, 30 Nov 2024 12:25:02 +0100 Subject: [PATCH] chore: updates to the content API (for use in CIBUS) --- Makefile | 2 +- base/blocks.py | 8 ++++++++ blog/models.py | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9fc9251..9eedd82 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ .PHONY: help build publish -VERSION = 1.5.0 +VERSION = 1.6.0 help: @perl -nle'print $& if m{^[a-zA-Z_-]+:.*?## .*$$}' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' diff --git a/base/blocks.py b/base/blocks.py index a109031..aef8178 100644 --- a/base/blocks.py +++ b/base/blocks.py @@ -1,3 +1,4 @@ +from wagtail.api import APIField from wagtail.blocks import ( CharBlock, ChoiceBlock, @@ -14,6 +15,13 @@ class ImageBlock(StructBlock): caption = CharBlock(required=False) attribution = CharBlock(required=False) + api_fields = [ + APIField('image'), + # Adds a URL to a rendered thumbnail of the image to the API + APIField('caption'), + APIField('attribution'), + ] + class Meta: icon = "image" template = "base/blocks/image_block.html" diff --git a/blog/models.py b/blog/models.py index 64ad0d5..54357fa 100644 --- a/blog/models.py +++ b/blog/models.py @@ -6,6 +6,7 @@ from modelcluster.fields import ParentalKey, ParentalManyToManyField from modelcluster.contrib.taggit import ClusterTaggableManager from taggit.models import TaggedItemBase from wagtail.api import APIField +from wagtail.images.api.fields import ImageRenditionField from wagtail.models import Page, Orderable from wagtail.fields import RichTextField, StreamField @@ -78,6 +79,7 @@ class BlogPage(SeoMixin, Page): # Export fields over the API api_fields = [ APIField('gallery_images'), + # Adds a URL to a rendered thumbnail of the image to the API APIField('body'), APIField('intro'), APIField('tags'),