Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade wagtail 4.0.4 #1699

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
Prev Previous commit
Next Next commit
Set block icons consistently across page types
istride committed Jul 24, 2024
commit f417a678eb9051af1d9f57f0891132bbb58e58e5
24 changes: 20 additions & 4 deletions home/blocks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from django.conf import settings
from django.forms.utils import flatatt
from django.utils.html import format_html, format_html_join
from django.utils.safestring import mark_safe
from django.utils.translation import gettext as _
@@ -23,7 +21,8 @@ def get_context(self, value, parent_context=None):
return context

class Meta:
template = 'blocks/media.html'
icon = "media"
template = "blocks/media.html"


class SocialMediaLinkBlock(blocks.StructBlock):
@@ -52,6 +51,9 @@ class Meta:
class EmbeddedQuestionnaireBlock(blocks.StructBlock):
direct_display = blocks.BooleanBlock(required=False)

class Meta:
icon = "form"


class EmbeddedPollBlock(EmbeddedQuestionnaireBlock):
poll = EmbeddedQuestionnaireChooserBlock(target_model='questionnaires.Poll')
@@ -119,6 +121,7 @@ def get_context(self, value, parent_context=None):
return context

class Meta:
icon = "link"
template = 'blocks/page_button.html'


@@ -137,7 +140,8 @@ def get_context(self, value, parent_context=None):
return context

class Meta:
template = 'blocks/article.html'
icon = "pick"
template = "blocks/article.html"


class NumberedListBlock(blocks.ListBlock):
@@ -152,6 +156,9 @@ def render_basic(self, value, context=None):
)
return format_html("<ol>{0}</ol>", children)

class Meta:
icon = "list-ol"


class RawHTMLBlock(blocks.RawHTMLBlock):
def render_basic(self, value, context=None):
@@ -188,4 +195,13 @@ class DownloadButtonBlock(blocks.StructBlock):
description = blocks.RichTextBlock()

class Meta:
icon = "download"
template = "blocks/download_button.html"


def heading_block():
return blocks.CharBlock(
icon="h1",
form_classname="full title",
template="blocks/heading.html",
)
51 changes: 27 additions & 24 deletions home/models.py
Original file line number Diff line number Diff line change
@@ -14,7 +14,6 @@
from django.utils.encoding import force_str
from django.utils.translation import gettext_lazy as _
from modelcluster.contrib.taggit import ClusterTaggableManager
from iogt.settings.base import WAGTAIL_CONTENT_LANGUAGES
from modelcluster.fields import ParentalKey
from rest_framework import status
from taggit.models import TaggedItemBase
@@ -42,8 +41,18 @@
from messaging.blocks import ChatBotButtonBlock
from comments.models import CommentableMixin
from home.blocks import (
MediaBlock, SocialMediaLinkBlock, SocialMediaShareButtonBlock, EmbeddedPollBlock, EmbeddedSurveyBlock,
EmbeddedQuizBlock, PageButtonBlock, NumberedListBlock, RawHTMLBlock, ArticleBlock, DownloadButtonBlock,
ArticleBlock,
DownloadButtonBlock,
EmbeddedPollBlock,
EmbeddedSurveyBlock,
EmbeddedQuizBlock,
heading_block,
MediaBlock,
PageButtonBlock,
NumberedListBlock,
RawHTMLBlock,
SocialMediaLinkBlock,
SocialMediaShareButtonBlock,
)
from .forms import SectionPageForm
from .mixins import PageUtilsMixin, TitleIconMixin
@@ -323,26 +332,20 @@ class AbstractArticle(Page, PageUtilsMixin, CommentableMixin, TitleIconMixin):

body = StreamField(
[
(
'heading',
blocks.CharBlock(
form_classname="full title",
template="blocks/heading.html",
),
),
('paragraph', blocks.RichTextBlock()),
('markdown', MarkdownBlock(icon='code')),
('paragraph_v1_legacy', RawHTMLBlock(icon='code')),
('image', ImageChooserBlock(template='blocks/image.html')),
('list', blocks.ListBlock(MarkdownBlock(icon='code'))),
('numbered_list', NumberedListBlock(MarkdownBlock(icon='code'))),
('page_button', PageButtonBlock()),
('embedded_poll', EmbeddedPollBlock()),
('embedded_survey', EmbeddedSurveyBlock()),
('embedded_quiz', EmbeddedQuizBlock()),
('media', MediaBlock(icon='media')),
('chat_bot', ChatBotButtonBlock()),
('download', DownloadButtonBlock()),
("heading", heading_block()),
("paragraph", blocks.RichTextBlock()),
("markdown", MarkdownBlock()),
("paragraph_v1_legacy", RawHTMLBlock(icon='code')),
("image", ImageChooserBlock(template='blocks/image.html')),
("list", blocks.ListBlock(MarkdownBlock(), icon="list-ul")),
("numbered_list", NumberedListBlock(MarkdownBlock())),
("page_button", PageButtonBlock()),
("embedded_poll", EmbeddedPollBlock()),
("embedded_survey", EmbeddedSurveyBlock()),
("embedded_quiz", EmbeddedQuizBlock()),
("media", MediaBlock()),
("chat_bot", ChatBotButtonBlock()),
("download", DownloadButtonBlock()),
],
use_json_field=True,
)
@@ -977,7 +980,7 @@ class ManifestSettings(models.Model):
)
language = models.CharField(
max_length=3,
choices=WAGTAIL_CONTENT_LANGUAGES,
choices=settings.WAGTAIL_CONTENT_LANGUAGES,
default="en",
verbose_name=_("Language"),
help_text=_("Choose language"),
19 changes: 10 additions & 9 deletions questionnaires/models.py
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@
from wagtailsvg.models import Svg

from home.blocks import (
heading_block,
MediaBlock,
NumberedListBlock,
PageButtonBlock,
@@ -63,13 +64,13 @@ class QuestionnairePage(Page, PageUtilsMixin, TitleIconMixin):

description = StreamField(
[
('heading', blocks.CharBlock(form_classname="full title", template='blocks/heading.html')),
('paragraph', blocks.RichTextBlock()),
('paragraph_v1_legacy', RawHTMLBlock(icon='code')),
("image", ImageChooserBlock(template='blocks/image.html')),
('list', MarkdownBlock(icon='code')),
('numbered_list', NumberedListBlock(MarkdownBlock(icon='code'))),
('page_button', PageButtonBlock()),
("heading", heading_block()),
("paragraph", blocks.RichTextBlock()),
("paragraph_v1_legacy", RawHTMLBlock(icon='code')),
("image", ImageChooserBlock(template="blocks/image.html")),
("list", MarkdownBlock()),
("numbered_list", NumberedListBlock(MarkdownBlock())),
("page_button", PageButtonBlock()),
],
null=True,
blank=True,
@@ -78,8 +79,8 @@ class QuestionnairePage(Page, PageUtilsMixin, TitleIconMixin):
thank_you_text = StreamField(
[
("paragraph", blocks.RichTextBlock()),
("media", MediaBlock(icon="media")),
("image", ImageChooserBlock(template='blocks/image.html')),
("media", MediaBlock()),
("image", ImageChooserBlock(template="blocks/image.html")),
],
null=True,
blank=True,