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

View file

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