diff --git a/district/blocks.py b/district/blocks.py index 9915b4247d4cfe49dbfde5f592bd3c1c002840a3..3ef570aea038855c4ca33af2316eaeaece873b73 100644 --- a/district/blocks.py +++ b/district/blocks.py @@ -12,11 +12,8 @@ from wagtail.images.blocks import ImageChooserBlock class AddressBlock(StructBlock): title = CharBlock(label="Titulek", required=True) - embed_map = URLBlock( - label="Odkaz na embed mapku", - required=False, - help_text="Hodnota 'src' v iframe", - ) + map_image = ImageChooserBlock(label="Obrázek mapy", required=False) + map_link = URLBlock(label="Odkaz na detail mapy", required=False) address = TextBlock(label="Adresa", required=True) address_info = TextBlock(label="Info k adrese", required=False) diff --git a/district/migrations/0034_alter_districtcenterpage_sidebar_content.py b/district/migrations/0034_alter_districtcenterpage_sidebar_content.py new file mode 100644 index 0000000000000000000000000000000000000000..f32746f46a374b795c637693c52248518121437a --- /dev/null +++ b/district/migrations/0034_alter_districtcenterpage_sidebar_content.py @@ -0,0 +1,86 @@ +# Generated by Django 3.2.11 on 2022-02-23 10:21 + +import wagtail.core.blocks +import wagtail.core.fields +import wagtail.images.blocks +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("district", "0033_alter_districthomepage_donation_page"), + ] + + operations = [ + migrations.AlterField( + model_name="districtcenterpage", + name="sidebar_content", + field=wagtail.core.fields.StreamField( + [ + ( + "address", + wagtail.core.blocks.StructBlock( + [ + ( + "title", + wagtail.core.blocks.CharBlock( + label="Titulek", required=True + ), + ), + ( + "map_image", + wagtail.images.blocks.ImageChooserBlock( + label="Obrázek mapy", required=False + ), + ), + ( + "map_link", + wagtail.core.blocks.URLBlock( + label="Odkaz na detail mapy", required=False + ), + ), + ( + "address", + wagtail.core.blocks.TextBlock( + label="Adresa", required=True + ), + ), + ( + "address_info", + wagtail.core.blocks.TextBlock( + label="Info k adrese", required=False + ), + ), + ] + ), + ), + ( + "contact", + wagtail.core.blocks.StructBlock( + [ + ( + "title", + wagtail.core.blocks.CharBlock( + label="Titulek", required=True + ), + ), + ( + "contact_list", + wagtail.core.blocks.ListBlock( + wagtail.core.blocks.PageChooserBlock( + label="Osoba", + page_type=["district.DistrictPersonPage"], + ), + label="List kontaktů", + ), + ), + ] + ), + ), + ], + blank=True, + verbose_name="Obsah bočního panelu", + ), + ), + ] diff --git a/district/templates/district/blocks/address_block.html b/district/templates/district/blocks/address_block.html index b2d5d89f692e752e8e19641e277e6570b5b875d5..12a0b344a7b098b4ed16eac5ee6ff6d6da574008 100644 --- a/district/templates/district/blocks/address_block.html +++ b/district/templates/district/blocks/address_block.html @@ -1,12 +1,15 @@ +{% load wagtailimages_tags %} + <h2 class="head-heavy-sm mb-2"> {{ self.title }} </h2> -<iframe - src="{{ self.embed_map }}" - width="100%" height="300" id="mapa-mobile" frameborder="0" style="border:0;" allowfullscreen="" aria-hidden="false" - tabindex="0" -></iframe> +{% if self.map_image %} + <a href="{{ self.map_link }}"> + {% image self.map_image width-1000 as img %} + <img src="{{ img.url }}" alt="{{ img.alt }}" class="h-80 w-full object-cover"> + </a> +{% endif %} <p> {{ self.address | linebreaks }} diff --git a/region/blocks.py b/region/blocks.py index 7ec56447f5d57a38a9af60837bcbb8bf1496ad35..678ce52e9a3d83a7b7b38982a8d1706ef6ba3f7a 100644 --- a/region/blocks.py +++ b/region/blocks.py @@ -12,11 +12,8 @@ from wagtail.images.blocks import ImageChooserBlock class AddressBlock(StructBlock): title = CharBlock(label="Titulek", required=True) - embed_map = URLBlock( - label="Odkaz na embed mapku", - required=False, - help_text="Hodnota 'src' v iframe", - ) + map_image = ImageChooserBlock(label="Obrázek mapy", required=False) + map_link = URLBlock(label="Odkaz na detail mapy", required=False) address = TextBlock(label="Adresa", required=True) address_info = TextBlock(label="Info k adrese", required=False) diff --git a/region/migrations/0011_alter_regioncenterpage_sidebar_content.py b/region/migrations/0011_alter_regioncenterpage_sidebar_content.py new file mode 100644 index 0000000000000000000000000000000000000000..4a6819d3e5fdc8cba88634acb022865c2e92052e --- /dev/null +++ b/region/migrations/0011_alter_regioncenterpage_sidebar_content.py @@ -0,0 +1,86 @@ +# Generated by Django 3.2.11 on 2022-02-23 09:50 + +import wagtail.core.blocks +import wagtail.core.fields +import wagtail.images.blocks +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("region", "0010_alter_regionhomepage_donation_page"), + ] + + operations = [ + migrations.AlterField( + model_name="regioncenterpage", + name="sidebar_content", + field=wagtail.core.fields.StreamField( + [ + ( + "address", + wagtail.core.blocks.StructBlock( + [ + ( + "title", + wagtail.core.blocks.CharBlock( + label="Titulek", required=True + ), + ), + ( + "map_image", + wagtail.images.blocks.ImageChooserBlock( + label="Obrázek mapy", required=False + ), + ), + ( + "map_link", + wagtail.core.blocks.URLBlock( + label="Odkaz na detail mapy", required=False + ), + ), + ( + "address", + wagtail.core.blocks.TextBlock( + label="Adresa", required=True + ), + ), + ( + "address_info", + wagtail.core.blocks.TextBlock( + label="Info k adrese", required=False + ), + ), + ] + ), + ), + ( + "contact", + wagtail.core.blocks.StructBlock( + [ + ( + "title", + wagtail.core.blocks.CharBlock( + label="Titulek", required=True + ), + ), + ( + "contact_list", + wagtail.core.blocks.ListBlock( + wagtail.core.blocks.PageChooserBlock( + label="Osoba", + page_type=["region.RegionPersonPage"], + ), + label="List kontaktů", + ), + ), + ] + ), + ), + ], + blank=True, + verbose_name="Obsah bočního panelu", + ), + ), + ] diff --git a/region/templates/region/blocks/address_block.html b/region/templates/region/blocks/address_block.html index b2d5d89f692e752e8e19641e277e6570b5b875d5..12a0b344a7b098b4ed16eac5ee6ff6d6da574008 100644 --- a/region/templates/region/blocks/address_block.html +++ b/region/templates/region/blocks/address_block.html @@ -1,12 +1,15 @@ +{% load wagtailimages_tags %} + <h2 class="head-heavy-sm mb-2"> {{ self.title }} </h2> -<iframe - src="{{ self.embed_map }}" - width="100%" height="300" id="mapa-mobile" frameborder="0" style="border:0;" allowfullscreen="" aria-hidden="false" - tabindex="0" -></iframe> +{% if self.map_image %} + <a href="{{ self.map_link }}"> + {% image self.map_image width-1000 as img %} + <img src="{{ img.url }}" alt="{{ img.alt }}" class="h-80 w-full object-cover"> + </a> +{% endif %} <p> {{ self.address | linebreaks }}