Skip to content
Snippets Groups Projects
Commit c5f0fb93 authored by Ondrej Rehounek's avatar Ondrej Rehounek
Browse files

main: WIP models

parent 1d2da4a0
No related branches found
No related tags found
2 merge requests!607Pirati.cz,!575Feature/pirati cz
Pipeline #9121 passed
from wagtail.core.blocks import CharBlock, PageChooserBlock, StructBlock, URLBlock
# HomePageCarouselBlock
# RecentWork/TweetsBlock
# NewsBlock
......@@ -7,6 +9,27 @@
# WorkTimelineBlock
# ArticleLinkBlock
# ProgramBlock
# PersonBlock
class PersonContactBlock(StructBlock):
position = CharBlock(label="Název pozice", required=False)
# email, phone?
person = PageChooserBlock(
label="Osoba",
page_type=["district.DistrictPersonPage"],
)
class Meta:
icon = "user"
label = "Osoba s volitelnou pozicí"
class PersonContactBoxBlock(StructBlock):
title = CharBlock(label="Titulek")
subtitle = CharBlock(label="Podtitulek")
button_link = URLBlock()
button_text = CharBlock(label="Text tlačítka")
# TwitterCarouselBlock
# ContactBlock
from django.db import models
from django.shortcuts import render
from wagtail.admin.edit_handlers import FieldPanel, ObjectList, TabbedInterface
from wagtail.core.fields import RichTextField, StreamField
from wagtail.core.models import Page
from wagtailmetadata.models import MetadataPageMixin
from shared.models import ( # ArticleMixin,; ExtendedMetadataPageMixin,; SubpageMixin,
from shared.const import RICH_TEXT_DEFAULT_FEATURES
from shared.models import (
ExtendedMetadataHomePageMixin,
ExtendedMetadataPageMixin,
MenuMixin,
SubpageMixin,
)
from shared.utils import make_promote_panels
# from . import blocks
from . import blocks
class MainHomePage(MenuMixin, ExtendedMetadataHomePageMixin, MetadataPageMixin, Page):
......@@ -20,7 +25,11 @@ class MainHomePage(MenuMixin, ExtendedMetadataHomePageMixin, MetadataPageMixin,
)
# header - fb, twitter, insta, youtube, dary, nalodeni
# footer - stream field loadovany pres page.root_page?
footer = StreamField(
[("item", blocks.PersonContactBlock())],
verbose_name="Kontaktní boxy",
blank=True,
)
settings_panels = [FieldPanel("matomo_id")]
......@@ -41,7 +50,7 @@ class MainHomePage(MenuMixin, ExtendedMetadataHomePageMixin, MetadataPageMixin,
# MainProgramPage
# MainPeoplePage
# MainPersonPage
# MainContactPage
"main.MainContactPage"
]
### OTHERS
......@@ -56,3 +65,41 @@ class MainHomePage(MenuMixin, ExtendedMetadataHomePageMixin, MetadataPageMixin,
@property
def root_page(self):
return self
class MainContactPage(ExtendedMetadataPageMixin, SubpageMixin, MetadataPageMixin, Page):
### FIELDS
contact_people = StreamField(
[("item", blocks.PersonContactBlock())],
verbose_name="Kontaktní osoby",
blank=True,
)
contact_boxes = StreamField(
[("item", blocks.PersonContactBlock())],
verbose_name="Kontaktní boxy",
blank=True,
)
text = RichTextField("Text", blank=True, features=RICH_TEXT_DEFAULT_FEATURES)
### PANELS
content_panels = Page.content_panels + [
FieldPanel("contact_people"),
FieldPanel("contact_boxes"),
FieldPanel("text"),
]
promote_panels = make_promote_panels()
settings_panels = []
### RELATIONS
parent_page_types = ["main.MainHomePage"]
subpage_types = []
### OTHERS
class Meta:
verbose_name = "Kontakty"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment