Add richtext as a block

This commit is contained in:
PCoder 2023-05-16 16:11:05 +05:30
parent 713f9ca9e3
commit fc03ea5927
2 changed files with 10 additions and 15 deletions

View File

@ -185,7 +185,8 @@ class ArticlePage(Page):
('info', InfoBlock(icon='help')),
('media', ChoiceBlock(choices=[
('gallery', 'Image gallery'),
], icon='media'))
], icon='media')),
('iframe', RichTextBlock())
], null=True, blank=True)
body_fr = StreamField([
('paragraph', RichTextBlock()),
@ -193,7 +194,8 @@ class ArticlePage(Page):
('info', InfoBlock(icon='help')),
('media', ChoiceBlock(choices=[
('gallery', 'Image gallery'),
], icon='media'))
], icon='media')),
('iframe', RichTextBlock())
], null=True, blank=True)
body_en = StreamField([
('paragraph', RichTextBlock()),
@ -201,7 +203,8 @@ class ArticlePage(Page):
('info', InfoBlock(icon='help')),
('media', ChoiceBlock(choices=[
('gallery', 'Image gallery'),
], icon='media'))
], icon='media')),
('iframe', RichTextBlock())
], null=True, blank=True)
trans_body = TranslatedField(
'body_de',
@ -214,8 +217,6 @@ class ArticlePage(Page):
on_homepage = models.BooleanField(default=False, verbose_name="Featured",
help_text="Auf der Frontpage anzeigen")
html_content = RichTextField(blank=True)
feed_image = models.ForeignKey(
'wagtailimages.Image',
null=True, blank=True,
@ -257,7 +258,6 @@ class ArticlePage(Page):
ImageChooserPanel('feed_image'),
], heading="Images"),
StreamFieldPanel('gallery'),
FieldPanel('html_content', classname='full'),
]
promote_panels = [
InlinePanel('related_links', label="Links"),

View File

@ -23,6 +23,10 @@
{% if block.value == 'gallery' %}
{% include 'home/photo_gallery.html' %}
{% endif %}
{% elif block.block_type == 'iframe' %}
{% autoescape off %}
{{ block.value|ph_html_decode }}
{% endautoescape %}
{% elif block.block_type != 'info' %}
<p class="block-{{ block.block_type }}">
{% include_block block %}
@ -31,15 +35,6 @@
{% endfor %}
</div>
{% if page.html_content %}
<!-- Any other content -->
<div class="article-body">
{% autoescape off %}
{{ page.html_content|ph_html_decode }}
{% endautoescape %}
</div>
{% endif %}
<!-- Infoblocks -->
<div class="row infoblocks">
{% for block in page.trans_body %}