diff --git a/uniweb/migrations/0003_auto_20200909_2354.py b/uniweb/migrations/0003_auto_20200909_2354.py new file mode 100644 index 0000000000000000000000000000000000000000..0f63dcdc0610b71715b6ca231e02c04a328b729b --- /dev/null +++ b/uniweb/migrations/0003_auto_20200909_2354.py @@ -0,0 +1,274 @@ +# Generated by Django 3.1.1 on 2020-09-09 21:54 + +import wagtail.core.blocks +import wagtail.core.fields +import wagtail.images.blocks +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("uniweb", "0002_auto_20200908_2354"), + ] + + operations = [ + migrations.AlterField( + model_name="uniwebflexiblepage", + name="content", + field=wagtail.core.fields.StreamField( + [ + ( + "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="text", + ), + ), + ( + "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="text", + ), + ), + ] + ), + ), + ( + "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( + [ + ( + "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="text", + ), + ), + ( + "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="text", + ), + ), + ] + ), + ), + ( + "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", + ), + ), + ] diff --git a/uniweb/models.py b/uniweb/models.py index ecb4cbb0614f454284add9bb2c3b57417d8fa35f..ddca6ef02a0e40578ae0bd2382466bd9b2775abe 100644 --- a/uniweb/models.py +++ b/uniweb/models.py @@ -43,6 +43,17 @@ class TextSectionBlock(blocks.StructBlock): label = "textová sekce" +class ColumnsSectionBlock(blocks.StructBlock): + title = blocks.CharBlock(label="nadpis", required=False) + 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 = "dvousloupcová textová sekce" + + class GallerySectionBlock(blocks.StructBlock): title = blocks.CharBlock(label="nadpis", required=False) images = blocks.ListBlock(ImageChooserBlock(label="obrázek")) @@ -81,6 +92,7 @@ class UniwebHomePage(MetadataPageMixin, Page): content = StreamField( [ ("text_section", TextSectionBlock()), + ("columns_section", ColumnsSectionBlock()), ("gallery_section", GallerySectionBlock()), ], verbose_name="obsah stránky", @@ -139,6 +151,7 @@ class UniwebFlexiblePage(Page, SubpageMixin, MetadataPageMixin): content = StreamField( [ ("text_section", TextSectionBlock()), + ("columns_section", ColumnsSectionBlock()), ("gallery_section", GallerySectionBlock()), ], verbose_name="obsah stránky", diff --git a/uniweb/templates/uniweb/snippet_sections.html b/uniweb/templates/uniweb/snippet_sections.html index 277fe9e34268fca6f7e11c6d81e5de53f780edbd..59c1919047885f16e3d423d20367a59a9e0b2955 100644 --- a/uniweb/templates/uniweb/snippet_sections.html +++ b/uniweb/templates/uniweb/snippet_sections.html @@ -13,6 +13,17 @@ </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 }} + </div> + <div class="content-block lg:w-1/2 lg:pl-5 my-4"> + {{ section.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 %}