diff --git a/main/menu.py b/main/menu.py new file mode 100644 index 0000000000000000000000000000000000000000..2003749f8f47219e7256782ef8bbb6d9a6b56060 --- /dev/null +++ b/main/menu.py @@ -0,0 +1,29 @@ +from wagtail.core.fields import StreamField + +from shared.blocks import MenuItemBlock as MenuItemBlockBase +from shared.models import MenuMixin as MenuMixinBase + + +class MenuItemBlock(MenuItemBlockBase): + class Meta: + label = "Položka v menu" + template = "main/includes/menu_item.html" + + +# +# +# class MenuParentBlock(MenuParentBlockBase): +# class Meta: +# label = "Podmenu" +# template = "styleguide/2.3.x/menu_parent.html" + + +class MenuMixin(MenuMixinBase): + menu = StreamField( + [("menu_item", MenuItemBlock())], # , ("menu_parent", MenuParentBlock()) + verbose_name="Menu", + blank=True, + ) + + class Meta: + abstract = True diff --git a/main/migrations/0008_alter_mainhomepage_menu.py b/main/migrations/0008_alter_mainhomepage_menu.py new file mode 100644 index 0000000000000000000000000000000000000000..39b876dc6513fb0a3695784fccd3f682843ec0f2 --- /dev/null +++ b/main/migrations/0008_alter_mainhomepage_menu.py @@ -0,0 +1,51 @@ +# Generated by Django 4.0.7 on 2022-08-23 14:46 + +import wagtail.blocks +import wagtail.fields +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("main", "0007_mainarticlepage_region_and_more"), + ] + + operations = [ + migrations.AlterField( + model_name="mainhomepage", + name="menu", + field=wagtail.fields.StreamField( + [ + ( + "menu_item", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + label="Titulek", required=True + ), + ), + ( + "page", + wagtail.blocks.PageChooserBlock( + label="Stránka", required=False + ), + ), + ( + "link", + wagtail.blocks.URLBlock( + label="Odkaz", required=False + ), + ), + ] + ), + ) + ], + blank=True, + use_json_field=None, + verbose_name="Menu", + ), + ), + ] diff --git a/main/models.py b/main/models.py index 9c3d90af93de6ffab16685607e884a13162cdb5a..40999296e67cdad6f617e2d3c2ae7cb65bb1a4f1 100644 --- a/main/models.py +++ b/main/models.py @@ -20,11 +20,10 @@ from wagtailmetadata.models import MetadataPageMixin from elections2021.constants import REGION_CHOICES # pozor, import ze sousedního modulu from shared.const import RICH_TEXT_DEFAULT_FEATURES from shared.forms import SubscribeForm -from shared.models import ( +from shared.models import ( # MenuMixin, ArticleMixin, ExtendedMetadataHomePageMixin, ExtendedMetadataPageMixin, - MenuMixin, SubpageMixin, ) from shared.utils import make_promote_panels, subscribe_to_newsletter @@ -32,6 +31,7 @@ from tuning import admin_help from twitter_utils.models import Tweet from . import blocks +from .menu import MenuMixin class MainHomePage(MenuMixin, ExtendedMetadataHomePageMixin, MetadataPageMixin, Page): diff --git a/main/templates/main/includes/layout/header.html b/main/templates/main/includes/layout/header.html index caa0fee2b2840fb5e97dc8d053afd2de414de6e4..d38a764c0b630a80edf483b3069c4a8edbb8304f 100644 --- a/main/templates/main/includes/layout/header.html +++ b/main/templates/main/includes/layout/header.html @@ -1,9 +1,9 @@ -{% load static %} +{% load static wagtailcore_tags %} <!-- Navbar --> <nav class="navbar-background bg-black xl:duration-200 xl:bg-transparent xl:absolute xl:z-50 xl:w-full hover:bg-black"> <!-- Logo --> - <a href="" class="menu-flag flex justify-center flag bg-white my-2 p-1 main-menu__logo xl:my-3"> + <a href="/" class="menu-flag flex justify-center flag bg-white my-2 p-1 main-menu__logo xl:my-3"> <img src="{% static "shared/img/logo-full-black.svg" %}" alt=""> </a> <!-- Flex container --> @@ -16,11 +16,9 @@ </label> <!-- Menu --> <div class="main-menu__main main-menu-items space-x-3 2xl:space-x-6 xl:flex"> - <a href="#" class="menu-link">Jak pracujeme</a> - <a href="#" class="menu-link">Program</a> - <a href="#" class="menu-link">O nás</a> - <a href="#" class="menu-link">Naloď se</a> - <a href="#" class="menu-link">Kontakty</a> + {% for block in page.root_page.menu %} + {% include_block block %} + {% endfor %} </div> <!-- Buttons & Social--> <div class="main-menu__external main-menu-items items-center space-x-1 2xl:space-x-3 xl:flex"> diff --git a/main/templates/main/includes/menu_item.html b/main/templates/main/includes/menu_item.html new file mode 100644 index 0000000000000000000000000000000000000000..de4d8a39fb8c394fe976708e9f4f88f32e24cad5 --- /dev/null +++ b/main/templates/main/includes/menu_item.html @@ -0,0 +1,4 @@ +{% firstof self.page.url self.link as target %} +<a href="{{ target }}" class="menu-link"> + {{ self.title }} +</a> diff --git a/main/templates/main/main_home_page.html b/main/templates/main/main_home_page.html index 98b93b0abbbce3687003d5212d3a4f82a6e6cfb3..7004c81bfa14429e5a4a1b61125cdb63e85a4170 100644 --- a/main/templates/main/main_home_page.html +++ b/main/templates/main/main_home_page.html @@ -1,10 +1,10 @@ {% extends "main/base.html" %} +{% load wagtailcore_tags %} {% block content %} <main role="main"> - <div class="__js-root"> - <ui-header-carousel></ui-header-carousel> - </div> -</main> - + {% for block in page.content %} + {% include_block block %} + {% endfor %} + </main> {% endblock %}