diff --git a/uniweb/migrations/0004_auto_20200911_0022.py b/uniweb/migrations/0004_auto_20200911_0022.py new file mode 100644 index 0000000000000000000000000000000000000000..33e277ce95dddc8458d818e3c80b360a360ce2f2 --- /dev/null +++ b/uniweb/migrations/0004_auto_20200911_0022.py @@ -0,0 +1,410 @@ +# 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", + ), + ), + ] diff --git a/uniweb/models.py b/uniweb/models.py index ddca6ef02a0e40578ae0bd2382466bd9b2775abe..32940e1895eeb907e55603df15c26d9b8000814a 100644 --- a/uniweb/models.py +++ b/uniweb/models.py @@ -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()), diff --git a/uniweb/templates/uniweb/base.html b/uniweb/templates/uniweb/base.html index 23afdfa5de3a8b66764c06ae9d5ec38cc23f73d1..e7960a3d35ccfbdc4274049566e9c4b827a27e27 100644 --- a/uniweb/templates/uniweb/base.html +++ b/uniweb/templates/uniweb/base.html @@ -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">©</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"> diff --git a/uniweb/templates/uniweb/snippet_sections.html b/uniweb/templates/uniweb/snippet_sections.html index 59c1919047885f16e3d423d20367a59a9e0b2955..6a6f7ec1744f0b3c9490e5829e1fb85f5804bdf5 100644 --- a/uniweb/templates/uniweb/snippet_sections.html +++ b/uniweb/templates/uniweb/snippet_sections.html @@ -1,32 +1,32 @@ {% 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>