Skip to content
Snippets Groups Projects
Commit 774c97d7 authored by jan.bednarik's avatar jan.bednarik
Browse files

uniweb: Content tables

parent 04fdbd15
No related branches found
No related tags found
2 merge requests!110uniweb: Content tables,!109uniweb: Content tables
Pipeline #1227 passed
......@@ -49,6 +49,7 @@ INSTALLED_APPS = [
"wagtail.contrib.forms",
"wagtail.contrib.redirects",
"wagtail.contrib.modeladmin",
"wagtail.contrib.table_block",
"wagtail.embeds",
"wagtail.sites",
"wagtail.users",
......
# Generated by Django 3.1.1 on 2020-09-11 12:26
import wagtail.contrib.table_block.blocks
import wagtail.core.blocks
import wagtail.core.fields
import wagtail.images.blocks
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("uniweb", "0005_auto_20200911_0050"),
]
operations = [
migrations.AlterField(
model_name="uniwebflexiblepage",
name="content",
field=wagtail.core.fields.StreamField(
[
(
"title",
wagtail.core.blocks.CharBlock(icon="title", label="nadpis"),
),
(
"text",
wagtail.core.blocks.RichTextBlock(
features=[
"h2",
"h3",
"h4",
"h5",
"bold",
"italic",
"ol",
"ul",
"hr",
"link",
"document-link",
"image",
"superscript",
"subscript",
"strikethrough",
"blockquote",
],
label="text",
),
),
(
"text_columns",
wagtail.core.blocks.StructBlock(
[
(
"left_text",
wagtail.core.blocks.RichTextBlock(
features=[
"h2",
"h3",
"h4",
"h5",
"bold",
"italic",
"ol",
"ul",
"hr",
"link",
"document-link",
"image",
"superscript",
"subscript",
"strikethrough",
"blockquote",
],
label="levý sloupec",
),
),
(
"right_text",
wagtail.core.blocks.RichTextBlock(
features=[
"h2",
"h3",
"h4",
"h5",
"bold",
"italic",
"ol",
"ul",
"hr",
"link",
"document-link",
"image",
"superscript",
"subscript",
"strikethrough",
"blockquote",
],
label="pravý sloupec",
),
),
]
),
),
(
"gallery",
wagtail.core.blocks.ListBlock(
wagtail.images.blocks.ImageChooserBlock(label="obrázek"),
icon="image",
label="galerie",
),
),
(
"table",
wagtail.contrib.table_block.blocks.TableBlock(
label="tabulka", template="uniweb/snippet_table.html"
),
),
],
blank=True,
verbose_name="obsah stránky",
),
),
migrations.AlterField(
model_name="uniwebhomepage",
name="content",
field=wagtail.core.fields.StreamField(
[
(
"title",
wagtail.core.blocks.CharBlock(icon="title", label="nadpis"),
),
(
"text",
wagtail.core.blocks.RichTextBlock(
features=[
"h2",
"h3",
"h4",
"h5",
"bold",
"italic",
"ol",
"ul",
"hr",
"link",
"document-link",
"image",
"superscript",
"subscript",
"strikethrough",
"blockquote",
],
label="text",
),
),
(
"text_columns",
wagtail.core.blocks.StructBlock(
[
(
"left_text",
wagtail.core.blocks.RichTextBlock(
features=[
"h2",
"h3",
"h4",
"h5",
"bold",
"italic",
"ol",
"ul",
"hr",
"link",
"document-link",
"image",
"superscript",
"subscript",
"strikethrough",
"blockquote",
],
label="levý sloupec",
),
),
(
"right_text",
wagtail.core.blocks.RichTextBlock(
features=[
"h2",
"h3",
"h4",
"h5",
"bold",
"italic",
"ol",
"ul",
"hr",
"link",
"document-link",
"image",
"superscript",
"subscript",
"strikethrough",
"blockquote",
],
label="pravý sloupec",
),
),
]
),
),
(
"gallery",
wagtail.core.blocks.ListBlock(
wagtail.images.blocks.ImageChooserBlock(label="obrázek"),
icon="image",
label="galerie",
),
),
(
"table",
wagtail.contrib.table_block.blocks.TableBlock(
label="tabulka", template="uniweb/snippet_table.html"
),
),
],
blank=True,
verbose_name="obsah stránky",
),
),
]
......@@ -6,6 +6,7 @@ from wagtail.admin.edit_handlers import (
MultiFieldPanel,
StreamFieldPanel,
)
from wagtail.contrib.table_block.blocks import TableBlock
from wagtail.core import blocks
from wagtail.core.fields import StreamField
from wagtail.core.models import Page
......@@ -84,6 +85,10 @@ class UniwebHomePage(MetadataPageMixin, Page):
ImageChooserBlock(label="obrázek"), label="galerie", icon="image"
),
),
(
"table",
TableBlock(label="tabulka", template="uniweb/snippet_table.html",),
),
],
verbose_name="obsah stránky",
blank=True,
......@@ -149,6 +154,10 @@ class UniwebFlexiblePage(Page, SubpageMixin, MetadataPageMixin):
ImageChooserBlock(label="obrázek"), label="galerie", icon="image"
),
),
(
"table",
TableBlock(label="tabulka", template="uniweb/snippet_table.html",),
),
],
verbose_name="obsah stránky",
blank=True,
......
......@@ -8,7 +8,7 @@
{% endif %}
{% if block.block_type == "text" %}
<div class="content-block w-full my-4 clearfix{% if forloop.first %} mt-8 lg:mt-12{% endif %}">
<div class="content-block my-4 clearfix{% if forloop.first %} mt-8 lg:mt-12{% endif %}">
{{ block.value|richtext }}
</div>
{% endif %}
......@@ -36,5 +36,11 @@
</div>
{% endif %}
{% if block.block_type == "table" %}
<div class="my-6{% if forloop.first %} mt-8 lg:mt-12{% endif %}">
{% include_block block %}
</div>
{% endif %}
{% endfor %}
</section>
{% load table_block_tags %}
<table class="table table--bordered table--condensed mx-auto">
{% if table_caption %}
<caption class="head-heavy-sm my-4">{{ table_caption }}</caption>
{% endif %}
{% if table_header %}
<thead>
<tr>
{% for column in table_header %}
{% with forloop.counter0 as col_index %}
<th scope="col" {% cell_classname 0 col_index %}>
{% if column.strip %}
{% if html_renderer %}
{{ column.strip|safe|linebreaksbr }}
{% else %}
{{ column.strip|linebreaksbr }}
{% endif %}
{% endif %}
</th>
{% endwith %}
{% endfor %}
</tr>
</thead>
{% endif %}
<tbody>
{% for row in data %}
{% with forloop.counter0 as row_index %}
<tr>
{% for column in row %}
{% with forloop.counter0 as col_index %}
{% if first_col_is_header and forloop.first %}
<th scope="row" {% cell_classname row_index col_index table_header %}>
{% if column.strip %}
{% if html_renderer %}
{{ column.strip|safe|linebreaksbr }}
{% else %}
{{ column.strip|linebreaksbr }}
{% endif %}
{% endif %}
</th>
{% else %}
<td {% cell_classname row_index col_index table_header %}>
{% if column.strip %}
{% if html_renderer %}
{{ column.strip|safe|linebreaksbr }}
{% else %}
{{ column.strip|linebreaksbr }}
{% endif %}
{% endif %}
</td>
{% endif %}
{% endwith %}
{% endfor %}
</tr>
{% endwith %}
{% endfor %}
</tbody>
</table>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment