Skip to content
Snippets Groups Projects
Commit ccac3591 authored by Štěpán Farka's avatar Štěpán Farka
Browse files

[ADD] gallery blok to ArticleMixin

parent 098e0a63
Branches
No related tags found
2 merge requests!442Release,!438[ADD] gallery blok to ArticleMixin
Pipeline #7396 passed
# 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",
),
),
]
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
<!-- Styles --> <!-- Styles -->
<link rel="stylesheet" href="{% static "styleguide18/assets/css/styles.css" %}"> <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"> <style type="text/css">
.inline-block { .inline-block {
......
# 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",
),
),
]
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
<!-- Styles --> <!-- Styles -->
<link rel="stylesheet" href="{% static "styleguide18/assets/css/styles.css" %}"> <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"> <style type="text/css">
.inline-block { .inline-block {
......
from django.forms.utils import ErrorList from django.forms.utils import ErrorList
from wagtail.core import blocks from wagtail.core import blocks
from wagtail.core.blocks.struct_block import StructBlockValidationError 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): class MenuItemBlock(blocks.StructBlock):
......
...@@ -6,7 +6,7 @@ from wagtail.core.fields import StreamField ...@@ -6,7 +6,7 @@ from wagtail.core.fields import StreamField
from wagtail.core.models import Page from wagtail.core.models import Page
from wagtail.images.edit_handlers import ImageChooserPanel from wagtail.images.edit_handlers import ImageChooserPanel
from shared.blocks import MenuItemBlock, MenuParentBlock from shared.blocks import GalleryBlock, MenuItemBlock, MenuParentBlock
class SubpageMixin: class SubpageMixin:
...@@ -47,7 +47,13 @@ class ArticleMixin(models.Model): ...@@ -47,7 +47,13 @@ class ArticleMixin(models.Model):
### FIELDS ### FIELDS
content = StreamField( 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", verbose_name="Článek",
blank=True, blank=True,
) )
......
{% 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>
# 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",
),
),
]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment