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

uniweb: Simplify content blocks

parent b1404a27
Branches
No related tags found
No related merge requests found
# Generated by Django 3.1.1 on 2020-09-10 22:22
import wagtail.core.blocks
import wagtail.core.fields
import wagtail.images.blocks
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("uniweb", "0003_auto_20200909_2354"),
]
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(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",
),
),
(
"text_section",
wagtail.core.blocks.StructBlock(
[
(
"title",
wagtail.core.blocks.CharBlock(
label="nadpis", required=False
),
),
(
"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",
),
),
]
),
),
(
"columns_section",
wagtail.core.blocks.StructBlock(
[
(
"title",
wagtail.core.blocks.CharBlock(
label="nadpis", required=False
),
),
(
"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_section",
wagtail.core.blocks.StructBlock(
[
(
"title",
wagtail.core.blocks.CharBlock(
label="nadpis", required=False
),
),
(
"images",
wagtail.core.blocks.ListBlock(
wagtail.images.blocks.ImageChooserBlock(
label="obrázek"
)
),
),
]
),
),
],
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(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",
),
),
(
"text_section",
wagtail.core.blocks.StructBlock(
[
(
"title",
wagtail.core.blocks.CharBlock(
label="nadpis", required=False
),
),
(
"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",
),
),
]
),
),
(
"columns_section",
wagtail.core.blocks.StructBlock(
[
(
"title",
wagtail.core.blocks.CharBlock(
label="nadpis", required=False
),
),
(
"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_section",
wagtail.core.blocks.StructBlock(
[
(
"title",
wagtail.core.blocks.CharBlock(
label="nadpis", required=False
),
),
(
"images",
wagtail.core.blocks.ListBlock(
wagtail.images.blocks.ImageChooserBlock(
label="obrázek"
)
),
),
]
),
),
],
blank=True,
verbose_name="obsah stránky",
),
),
]
......@@ -35,14 +35,16 @@ RICH_TEXT_FEATURES = [
]
# TODO remove
class TextSectionBlock(blocks.StructBlock):
title = blocks.CharBlock(label="nadpis", required=False)
text = blocks.RichTextBlock(label="text", features=RICH_TEXT_FEATURES)
class Meta:
label = "textová sekce"
label = "(deprecated) textová sekce"
# TODO remove
class ColumnsSectionBlock(blocks.StructBlock):
title = blocks.CharBlock(label="nadpis", required=False)
left_text = blocks.RichTextBlock(label="levý sloupec", features=RICH_TEXT_FEATURES)
......@@ -51,15 +53,27 @@ class ColumnsSectionBlock(blocks.StructBlock):
)
class Meta:
label = "dvousloupcová textová sekce"
label = "(deprecated) dvousloupcová textová sekce"
class ColumnsTextBlock(blocks.StructBlock):
left_text = blocks.RichTextBlock(label="levý sloupec", features=RICH_TEXT_FEATURES)
right_text = blocks.RichTextBlock(
label="pravý sloupec", features=RICH_TEXT_FEATURES
)
class Meta:
label = "text dva sloupce"
icon = "doc-full"
# TODO remove
class GallerySectionBlock(blocks.StructBlock):
title = blocks.CharBlock(label="nadpis", required=False)
images = blocks.ListBlock(ImageChooserBlock(label="obrázek"))
class Meta:
label = "galerie obrázků"
label = "(deprecated) galerie obrázků"
class MenuItemBlock(blocks.StructBlock):
......@@ -91,6 +105,15 @@ class UniwebHomePage(MetadataPageMixin, Page):
content = StreamField(
[
("title", blocks.CharBlock(label="nadpis", icon="title")),
("text", blocks.RichTextBlock(label="text")),
("text_columns", ColumnsTextBlock()),
(
"gallery",
blocks.ListBlock(
ImageChooserBlock(label="obrázek"), label="galerie", icon="image"
),
),
("text_section", TextSectionBlock()),
("columns_section", ColumnsSectionBlock()),
("gallery_section", GallerySectionBlock()),
......@@ -150,6 +173,15 @@ class UniwebFlexiblePage(Page, SubpageMixin, MetadataPageMixin):
content = StreamField(
[
("title", blocks.CharBlock(label="nadpis", icon="title")),
("text", blocks.RichTextBlock(label="text")),
("text_columns", ColumnsTextBlock()),
(
"gallery",
blocks.ListBlock(
ImageChooserBlock(label="obrázek"), label="galerie", icon="image"
),
),
("text_section", TextSectionBlock()),
("columns_section", ColumnsSectionBlock()),
("gallery_section", GallerySectionBlock()),
......
......@@ -34,6 +34,10 @@
margin-left: auto;
margin-right: auto;
}
.copyleft {
display:inline-block;
transform: rotate(180deg);
}
</style>
{% if page.matomo_id %}
......@@ -81,7 +85,7 @@
</ui-app>
</nav>
<div class="container container--default py-4 lg:py-12">
<div class="container container--default lg:py-4">
{% block content %}{% endblock %}
</div>
......@@ -94,7 +98,7 @@
<img src="{% static "uniweb/assets/images/logo.svg" %}" alt="logo pirátské strany" class="w-32 md:w-40 pb-6" />
</a>
<p class="para hidden md:block md:mb-4 lg:mb-0 text-grey-200">
{% now "Y" %} Piráti. Všechna práva vyhlazena. Sdílejte a nechte ostatní sdílet za stejných podmínek.
<span class="copyleft">&copy;</span> {% now "Y" %} Piráti. Všechna práva vyhlazena. Sdílejte a nechte ostatní sdílet za stejných podmínek.
</p>
</section>
<section class="footer__social lg:text-right">
......
{% load wagtailcore_tags wagtailimages_tags %}
{% for section in page.content %}
<section class="mb-8 lg:mb-16 clearfix">
<section class="mb-8 lg:mb-16">
{% for block in page.content %}
{% if section.value.title %}
<h1 class="head-alt-md md:head-alt-lg max-w-5xl mt-4 mb-6">{{ section.value.title }}</h1>
{% if block.block_type == "title" %}
<h1 class="head-alt-md md:head-alt-lg max-w-5xl my-6 lg:mt-16">{{ block.value }}</h1>
{% endif %}
{% if section.block_type == "text_section" %}
<div class="content-block w-full my-4">
{{ section.value.text|richtext }}
{% if block.block_type == "text" %}
<div class="content-block w-full my-4 clearfix{% if forloop.first %} mt-8 lg:mt-12{% endif %}">
{{ block.value|richtext }}
</div>
{% endif %}
{% if section.block_type == "columns_section" %}
<div class="lg:flex">
<div class="content-block lg:w-1/2 lg:pr-5 my-4">
{{ section.value.left_text|richtext }}
{% if block.block_type == "text_columns" %}
<div class="lg:flex clearfix">
<div class="content-block lg:w-1/2 lg:pr-5 my-4{% if forloop.first %} mt-8 lg:mt-12{% endif %}">
{{ block.value.left_text|richtext }}
</div>
<div class="content-block lg:w-1/2 lg:pl-5 my-4">
{{ section.value.right_text|richtext }}
<div class="content-block lg:w-1/2 lg:pl-5 my-4{% if forloop.first %} mt-8 lg:mt-12{% endif %}">
{{ block.value.right_text|richtext }}
</div>
</div>
{% endif %}
{% if section.block_type == "gallery_section" %}
<div class="content-block w-full my-6 grid grid-cols-4 gap-4">
{% for picture in section.value.images %}
{% if block.block_type == "gallery" %}
<div class="content-block w-full my-6 grid grid-cols-4 gap-4{% if forloop.first %} mt-8 lg:mt-12{% endif %}">
{% for picture in block.value %}
{% image picture width-2000 as img %}
{% image picture fill-300x200 as thumb %}
<div>
......@@ -36,5 +36,5 @@
</div>
{% endif %}
</section>
{% endfor %}
</section>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment