Merge pull request 'WIP 10694-table-block' (#3) from 10694-table-block into master
Reviewed-on: #3
This commit is contained in:
commit
9eaf497430
4 changed files with 94 additions and 0 deletions
|
@ -17,6 +17,7 @@ from wagtail.admin.edit_handlers import FieldPanel, StreamFieldPanel, InlinePane
|
||||||
from wagtail.images.blocks import ImageChooserBlock
|
from wagtail.images.blocks import ImageChooserBlock
|
||||||
from wagtail.images.edit_handlers import ImageChooserPanel
|
from wagtail.images.edit_handlers import ImageChooserPanel
|
||||||
from wagtail.search import index
|
from wagtail.search import index
|
||||||
|
from wagtail.contrib.table_block.blocks import TableBlock
|
||||||
|
|
||||||
from puput.models import EntryPage, BlogPage
|
from puput.models import EntryPage, BlogPage
|
||||||
from feedler.models import Entry, Stream
|
from feedler.models import Entry, Stream
|
||||||
|
@ -56,6 +57,34 @@ class ArticleIndexPage(Page):
|
||||||
'intro_en',
|
'intro_en',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
table_en = StreamField(
|
||||||
|
[
|
||||||
|
('table_en', TableBlock(template='home/program_table.html'))
|
||||||
|
],
|
||||||
|
null=True,
|
||||||
|
blank=True,
|
||||||
|
)
|
||||||
|
table_de = StreamField(
|
||||||
|
[
|
||||||
|
('table_de', TableBlock(template='home/program_table.html'))
|
||||||
|
],
|
||||||
|
null=True,
|
||||||
|
blank=True,
|
||||||
|
)
|
||||||
|
table_fr = StreamField(
|
||||||
|
[
|
||||||
|
('table_fr', TableBlock(template='home/program_table.html'))
|
||||||
|
],
|
||||||
|
null=True,
|
||||||
|
blank=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
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_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_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)
|
subscribe_label_en = models.CharField("Button Label (en)", default='', blank=True, max_length=250)
|
||||||
|
@ -81,6 +110,9 @@ class ArticleIndexPage(Page):
|
||||||
FieldPanel('title_en'),
|
FieldPanel('title_en'),
|
||||||
FieldPanel('intro_en'),
|
FieldPanel('intro_en'),
|
||||||
ImageChooserPanel('header_image'),
|
ImageChooserPanel('header_image'),
|
||||||
|
FieldPanel('table_en'),
|
||||||
|
FieldPanel('table_fr'),
|
||||||
|
FieldPanel('table_de'),
|
||||||
ImageChooserPanel('feed_image'),
|
ImageChooserPanel('feed_image'),
|
||||||
MultiFieldPanel(
|
MultiFieldPanel(
|
||||||
[
|
[
|
||||||
|
|
|
@ -45,6 +45,14 @@
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
<!-- Table content -->
|
||||||
|
<div class="article-table table-program" role="main">
|
||||||
|
{% for block in page.trans_table %}
|
||||||
|
{% if block.block_type == 'table_en' or block.block_type == 'table_fr' or block.block_type == 'table_de' %}
|
||||||
|
{% include_block block %}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
</div><!-- /container -->
|
</div><!-- /container -->
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
53
publichealth/home/templates/home/program_table.html
Normal file
53
publichealth/home/templates/home/program_table.html
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
<style>
|
||||||
|
.table-program td, th {
|
||||||
|
padding: 0 10px !important;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<table class="table-program">
|
||||||
|
{% if table_header %}
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
{% for column in table_header %}
|
||||||
|
<th>
|
||||||
|
{% if column.strip %}
|
||||||
|
{% if html_renderer %}
|
||||||
|
{{ column.strip|safe|linebreaksbr }}
|
||||||
|
{% else %}
|
||||||
|
{{ column.strip|linebreaksbr }}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
</th>
|
||||||
|
{% endfor %}
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
{% endif %}
|
||||||
|
<tbody>
|
||||||
|
{% for row in data %}
|
||||||
|
<tr>
|
||||||
|
{% for column in row %}
|
||||||
|
{% if first_col_is_header and forloop.first %}
|
||||||
|
<th>
|
||||||
|
{% if column.strip %}
|
||||||
|
{% if html_renderer %}
|
||||||
|
{{ column.strip|safe|linebreaksbr }}
|
||||||
|
{% else %}
|
||||||
|
{{ column.strip|linebreaksbr }}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
</th>
|
||||||
|
{% else %}
|
||||||
|
<td>
|
||||||
|
{% if column.strip %}
|
||||||
|
{% if html_renderer %}
|
||||||
|
{{ column.strip|safe|linebreaksbr }}
|
||||||
|
{% else %}
|
||||||
|
{{ column.strip|linebreaksbr }}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
|
@ -44,6 +44,7 @@ INSTALLED_APPS = [
|
||||||
'wagtail.contrib.redirects',
|
'wagtail.contrib.redirects',
|
||||||
'wagtail.contrib.search_promotions',
|
'wagtail.contrib.search_promotions',
|
||||||
"wagtail.contrib.legacy.richtext",
|
"wagtail.contrib.legacy.richtext",
|
||||||
|
'wagtail.contrib.table_block',
|
||||||
|
|
||||||
'wagtail.embeds',
|
'wagtail.embeds',
|
||||||
'wagtail.sites',
|
'wagtail.sites',
|
||||||
|
|
Loading…
Reference in a new issue