diff --git a/district/migrations/0051_alter_districtarticlepage_content.py b/district/migrations/0051_alter_districtarticlepage_content.py new file mode 100644 index 0000000000000000000000000000000000000000..d89ac89a1b5ef1526d1662072a6aba0a847a0545 --- /dev/null +++ b/district/migrations/0051_alter_districtarticlepage_content.py @@ -0,0 +1,63 @@ +# Generated by Django 4.0.3 on 2022-04-01 14:13 + +import wagtail.core.blocks +import wagtail.core.fields +import wagtail.images.blocks +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("district", "0050_alter_districtcrossroadpage_content_and_more"), + ] + + operations = [ + migrations.AlterField( + model_name="districtarticlepage", + name="content", + field=wagtail.core.fields.StreamField( + [ + ( + "text", + wagtail.core.blocks.RichTextBlock( + features=[ + "h2", + "h3", + "h4", + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + "image", + ], + label="Textový editor", + ), + ), + ( + "gallery", + wagtail.core.blocks.StructBlock( + [ + ( + "gallery_items", + wagtail.core.blocks.ListBlock( + wagtail.images.blocks.ImageChooserBlock( + label="obrázek", required=True + ), + group="ostatní", + icon="image", + label="Galerie", + ), + ) + ], + label="Galerie", + ), + ), + ], + blank=True, + verbose_name="Článek", + ), + ), + ] diff --git a/district/templates/district/base.html b/district/templates/district/base.html index f043d6bbb7de2fcb36f28743bb7b37ba82356975..ea83320f5d05c69ba38acd910d0e7bf4da316f08 100644 --- a/district/templates/district/base.html +++ b/district/templates/district/base.html @@ -17,6 +17,7 @@ <!-- Styles --> <link rel="stylesheet" href="{% static "styleguide18/assets/css/styles.css" %}"> + <link href="{% static "shared/vendor/fancybox/jquery.fancybox.min.css" %}" rel="stylesheet"> <style type="text/css"> .inline-block { diff --git a/region/migrations/0026_alter_regionarticlepage_content.py b/region/migrations/0026_alter_regionarticlepage_content.py new file mode 100644 index 0000000000000000000000000000000000000000..f81ad07004edde357281ff17fc0a49750442b27f --- /dev/null +++ b/region/migrations/0026_alter_regionarticlepage_content.py @@ -0,0 +1,63 @@ +# Generated by Django 4.0.3 on 2022-04-01 14:13 + +import wagtail.core.blocks +import wagtail.core.fields +import wagtail.images.blocks +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("region", "0025_alter_regioncrossroadpage_content_and_more"), + ] + + operations = [ + migrations.AlterField( + model_name="regionarticlepage", + name="content", + field=wagtail.core.fields.StreamField( + [ + ( + "text", + wagtail.core.blocks.RichTextBlock( + features=[ + "h2", + "h3", + "h4", + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + "image", + ], + label="Textový editor", + ), + ), + ( + "gallery", + wagtail.core.blocks.StructBlock( + [ + ( + "gallery_items", + wagtail.core.blocks.ListBlock( + wagtail.images.blocks.ImageChooserBlock( + label="obrázek", required=True + ), + group="ostatní", + icon="image", + label="Galerie", + ), + ) + ], + label="Galerie", + ), + ), + ], + blank=True, + verbose_name="Článek", + ), + ), + ] diff --git a/region/templates/region/base.html b/region/templates/region/base.html index 0b20a02f9d13d9fd48c3ec41cf33838facf4203d..18eab8c095baa7b4467bc18cb88bf786d2041b6e 100644 --- a/region/templates/region/base.html +++ b/region/templates/region/base.html @@ -17,6 +17,7 @@ <!-- Styles --> <link rel="stylesheet" href="{% static "styleguide18/assets/css/styles.css" %}"> + <link href="{% static "shared/vendor/fancybox/jquery.fancybox.min.css" %}" rel="stylesheet"> <style type="text/css"> .inline-block { diff --git a/shared/blocks.py b/shared/blocks.py index b0d28484ffa65460d0761e21033b258f0c0d814d..c4dbe9ae5b4270767750d20364d63aca5234be9e 100644 --- a/shared/blocks.py +++ b/shared/blocks.py @@ -1,6 +1,20 @@ from django.forms.utils import ErrorList from wagtail.core import blocks from wagtail.core.blocks.struct_block import StructBlockValidationError +from wagtail.images.blocks import ImageChooserBlock + + +class GalleryBlock(blocks.StructBlock): + gallery_items = blocks.ListBlock( + ImageChooserBlock(label="obrázek", required=True), + label="Galerie", + icon="image", + group="ostatní", + ) + + class Meta: + label = "Galerie" + template = "styleguide/2.3.x/blocks/gallery_block.html" class MenuItemBlock(blocks.StructBlock): diff --git a/shared/models.py b/shared/models.py index d070cf939bfb1bcc68ebeace4dd102e27d9fe2cb..6e847cac7a984110d6e60ff96aea953df6284f7a 100644 --- a/shared/models.py +++ b/shared/models.py @@ -6,7 +6,7 @@ from wagtail.core.fields import StreamField from wagtail.core.models import Page from wagtail.images.edit_handlers import ImageChooserPanel -from shared.blocks import MenuItemBlock, MenuParentBlock +from shared.blocks import GalleryBlock, MenuItemBlock, MenuParentBlock class SubpageMixin: @@ -47,7 +47,13 @@ class ArticleMixin(models.Model): ### FIELDS content = StreamField( - [("text", RichTextBlock(label="Textový editor", features=RICH_TEXT_FEATURES))], + [ + ( + "text", + RichTextBlock(label="Textový editor", features=RICH_TEXT_FEATURES), + ), + ("gallery", GalleryBlock(label="Galerie")), + ], verbose_name="Článek", blank=True, ) diff --git a/shared/templates/styleguide/2.3.x/blocks/gallery_block.html b/shared/templates/styleguide/2.3.x/blocks/gallery_block.html new file mode 100644 index 0000000000000000000000000000000000000000..091b5efad1db3b435f93b80565ebf27ba95a16ae --- /dev/null +++ b/shared/templates/styleguide/2.3.x/blocks/gallery_block.html @@ -0,0 +1,10 @@ +{% load wagtailimages_tags %} +<div class="content-block w-full px-4 my-6 grid grid-cols-4 gap-4"> + {% for picture in self.gallery_items %} + {% image picture width-2000 as img %} + {% image picture fill-300x200 as thumb %} + <div> + <a data-fancybox="gallery" href="{{ img.url }}"><img data-src="{{ thumb.url }}" class="lazyload img-fluid" alt="{{ thumb.alt }}"></a> + </div> + {% endfor %} +</div> diff --git a/uniweb/migrations/0023_alter_uniwebarticlepage_content.py b/uniweb/migrations/0023_alter_uniwebarticlepage_content.py new file mode 100644 index 0000000000000000000000000000000000000000..5745f5a15fad6851e80c0271c47e7a5ce771868d --- /dev/null +++ b/uniweb/migrations/0023_alter_uniwebarticlepage_content.py @@ -0,0 +1,63 @@ +# Generated by Django 4.0.3 on 2022-04-01 14:13 + +import wagtail.core.blocks +import wagtail.core.fields +import wagtail.images.blocks +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("uniweb", "0022_remove_uniwebarticlepage_text_and_more"), + ] + + operations = [ + migrations.AlterField( + model_name="uniwebarticlepage", + name="content", + field=wagtail.core.fields.StreamField( + [ + ( + "text", + wagtail.core.blocks.RichTextBlock( + features=[ + "h2", + "h3", + "h4", + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + "image", + ], + label="Textový editor", + ), + ), + ( + "gallery", + wagtail.core.blocks.StructBlock( + [ + ( + "gallery_items", + wagtail.core.blocks.ListBlock( + wagtail.images.blocks.ImageChooserBlock( + label="obrázek", required=True + ), + group="ostatní", + icon="image", + label="Galerie", + ), + ) + ], + label="Galerie", + ), + ), + ], + blank=True, + verbose_name="Článek", + ), + ), + ]