Skip to content
Snippets Groups Projects
Verified Commit aed77072 authored by Alexa Valentová's avatar Alexa Valentová
Browse files

migrate blocks

parent e7993ff3
Branches
No related tags found
2 merge requests!994Release,!988Redesign
Pipeline #18369 passed
This commit is part of merge request !994. Comments created here will be created in the context of that merge request.
Showing
with 1376 additions and 1273 deletions
This diff is collapsed.
{% load static %} {% load static %}
<script src="{% static "maps_utils/vendor/vue@2/vue2.min.js" %}"></script>
<script src="{% static "maps_utils/vendor/leaflet@1.8.0/leaflet.min.js" %}"></script> <script src="{% static "maps_utils/vendor/leaflet@1.8.0/leaflet.min.js" %}"></script>
<script src="{% static "maps_utils/vendor/leaflet.markercluster@1.5.3/leaflet.markercluster.min.js" %}"></script> <script src="{% static "maps_utils/vendor/leaflet.markercluster@1.5.3/leaflet.markercluster.min.js" %}"></script>
<script src="{% static "maps_utils/vendor/polylabel@1.0.2/polylabel.min.js" %}"></script> <script src="{% static "maps_utils/vendor/polylabel@1.0.2/polylabel.min.js" %}"></script>
......
...@@ -19,9 +19,9 @@ from calendar_utils.models import CalendarMixin ...@@ -19,9 +19,9 @@ from calendar_utils.models import CalendarMixin
from shared.models import ( from shared.models import (
ExtendedMetadataHomePageMixin, ExtendedMetadataHomePageMixin,
ExtendedMetadataPageMixin, ExtendedMetadataPageMixin,
FooterMixin,
SubpageMixin, SubpageMixin,
) )
from shared.models.legacy import FooterMixin
from tuning import admin_help from tuning import admin_help
HELP_COMBINED_TITLE = ( HELP_COMBINED_TITLE = (
......
...@@ -34,7 +34,7 @@ class GalleryBlock(blocks.StructBlock): ...@@ -34,7 +34,7 @@ class GalleryBlock(blocks.StructBlock):
class Meta: class Meta:
label = "Galerie" label = "Galerie"
icon = "image" icon = "image"
template = "styleguide/2.3.x/blocks/gallery_block.html" template = "styleguide2/includes/molecules/gallery/gallery.html"
class FigureBlock(blocks.StructBlock): class FigureBlock(blocks.StructBlock):
...@@ -44,7 +44,7 @@ class FigureBlock(blocks.StructBlock): ...@@ -44,7 +44,7 @@ class FigureBlock(blocks.StructBlock):
class Meta: class Meta:
label = "Obrázek" label = "Obrázek"
icon = "image" icon = "image"
template = "styleguide/2.3.x/blocks/figure_block.html" template = "styleguide2/includes/atoms/figure/figure.html"
class MenuItemBlock(blocks.StructBlock): class MenuItemBlock(blocks.StructBlock):
...@@ -71,15 +71,6 @@ class MenuItemBlock(blocks.StructBlock): ...@@ -71,15 +71,6 @@ class MenuItemBlock(blocks.StructBlock):
return super().clean(value) return super().clean(value)
class MenuParentBlock(blocks.StructBlock):
title = blocks.CharBlock(label="Titulek", required=True)
menu_items = blocks.ListBlock(MenuItemBlock(), label="Položky menu")
class Meta:
label = "Podmenu"
template = "styleguide/2.3.x/menu_parent.html"
class ProgramItemBlock(blocks.StructBlock): class ProgramItemBlock(blocks.StructBlock):
title = blocks.CharBlock(label="Název", required=True) title = blocks.CharBlock(label="Název", required=True)
completion_percentage = blocks.IntegerBlock( completion_percentage = blocks.IntegerBlock(
...@@ -109,7 +100,7 @@ class YouTubeVideoBlock(blocks.StructBlock): ...@@ -109,7 +100,7 @@ class YouTubeVideoBlock(blocks.StructBlock):
class Meta: class Meta:
label = "YouTube video" label = "YouTube video"
icon = "media" icon = "media"
template = "styleguide/2.3.x/blocks/video_block.html" template = "styleguide2/includes/atoms/youtube_video/youtube_video.html"
def clean(self, value): def clean(self, value):
errors = {} errors = {}
...@@ -205,20 +196,9 @@ class YouTubeVideoBlock(blocks.StructBlock): ...@@ -205,20 +196,9 @@ class YouTubeVideoBlock(blocks.StructBlock):
class CardBlock(blocks.StructBlock): class CardBlock(blocks.StructBlock):
img = ImageChooserBlock(label="Obrázek", required=False) img = ImageChooserBlock(label="Obrázek", required=False)
elevation = blocks.IntegerBlock(
label="Velikost stínu",
min_value=0,
max_value=21,
help_text="0 = žádný stín, 21 = maximální stín",
default=2,
)
headline = blocks.TextBlock(label="Titulek", required=False) headline = blocks.TextBlock(label="Titulek", required=False)
hoveractive = blocks.BooleanBlock(
label="Zvýraznit stín na hover",
default=False,
help_text="Pokud je zapnuto, stín se zvýrazní, když na kartu uživatel najede myší.",
required=False,
)
content = blocks.StreamBlock( content = blocks.StreamBlock(
label="Obsah", label="Obsah",
local_blocks=[ local_blocks=[
...@@ -228,7 +208,7 @@ class CardBlock(blocks.StructBlock): ...@@ -228,7 +208,7 @@ class CardBlock(blocks.StructBlock):
label="Textový editor", features=RICH_TEXT_DEFAULT_FEATURES label="Textový editor", features=RICH_TEXT_DEFAULT_FEATURES
), ),
), ),
("table", TableBlock(template="shared/blocks/table_block.html")), ("table", TableBlock(template="styleguide2/includes/atoms/table/table.html", label="Tabulka")),
("figure", FigureBlock()), ("figure", FigureBlock()),
("youtube", YouTubeVideoBlock()), ("youtube", YouTubeVideoBlock()),
("map_point", MapPointBlock(label="Špendlík na mapě")), ("map_point", MapPointBlock(label="Špendlík na mapě")),
...@@ -236,13 +216,15 @@ class CardBlock(blocks.StructBlock): ...@@ -236,13 +216,15 @@ class CardBlock(blocks.StructBlock):
], ],
required=False, required=False,
) )
page = blocks.PageChooserBlock(label="Stránka", required=False) page = blocks.PageChooserBlock(label="Stránka", required=False)
link = blocks.URLBlock(label="Odkaz", required=False) link = blocks.URLBlock(label="Odkaz", required=False)
class Meta: class Meta:
label = "Karta" label = "Karta"
icon = "form" icon = "form"
template = "styleguide/2.3.x/blocks/card_block.html" template = "styleguide2/includes/molecules/boxes/card_box_block.html"
def clean(self, value): def clean(self, value):
errors = {} errors = {}
...@@ -254,6 +236,7 @@ class CardBlock(blocks.StructBlock): ...@@ -254,6 +236,7 @@ class CardBlock(blocks.StructBlock):
errors["link"] = ErrorList( errors["link"] = ErrorList(
["Odkaz nemůže být vybrán současně se stránkou."] ["Odkaz nemůže být vybrán současně se stránkou."]
) )
if errors: if errors:
raise StructBlockValidationError(errors) raise StructBlockValidationError(errors)
...@@ -262,45 +245,34 @@ class CardBlock(blocks.StructBlock): ...@@ -262,45 +245,34 @@ class CardBlock(blocks.StructBlock):
class ButtonBlock(blocks.StructBlock): class ButtonBlock(blocks.StructBlock):
title = blocks.CharBlock(label="Titulek", max_length=128, required=True) title = blocks.CharBlock(label="Titulek", max_length=128, required=True)
icon = blocks.CharBlock(
label="Ikonka",
max_length=128,
required=False,
help_text="Identifikátor ikonky ze styleguide (https://styleguide.pirati.cz/latest/?p=viewall-atoms-icons), např. ico--key.",
)
size = blocks.ChoiceBlock(
choices=(("sm", "Malá"), ("base", "Střední"), ("lg", "Velká")),
label="Velikost",
default="base",
)
color = blocks.ChoiceBlock( color = blocks.ChoiceBlock(
choices=( choices=(
("black", "Černá"), ("black", "Černá"),
("white", "Bílá"), ("white", "Bílá"),
("pirati-yellow", "Žlutá"),
("grey-125", "Světle šedá"), ("grey-125", "Světle šedá"),
("blue-300", "Modrá"), ("blue-300", "Modrá"),
("cyan-200", "Tyrkysová"), ("cyan-200", "Tyrkysová"),
("green-400", "Zelené"), ("green-400", "Zelená"),
("violet-400", "Vínová"), ("violet-400", "Vínová"),
("red-600", "Červená"), ("red-600", "Červená"),
), ),
label="Barva", label="Barva",
default="base", default="black",
) )
hoveractive = blocks.BooleanBlock( hoveractive = blocks.BooleanBlock(
label="Animovat na hover", label="Animovat na hover",
default=True, default=True,
help_text="Pokud je zapnuto, tlačítko mění barvu, když na něj uživatel najede myší.", help_text="Pokud je zapnuto, tlačítko při najetí kurzorem ukáže žlutou šipku.",
required=False,
)
mobile_fullwidth = blocks.BooleanBlock(
label="Plná šířka na mobilních zařízeních",
default=True,
help_text="Pokud je zapnuto, tlačítko se na mobilních zařízeních roztáhne na plnou šířku.",
required=False, required=False,
) )
page = blocks.PageChooserBlock(label="Stránka", required=False) page = blocks.PageChooserBlock(label="Stránka", required=False)
link = blocks.URLBlock(label="Odkaz", required=False) link = blocks.URLBlock(label="Odkaz", required=False)
align = blocks.ChoiceBlock( align = blocks.ChoiceBlock(
choices=( choices=(
("auto", "Automaticky"), ("auto", "Automaticky"),
...@@ -313,7 +285,30 @@ class ButtonBlock(blocks.StructBlock): ...@@ -313,7 +285,30 @@ class ButtonBlock(blocks.StructBlock):
class Meta: class Meta:
label = "Tlačítko" label = "Tlačítko"
icon = "code" icon = "code"
template = "styleguide/2.3.x/blocks/button_block.html" template = "styleguide2/includes/atoms/buttons/round_button_block.html"
def get_context(self, value, parent_context=None):
context = super().get_context(value, parent_context)
context["background_color"] = f"bg-{value['color']}"
context["text_color"] = (
"text-white"
if value["color"] in (
"black",
"red-600",
"blue-300",
"cyan-200",
"green-400",
"violet-400",
"red-600"
)
else "text-black"
)
context["color_classes"] = f"{context['background_color']} {context['text_color']}"
return context
def clean(self, value): def clean(self, value):
errors = {} errors = {}
...@@ -330,25 +325,17 @@ class ButtonBlock(blocks.StructBlock): ...@@ -330,25 +325,17 @@ class ButtonBlock(blocks.StructBlock):
errors["page"] = ErrorList(["Stránka nebo odkaz musí být vyplněna."]) errors["page"] = ErrorList(["Stránka nebo odkaz musí být vyplněna."])
errors["link"] = ErrorList(["Stránka nebo odkaz musí být vyplněna."]) errors["link"] = ErrorList(["Stránka nebo odkaz musí být vyplněna."])
if (
value["hoveractive"]
and value["color"] not in ("black", "white", "grey-125")
):
errors["hoveractive"] = ErrorList(["Šipku lze ukazovat pouze s černým, bílým nebo šedým pozadím."])
if errors: if errors:
raise StructBlockValidationError(errors) raise StructBlockValidationError(errors)
return super().clean(value) return super().clean(value)
def get_context(self, value, parent_context=None):
context = super().get_context(value, parent_context)
if value["icon"]:
context["icon_class"] = (
value["icon"]
if value["icon"].startswith("ico--")
else f"ico--{value['icon']}"
)
else:
context["icon_class"] = None
return context
class ButtonGroupBlock(blocks.StructBlock): class ButtonGroupBlock(blocks.StructBlock):
buttons = blocks.ListBlock(ButtonBlock(), label="Tlačítka") buttons = blocks.ListBlock(ButtonBlock(), label="Tlačítka")
...@@ -356,7 +343,7 @@ class ButtonGroupBlock(blocks.StructBlock): ...@@ -356,7 +343,7 @@ class ButtonGroupBlock(blocks.StructBlock):
class Meta: class Meta:
label = "Skupina tlačítek" label = "Skupina tlačítek"
icon = "list-ul" icon = "list-ul"
template = "styleguide/2.3.x/blocks/button_group_block.html" template = "styleguide2/includes/atoms/buttons/round_button_group_block.html"
class FullSizeHeaderBlock(blocks.StructBlock): class FullSizeHeaderBlock(blocks.StructBlock):
...@@ -372,32 +359,8 @@ class FullSizeHeaderBlock(blocks.StructBlock): ...@@ -372,32 +359,8 @@ class FullSizeHeaderBlock(blocks.StructBlock):
class HeadlineBlock(blocks.StructBlock): class HeadlineBlock(blocks.StructBlock):
headline = blocks.CharBlock(label="Headline", max_length=300, required=True) headline = blocks.CharBlock(label="Nadpis", max_length=300, required=True)
style = blocks.ChoiceBlock(
choices=(
("head-alt-xl", "Bebas XL"),
("head-alt-lg", "Bebas L"),
("head-alt-md", "Bebas M"),
("head-alt-base", "Bebas base"),
("head-alt-sm", "Bebas SM"),
("head-alt-xs", "Bebas XS"),
("head-alt-2xs", "Bebas 2XS"),
("head-heavy-base", "Roboto base"),
("head-heavy-sm", "Roboto SM"),
("head-heavy-xs", "Roboto XS"),
("head-heavy-2xs", "Roboto 2XS"),
("head-allcaps-2xs", "Allcaps 2XS"),
("head-allcaps-3xs", "Allcaps 3XS"),
("head-allcaps-4xs", "Allcaps 4XS"),
("head-heavy-allcaps-2xs", "Allcaps heavy 2XS"),
("head-heavy-allcaps-3xs", "Allcaps heavy 3XS"),
("head-heavy-allcaps-4xs", "Allcaps heavy 4XS"),
),
label="Styl",
help_text="Náhled si prohlédněte na https://styleguide.pir-test.eu/latest/?p=viewall-atoms-text.",
default="head-alt-md",
required=True,
)
tag = blocks.ChoiceBlock( tag = blocks.ChoiceBlock(
choices=( choices=(
("h1", "H1"), ("h1", "H1"),
...@@ -412,6 +375,21 @@ class HeadlineBlock(blocks.StructBlock): ...@@ -412,6 +375,21 @@ class HeadlineBlock(blocks.StructBlock):
required=True, required=True,
default="h1", default="h1",
) )
style = blocks.ChoiceBlock(
choices=(
("head-alt-xl", "Velký, Bebas Neue - 6XL"),
("head-alt-lg", "Střední, Bebas Neue - 4XL"),
("head-alt-md", "Základní velikost - Roboto - MD"),
("head-alt-sm", "Malý - Roboto - SM"),
("head-alt-xs", "Extra malý - Roboto - XS"),
),
label="Velikost",
help_text="Náhled si prohlédněte na https://styleguide2.pirati.cz/pattern/patterns/atoms/text/headings.html.",
default="head-alt-xl",
required=True,
)
align = blocks.ChoiceBlock( align = blocks.ChoiceBlock(
choices=( choices=(
("auto", "Automaticky"), ("auto", "Automaticky"),
...@@ -424,31 +402,21 @@ class HeadlineBlock(blocks.StructBlock): ...@@ -424,31 +402,21 @@ class HeadlineBlock(blocks.StructBlock):
def get_context(self, value, parent_context=None): def get_context(self, value, parent_context=None):
context = super().get_context(value, parent_context) context = super().get_context(value, parent_context)
context["responsive_style"] = { context["responsive_style"] = {
"head-alt-xl": "head-alt-lg md:head-alt-xl", "head-alt-xl": "head-6xl",
"head-alt-lg": "head-alt-md md:head-alt-lg", "head-alt-lg": "head-4xl",
"head-alt-md": "head-alt-md", "head-alt-md": "head-base",
"head-alt-base": "head-alt-base", "head-alt-sm": "head-sm",
"head-alt-sm": "head-alt-sm", "head-alt-xs": "head-xs",
"head-alt-xs": "head-alt-xs", }.get(value["style"], "head-4xl")
"head-alt-2xs": "head-alt-2xs",
"head-heavy-base": "head-heavy-base",
"head-heavy-sm": "head-heavy-sm",
"head-heavy-xs": "head-heavy-xs",
"head-heavy-2xs": "head-heavy-2xs",
"head-allcaps-2xs": "head-allcaps-2xs",
"head-allcaps-3xs": "head-allcaps-3xs",
"head-allcaps-4xs": "head-allcaps-4xs",
"head-heavy-allcaps-2xs": "head-heavy-allcaps-2xs",
"head-heavy-allcaps-3xs": "head-heavy-allcaps-3xs",
"head-heavy-allcaps-4xs": "head-heavy-allcaps-4xs",
}[value["style"]]
return context return context
class Meta: class Meta:
label = "Headline" label = "Nadpis"
icon = "bold" icon = "bold"
template = "styleguide/2.3.x/blocks/headline_block.html" template = "styleguide2/includes/atoms/text/heading.html"
class TwoColumnBlock(blocks.StructBlock): class TwoColumnBlock(blocks.StructBlock):
...@@ -461,7 +429,7 @@ class TwoColumnBlock(blocks.StructBlock): ...@@ -461,7 +429,7 @@ class TwoColumnBlock(blocks.StructBlock):
label="Textový editor", features=RICH_TEXT_DEFAULT_FEATURES label="Textový editor", features=RICH_TEXT_DEFAULT_FEATURES
), ),
), ),
("table", TableBlock(template="shared/blocks/table_block.html")), ("table", TableBlock(template="styleguide2/includes/atoms/table/table.html", label="Tabulka")),
("card", CardBlock()), ("card", CardBlock()),
("figure", FigureBlock()), ("figure", FigureBlock()),
("youtube", YouTubeVideoBlock()), ("youtube", YouTubeVideoBlock()),
...@@ -481,7 +449,7 @@ class TwoColumnBlock(blocks.StructBlock): ...@@ -481,7 +449,7 @@ class TwoColumnBlock(blocks.StructBlock):
label="Textový editor", features=RICH_TEXT_DEFAULT_FEATURES label="Textový editor", features=RICH_TEXT_DEFAULT_FEATURES
), ),
), ),
("table", TableBlock(template="shared/blocks/table_block.html")), ("table", TableBlock(template="styleguide2/includes/atoms/table/table.html", label="Tabulka")),
("card", CardBlock()), ("card", CardBlock()),
("figure", FigureBlock()), ("figure", FigureBlock()),
("youtube", YouTubeVideoBlock()), ("youtube", YouTubeVideoBlock()),
...@@ -496,7 +464,7 @@ class TwoColumnBlock(blocks.StructBlock): ...@@ -496,7 +464,7 @@ class TwoColumnBlock(blocks.StructBlock):
class Meta: class Meta:
label = "Dva sloupce" label = "Dva sloupce"
icon = "grip" icon = "grip"
template = "styleguide/2.3.x/blocks/two_column_block.html" template = "styleguide2/includes/atoms/grids/two_columns.html"
class ThreeColumnBlock(blocks.StructBlock): class ThreeColumnBlock(blocks.StructBlock):
...@@ -509,7 +477,7 @@ class ThreeColumnBlock(blocks.StructBlock): ...@@ -509,7 +477,7 @@ class ThreeColumnBlock(blocks.StructBlock):
label="Textový editor", features=RICH_TEXT_DEFAULT_FEATURES label="Textový editor", features=RICH_TEXT_DEFAULT_FEATURES
), ),
), ),
("table", TableBlock(template="shared/blocks/table_block.html")), ("table", TableBlock(template="styleguide2/includes/atoms/table/table.html", label="Tabulka")),
("card", CardBlock()), ("card", CardBlock()),
("figure", FigureBlock()), ("figure", FigureBlock()),
("youtube", YouTubeVideoBlock()), ("youtube", YouTubeVideoBlock()),
...@@ -529,7 +497,7 @@ class ThreeColumnBlock(blocks.StructBlock): ...@@ -529,7 +497,7 @@ class ThreeColumnBlock(blocks.StructBlock):
label="Textový editor", features=RICH_TEXT_DEFAULT_FEATURES label="Textový editor", features=RICH_TEXT_DEFAULT_FEATURES
), ),
), ),
("table", TableBlock(template="shared/blocks/table_block.html")), ("table", TableBlock(template="styleguide2/includes/atoms/table/table.html", label="Tabulka")),
("card", CardBlock()), ("card", CardBlock()),
("figure", FigureBlock()), ("figure", FigureBlock()),
("youtube", YouTubeVideoBlock()), ("youtube", YouTubeVideoBlock()),
...@@ -549,7 +517,7 @@ class ThreeColumnBlock(blocks.StructBlock): ...@@ -549,7 +517,7 @@ class ThreeColumnBlock(blocks.StructBlock):
label="Textový editor", features=RICH_TEXT_DEFAULT_FEATURES label="Textový editor", features=RICH_TEXT_DEFAULT_FEATURES
), ),
), ),
("table", TableBlock(template="shared/blocks/table_block.html")), ("table", TableBlock(template="styleguide2/includes/atoms/table/table.html", label="Tabulka")),
("card", CardBlock()), ("card", CardBlock()),
("figure", FigureBlock()), ("figure", FigureBlock()),
("youtube", YouTubeVideoBlock()), ("youtube", YouTubeVideoBlock()),
...@@ -564,51 +532,7 @@ class ThreeColumnBlock(blocks.StructBlock): ...@@ -564,51 +532,7 @@ class ThreeColumnBlock(blocks.StructBlock):
class Meta: class Meta:
label = "Tři sloupce" label = "Tři sloupce"
icon = "grip" icon = "grip"
template = "styleguide/2.3.x/blocks/three_column_block.html" template = "styleguide2/includes/atoms/grids/three_columns.html"
class ImageBannerBlock(blocks.StructBlock):
image = ImageChooserBlock(
label="Obrázek",
required=True,
)
headline = blocks.CharBlock(label="Headline", max_length=128, required=True)
content = blocks.StreamBlock(
label="Obsah pravého sloupce",
local_blocks=[
(
"text",
blocks.RichTextBlock(
label="Textový editor",
features=(
"h2",
"h3",
"h4",
"h5",
"bold",
"italic",
"ol",
"ul",
"hr",
"link",
"document-link",
"superscript",
"subscript",
"strikethrough",
"blockquote",
),
),
),
("button", ButtonBlock()),
("button_group", ButtonGroupBlock()),
],
required=False,
)
class Meta:
label = "Obrázkový banner"
icon = "image"
template = "styleguide/2.3.x/blocks/image_banner_block.html"
class CardLinkBlockMixin(blocks.StructBlock): class CardLinkBlockMixin(blocks.StructBlock):
...@@ -1087,11 +1011,18 @@ DEFAULT_CONTENT_BLOCKS = [ ...@@ -1087,11 +1011,18 @@ DEFAULT_CONTENT_BLOCKS = [
( (
"text", "text",
blocks.RichTextBlock( blocks.RichTextBlock(
label="Textový editor", features=RICH_TEXT_DEFAULT_FEATURES label="Textový editor", features=RICH_TEXT_DEFAULT_FEATURES,
template="styleguide2/includes/atoms/text/prose_richtext.html"
), ),
), ),
("headline", HeadlineBlock()), ("headline", HeadlineBlock()),
("table", TableBlock(template="shared/blocks/table_block.html")), (
"table",
TableBlock(
template="styleguide2/includes/atoms/table/table.html",
label="Tabulka"
)
),
("gallery", GalleryBlock(label="Galerie")), ("gallery", GalleryBlock(label="Galerie")),
("figure", FigureBlock()), ("figure", FigureBlock()),
("card", CardBlock()), ("card", CardBlock()),
...@@ -1102,5 +1033,4 @@ DEFAULT_CONTENT_BLOCKS = [ ...@@ -1102,5 +1033,4 @@ DEFAULT_CONTENT_BLOCKS = [
("map_collection", MapFeatureCollectionBlock(label="Mapová kolekce")), ("map_collection", MapFeatureCollectionBlock(label="Mapová kolekce")),
("button", ButtonBlock()), ("button", ButtonBlock()),
("button_group", ButtonGroupBlock()), ("button_group", ButtonGroupBlock()),
("image_banner", ImageBannerBlock()),
] ]
...@@ -44,13 +44,6 @@ class CTAMixin(StructBlock): ...@@ -44,13 +44,6 @@ class CTAMixin(StructBlock):
label = "Tlačítko s odkazem" label = "Tlačítko s odkazem"
class MainButtonBlock(CTAMixin):
class Meta:
icon = "doc-empty"
label = "Tlačítko s odkazem"
template = "styleguide2/includes/atoms/buttons/round_button_block.html"
class LinkBlock(StructBlock): class LinkBlock(StructBlock):
text = CharBlock(label="Název") text = CharBlock(label="Název")
link = URLBlock(label="Odkaz") link = URLBlock(label="Odkaz")
...@@ -263,18 +256,6 @@ class PeopleOverviewBlock(StructBlock): ...@@ -263,18 +256,6 @@ class PeopleOverviewBlock(StructBlock):
label = "Skupina osob" label = "Skupina osob"
# Buttons
class MainButtonGroupBlock(StructBlock):
buttons = ListBlock(MainButtonBlock(label="Tlačítko"), label="Tlačítka")
class Meta:
template = "styleguide2/includes/atoms/buttons/group.html"
icon = "group"
label = "Skupina tlačítek"
# Program # Program
......
from .base import * # noqa from .legacy import * # noqa
from .main import * # noqa from .main import * # noqa
This diff is collapsed.
import logging
from urllib.parse import quote
from django.db import models
from django.utils import timezone
from modelcluster.fields import ParentalManyToManyField
from wagtail.admin.panels import FieldPanel, PublishingPanel
from wagtail.fields import StreamField
from wagtail.models import Page
from wagtail.search import index
from shared.blocks import DEFAULT_CONTENT_BLOCKS, FooterLinksBlock
from .main import ArticlesMixin
logger = logging.getLogger(__name__)
# --- BEGIN Migrated models ---
class ArticleMixin(models.Model):
"""
Common fields for articles.
Must be used in class definition before MetadataPageMixin!
If you want to tag articles, add tags as `tags` field in article page model.
"""
### FIELDS
content = StreamField(
DEFAULT_CONTENT_BLOCKS,
verbose_name="Článek",
blank=True,
use_json_field=True,
)
timestamp = models.DateTimeField("Datum a čas", default=timezone.now)
perex = models.TextField("perex")
author = models.CharField("autor", max_length=250, blank=True, null=True)
image = models.ForeignKey(
"wagtailimages.Image",
on_delete=models.PROTECT,
blank=True,
null=True,
verbose_name="obrázek",
)
"""
Hidden field describing the source of shared articles, can be of values "district", "uniweb", "elections"
or "main", depending on from which type of site this article was shared from
"""
shared_type = models.TextField(null=True, blank=True)
"""
Hidden field which links to a Page model of ArticlesMixin page to which this article was shared.
Example: DistrictArticlesPage has shared tag "main", which this article shares as well -> shared_from will contain a reference to DistrictArticlesPage
"""
shared_from = models.ForeignKey(
Page,
null=True,
blank=True,
related_name="+",
on_delete=models.PROTECT,
)
search_fields = Page.search_fields + [
index.SearchField("title"),
index.SearchField("author"),
index.SearchField("perex"),
index.SearchField("content"),
]
### PANELS
content_panels = Page.content_panels + [
FieldPanel("timestamp"),
FieldPanel("perex"),
FieldPanel("content"),
FieldPanel("author"),
FieldPanel("image"),
]
settings_panels = [PublishingPanel()]
class Meta:
abstract = True
@property
def get_original_url(self):
return self.full_url
@property
def get_no_index(self):
"""
Indicates that a link to self should contain rel="noindex"
"""
return self.shared_from is not None
@property
def get_rel(self):
"""
Returns "rel" property for a link to this article
"""
return "rel=noindex" if self.get_no_index else ""
@property
def date(self):
"""
Returns the date of this article's timestamp.
"""
return self.timestamp.date()
def get_url(self, request=None):
# 'request' kwarg for Wagtail compatibility
if self.shared_from is not None:
return f"{self.shared_from.url}sdilene?sdilene={quote(self.slug)}"
return self.url
def get_full_url(self, request=None):
# 'request' kwarg for Wagtail compatibility
if self.shared_from is not None:
return f"{self.shared_from.full_url}sdilene?sdilene={quote(self.slug)}"
return self.full_url
@property
def articles_page(self):
"""
Returns articles page on which this article is displayed
"""
return (
self.shared_from.get_specific()
if self.shared_from
else self.get_parent().get_specific()
)
@property
def root_page(self):
"""
Returns root page of article, or a root page of Articles page to which this article was shared
"""
if self.shared_from is None:
return self.get_parent().get_ancestors().specific().live().last()
return self.shared_from.get_specific().root_page
@property
def get_tags(self):
"""
Returns all tags, including tags of shared articles from another site
"""
if self.shared_from is not None:
return self.articles_page.search_tags_by_unioned_id_query([self])
return self.tags.all()
@classmethod
def has_tags(cls):
try:
cls._meta.get_field("tags")
except models.FieldDoesNotExist:
return False
return True
def get_meta_image(self):
if hasattr(self, "search_image") and self.search_image:
return self.search_image
return self.image
def get_meta_description(self):
if hasattr(self, "search_description") and self.search_description:
return self.search_description
return self.perex
class FooterMixin(models.Model):
footer_links = StreamField(
[
("footer_links", FooterLinksBlock()),
],
verbose_name="Odkazy v zápatí webu",
blank=True,
max_num=1,
use_json_field=True,
)
class Meta:
abstract = True
class ArticlesPageMixin(ArticlesMixin, models.Model):
def get_shared_tags(self):
"""
Overrides get_shared_tags from ArticlesMixin, returns shared tags
"""
return self.shared_tags
shared_tags = ParentalManyToManyField(
"shared.SharedTag",
verbose_name="Výběr tagů pro články sdílené mezi sítěmi",
help_text="Pro výběr jednoho tagu klikněte na tag a uložte nebo publikujte stránku. Pro výběr více tagů využijte podržte Ctrl a vyberte příslušné tagy.",
blank=True,
)
content_panels = Page.content_panels + [FieldPanel("shared_tags")]
class Meta:
abstract = True
# --- END Migrated models ---
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
{% load table_block_tags shared_filters %} {% load table_block_tags shared_filters %}
<div class="my-6"> <div class="my-6 prose">
<table class="table table--bordered content-block"> <table>
{% if table_caption %} {% if table_caption %}
<caption class="head-heavy-sm my-4">{{ table_caption }}</caption> <caption class="head-heavy-sm my-4">{{ table_caption }}</caption>
{% endif %} {% endif %}
......
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
{% if download_link %} {% if download_link %}
<div class="inline-block py-8"> <div class="inline-block py-8">
{% include "styleguide2/includes/atoms/buttons/round_button.html" with button_text="Stáhnout dokument" url=page.pdf_url %} {% include "styleguide2/includes/atoms/buttons/round_button.html" with text="Stáhnout dokument" url=page.pdf_url show_arrow_on_hover=True %}
</div> </div>
{% endif %} {% endif %}
{% endblock %} {% endblock %}
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
<img class="w-full h-48 object-cover" src="{{ img.url }}" alt="{{ img.alt }}" /> <img class="w-full h-48 object-cover" src="{{ img.url }}" alt="{{ img.alt }}" />
{% endif %} {% endif %}
{% endif %} {% endif %}
<div class="card__body"> <div class="card__body">
{% if self.headline %} {% if self.headline %}
<h1 class="card-headline mb-2"> <h1 class="card-headline mb-2">
......
{% load wagtailimages_tags %} {% load wagtailimages_tags %}
<div class="w-full grid grid-cols-4 gap-4">
<div
class="
flex flex-wrap items-center gap-2 my-8 justify-center
lg:justify-start
"
>
{% for picture in self.gallery_items %} {% for picture in self.gallery_items %}
{% image picture width-2000 as img %} {% image picture width-2000 as img %}
{% image picture fill-300x200 as thumb %} {% image picture fill-300x200 as thumb %}
<div> <a
<a data-fancybox="gallery" href="{{ img.url }}"><img data-src="{{ thumb.url }}" class="lazyload img-fluid" alt="{{ thumb.alt }}"></a> class="w-40"
</div> href="{{ img.url }}"
data-fancybox="gallery"
data-caption="{{ thumb.alt }}"
>
<img class="rounded" src="{{ thumb.url }}" alt="thumb.alt" />
</a>
{% endfor %} {% endfor %}
</div> </div>
{% load wagtailimages_tags %} {% load wagtailimages_tags %}
<div class="mb-10 text-center youtube-poster" id="ytVideo{{ self.video_id }}PosterContainer"> <div class="mb-10 text-center youtube-poster" id="ytVideo{{ self.video_id }}PosterContainer">
{% image self.poster_image width-720 as img %} {% image self.poster_image width-720 as img %}
<img src="{{ img.url }}" alt="{{ img.alt }}" class="w-full object-cover mb-2"> <img src="{{ img.url }}" alt="{{ img.alt }}" class="w-full object-cover mb-2">
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
{% endfor %} {% endfor %}
<div class="flex justify-start"> <div class="flex justify-start">
{% include 'styleguide2/includes/atoms/buttons/round_button.html' with url=page.root_page.articles_page.url button_text='Zpět na aktuality' %} {% include 'styleguide2/includes/atoms/buttons/round_button.html' with url=page.root_page.articles_page.url text='Zpět na aktuality' show_arrow_on_hover=True %}
</div> </div>
</div> </div>
</main> </main>
......
...@@ -22,7 +22,9 @@ ...@@ -22,7 +22,9 @@
<!-- Styles --> <!-- Styles -->
<link rel="stylesheet" href="{% static 'styleguide2/main.css' %}"> <link rel="stylesheet" href="{% static 'styleguide2/main.css' %}">
{% include "maps_utils/includes/styles.html" %}
<!--TODO - Migrate to styleguide-->
{% block styles %}{% endblock styles %} {% block styles %}{% endblock styles %}
{% if page.root_page.matomo_id %} {% if page.root_page.matomo_id %}
...@@ -39,6 +41,9 @@ ...@@ -39,6 +41,9 @@
<script src="{% static 'styleguide2/main.js' %}"></script> <script src="{% static 'styleguide2/main.js' %}"></script>
<!--TODO - Migrate to styleguide-->
{% include "maps_utils/includes/scripts.html" %}
{% block scripts %}{% endblock scripts %} {% block scripts %}{% endblock scripts %}
</body> </body>
</html> </html>
...@@ -13,10 +13,27 @@ ...@@ -13,10 +13,27 @@
{% block size_classes %} {% block size_classes %}
pl-8 pr-3 py-3 pl-8 pr-3 py-3
xl:text-lg xl:pl-8 xl:pr-3 xl:py-4 xl:text-lg
{% if show_arrow_on_hover %}
xl:pl-8 xl:pr-3
{% else %}
xl:px-8
{% endif %}
xl:py-4
{% endblock %} {% endblock %}
" "
> >
<span class="group-hover:-translate-x-2 duration-200">{{ button_text }}</span> <span
{% if show_arrow_on_hover %}
class="
group-hover:-translate-x-2 duration-200
"
{% endif %}
>{{ text }}</span>
{% if show_arrow_on_hover %}
<span class="opacity-0 group-hover:opacity-100 duration-200 mb-[0.03rem]">{% include 'styleguide2/includes/atoms/icons/arrow.html' %}</span> <span class="opacity-0 group-hover:opacity-100 duration-200 mb-[0.03rem]">{% include 'styleguide2/includes/atoms/icons/arrow.html' %}</span>
{% endif %}
</{% block element_closer %}a{% endblock %}> </{% block element_closer %}a{% endblock %}>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment