WIP: dirty hack to add table to content (not working)

This commit is contained in:
PCoder 2022-07-07 11:27:38 +02:00
parent 1abbc707f3
commit 57e30e6217
3 changed files with 45 additions and 2 deletions

View File

@ -17,6 +17,7 @@ from wagtail.admin.edit_handlers import FieldPanel, StreamFieldPanel, InlinePane
from wagtail.images.blocks import ImageChooserBlock
from wagtail.images.edit_handlers import ImageChooserPanel
from wagtail.search import index
from wagtail.contrib.table_block.blocks import TableBlock
from puput.models import EntryPage, BlogPage
from feedler.models import Entry, Stream
@ -49,6 +50,15 @@ class ArticleIndexPage(Page):
'intro_en',
)
table_en = TableBlock()
table_fr = TableBlock()
table_de = TableBlock()
trans_table = TranslatedField(
'table_de',
'table_fr',
'table_en',
)
subscribe_label_de = models.CharField("Button Label (de)", default='', blank=True, max_length=250)
subscribe_label_fr = models.CharField("Button Label (fr)", default='', blank=True, max_length=250)
subscribe_label_en = models.CharField("Button Label (en)", default='', blank=True, max_length=250)
@ -73,6 +83,9 @@ class ArticleIndexPage(Page):
FieldPanel('intro_fr'),
FieldPanel('title_en'),
FieldPanel('intro_en'),
#FieldPanel('table_en'),
#FieldPanel('table_fr'),
#FieldPanel('table_de'),
ImageChooserPanel('feed_image'),
MultiFieldPanel(
[
@ -168,6 +181,14 @@ class ArticlePage(Page):
'body_fr',
'body_en',
)
table_en = TableBlock()
table_fr = TableBlock()
table_de = TableBlock()
trans_table = TranslatedField(
'table_en',
'table_fr',
'table_de',
)
date = models.DateField("Date", null=True, blank=True)
@ -261,6 +282,15 @@ class HomePage(Page):
'body_en',
)
#table_en = TableBlock()
#table_fr = TableBlock()
#table_de = TableBlock()
#trans_table = TranslatedField(
# 'table_en',
# 'table_fr',
# 'table_de',
#)
infos_de = StreamField([
('info', InfoBlock())
], null=True, blank=True)
@ -275,24 +305,27 @@ class HomePage(Page):
'infos_fr',
'infos_en',
)
# content_table = StreamField(TableBlock(), verbose_name=_('Content Table'), blank=True)
content_panels = Page.content_panels + [
MultiFieldPanel([
FieldPanel('intro_de', classname="full"),
FieldPanel('body_de', classname="full"),
StreamFieldPanel('infos_de'),
#StreamFieldPanel('table_de'),
], heading="Deutsch",
classname="collapsible collapsed"),
MultiFieldPanel([
FieldPanel('intro_fr', classname="full"),
FieldPanel('body_fr', classname="full"),
StreamFieldPanel('infos_fr'),
#StreamFieldPanel('table_fr'),
], heading="Français",
classname="collapsible collapsed"),
MultiFieldPanel([
FieldPanel('intro_en', classname="full"),
FieldPanel('body_en', classname="full"),
StreamFieldPanel('infos_en'),
#StreamFieldPanel('table_fr'),
], heading="English",
classname="collapsible collapsed"),
]

View File

@ -27,10 +27,19 @@
<p class="block-{{ block.block_type }}">
{% include_block block %}
</p>
{% endif %}
{% endfor %}
</div>
<!-- Table content -->
<div class="article-table" role="main">
{% for block in page.trans_table %}
{% elif block.block_type == 'table' %}
{% include_block block %}
{% endif %}
{% endfor %}
<!-- Infoblocks -->
<div class="row infoblocks">
{% for block in page.trans_body %}

View File

@ -44,6 +44,7 @@ INSTALLED_APPS = [
'wagtail.contrib.redirects',
'wagtail.contrib.search_promotions',
"wagtail.contrib.legacy.richtext",
'wagtail.contrib.table_block',
'wagtail.embeds',
'wagtail.sites',