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

uniweb: Gallery section

parent 6d579e90
No related branches found
No related tags found
2 merge requests!95sync test,!89Uniweb
...@@ -9,6 +9,7 @@ from wagtail.admin.edit_handlers import ( ...@@ -9,6 +9,7 @@ from wagtail.admin.edit_handlers import (
from wagtail.core import blocks from wagtail.core import blocks
from wagtail.core.fields import StreamField from wagtail.core.fields import StreamField
from wagtail.core.models import Page from wagtail.core.models import Page
from wagtail.images.blocks import ImageChooserBlock
from wagtail.images.edit_handlers import ImageChooserPanel from wagtail.images.edit_handlers import ImageChooserPanel
from wagtailmetadata.models import MetadataPageMixin from wagtailmetadata.models import MetadataPageMixin
...@@ -41,6 +42,14 @@ class TextSectionBlock(blocks.StructBlock): ...@@ -41,6 +42,14 @@ class TextSectionBlock(blocks.StructBlock):
label = "textová sekce" label = "textová sekce"
class GallerySectionBlock(blocks.StructBlock):
title = blocks.CharBlock(label="nadpis", required=False)
images = blocks.ListBlock(ImageChooserBlock(label="obrázek"))
class Meta:
label = "galerie obrázků"
class MenuItemBlock(blocks.StructBlock): class MenuItemBlock(blocks.StructBlock):
name = blocks.CharBlock(label="název") name = blocks.CharBlock(label="název")
page = blocks.PageChooserBlock(label="stránka") page = blocks.PageChooserBlock(label="stránka")
...@@ -66,8 +75,11 @@ class UniwebHomePage(MetadataPageMixin, Page): ...@@ -66,8 +75,11 @@ class UniwebHomePage(MetadataPageMixin, Page):
### FIELDS ### FIELDS
content = StreamField( content = StreamField(
[("text_section", TextSectionBlock()),], [
verbose_name="Obsah stránky", ("text_section", TextSectionBlock()),
("gallery_section", GallerySectionBlock()),
],
verbose_name="obsah stránky",
blank=True, blank=True,
) )
# settings # settings
...@@ -121,8 +133,11 @@ class UniwebFlexiblePage(Page, SubpageMixin, MetadataPageMixin): ...@@ -121,8 +133,11 @@ class UniwebFlexiblePage(Page, SubpageMixin, MetadataPageMixin):
### FIELDS ### FIELDS
content = StreamField( content = StreamField(
[("text_section", TextSectionBlock()),], [
verbose_name="Obsah stránky", ("text_section", TextSectionBlock()),
("gallery_section", GallerySectionBlock()),
],
verbose_name="obsah stránky",
blank=True, blank=True,
) )
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
<!-- Bootstrap CSS --> <!-- Bootstrap CSS -->
<link rel="stylesheet" href="{% static "shared/vendor/bootstrap-4.4.1/css/bootstrap.min.css" %}"> <link rel="stylesheet" href="{% static "shared/vendor/bootstrap-4.4.1/css/bootstrap.min.css" %}">
<link rel="stylesheet" href="{% static "shared/vendor/fancybox/jquery.fancybox.min.css" %}">
<!-- Styles --> <!-- Styles -->
<link href="{% static "uniweb/assets/css/style.css" %}" rel="stylesheet"> <link href="{% static "uniweb/assets/css/style.css" %}" rel="stylesheet">
...@@ -103,5 +104,11 @@ ...@@ -103,5 +104,11 @@
</footer> </footer>
<!-- /FOOTER --> <!-- /FOOTER -->
<!-- JavaScript libraries -->
<script src="{% static "shared/vendor/jquery/jquery-3.4.1.min.js" %}"></script>
<script src="{% static "shared/vendor/bootstrap-4.4.1/js/bootstrap.min.js" %}"></script>
<script src="{% static "shared/vendor/lazysizes/lazysizes.min.js" %}"></script>
<script src="{% static "shared/vendor/fancybox/jquery.fancybox.min.js" %}"></script>
</body> </body>
</html> </html>
{% load wagtailcore_tags %} {% load wagtailcore_tags wagtailimages_tags %}
{% for section in page.content %} {% for section in page.content %}
<section class="section--{% cycle "alternate" "primary" %}"> <section class="section--{% cycle "alternate" "primary" %}">
<div class="container"> <div class="container">
{% if section.value.title %} {% if section.value.title %}
<h2 class="lead page-subheading mb-4">{{ section.value.title }}</h2> <h2 class="lead page-subheading mb-4">{{ section.value.title }}</h2>
{% endif %} {% endif %}
{% if section.block_type == "text_section" %}
<div class="row"> <div class="row">
<div class="col-12 richtext"> <div class="col-12 richtext">
{{ section.value.text|richtext }} {{ section.value.text|richtext }}
</div><!-- /column --> </div>
</div><!-- /row --> </div>
{% endif %}
{% if section.block_type == "gallery_section" %}
<div class="row about-images">
{% for picture in section.value.images %}
{% image picture width-2000 as img %}
{% image picture fill-300x200 as thumb %}
<div class="col-6 col-md-3 mb-4">
<a data-fancybox="gallery" href="{{ img.url }}"><img data-src="{{ thumb.url }}" class="lazyload img-fluid" alt="{{ thumb.alt }}"></a>
</div>
{% endfor %}
</div>
{% endif %}
</div> <!-- /container --> </div>
</section> </section>
{% endfor %} {% endfor %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment