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

elections2021: Government team page

parent cb6a586c
No related branches found
No related tags found
2 merge requests!316Release,!315elections2021: Government team page
Pipeline #4511 passed
# Generated by Django 3.2.4 on 2021-07-15 11:48
import django.db.models.deletion
import wagtail.core.blocks
import wagtail.core.fields
import wagtail.images.blocks
import wagtailmetadata.models
from django.db import migrations, models
import shared.models
class Migration(migrations.Migration):
dependencies = [
("wagtailcore", "0062_comment_models_and_pagesubscription"),
("wagtailimages", "0023_add_choose_permissions"),
("elections2021", "0032_auto_20210625_1540"),
]
operations = [
migrations.CreateModel(
name="Elections2021GovernmentTeamPage",
fields=[
(
"page_ptr",
models.OneToOneField(
auto_created=True,
on_delete=django.db.models.deletion.CASCADE,
parent_link=True,
primary_key=True,
serialize=False,
to="wagtailcore.page",
),
),
(
"sections",
wagtail.core.fields.StreamField(
[
(
"section",
wagtail.core.blocks.StructBlock(
[
(
"title",
wagtail.core.blocks.CharBlock(
label="název"
),
),
(
"members",
wagtail.core.blocks.ListBlock(
wagtail.core.blocks.StructBlock(
[
(
"name",
wagtail.core.blocks.CharBlock(
label="jméno"
),
),
(
"photo",
wagtail.images.blocks.ImageChooserBlock(
label="fotka"
),
),
(
"occupation",
wagtail.core.blocks.CharBlock(
label="povolání"
),
),
(
"resume",
wagtail.core.blocks.TextBlock(
label="medailonek"
),
),
]
)
),
),
]
),
)
],
blank=True,
verbose_name="sekce vládního týmu",
),
),
(
"photo",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
to="wagtailimages.image",
verbose_name="hlavní fotka",
),
),
(
"search_image",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="+",
to="wagtailimages.image",
verbose_name="Search image",
),
),
],
options={
"verbose_name": "Vládní tým",
},
bases=(
shared.models.SubpageMixin,
wagtailmetadata.models.WagtailImageMetadataMixin,
"wagtailcore.page",
models.Model,
),
),
]
...@@ -142,6 +142,7 @@ class MenuItemBlock(blocks.StructBlock): ...@@ -142,6 +142,7 @@ class MenuItemBlock(blocks.StructBlock):
"elections2021.Elections2021StrategicPage", "elections2021.Elections2021StrategicPage",
"elections2021.Elections2021MythsPage", "elections2021.Elections2021MythsPage",
"elections2021.Elections2021DownloadsPage", "elections2021.Elections2021DownloadsPage",
"elections2021.Elections2021GovernmentTeamPage",
], ],
) )
...@@ -167,6 +168,7 @@ class SlideBlock(blocks.StructBlock): ...@@ -167,6 +168,7 @@ class SlideBlock(blocks.StructBlock):
"elections2021.Elections2021StrategicPage", "elections2021.Elections2021StrategicPage",
"elections2021.Elections2021MythsPage", "elections2021.Elections2021MythsPage",
"elections2021.Elections2021DownloadsPage", "elections2021.Elections2021DownloadsPage",
"elections2021.Elections2021GovernmentTeamPage",
], ],
required=False, required=False,
) )
...@@ -295,6 +297,7 @@ class Elections2021HomePage(MetadataPageMixin, RoutablePageMixin, Page): ...@@ -295,6 +297,7 @@ class Elections2021HomePage(MetadataPageMixin, RoutablePageMixin, Page):
"elections2021.Elections2021StrategicListPage", "elections2021.Elections2021StrategicListPage",
"elections2021.Elections2021MythsPage", "elections2021.Elections2021MythsPage",
"elections2021.Elections2021DownloadsPage", "elections2021.Elections2021DownloadsPage",
"elections2021.Elections2021GovernmentTeamPage",
] ]
### OTHERS ### OTHERS
...@@ -352,6 +355,10 @@ class Elections2021HomePage(MetadataPageMixin, RoutablePageMixin, Page): ...@@ -352,6 +355,10 @@ class Elections2021HomePage(MetadataPageMixin, RoutablePageMixin, Page):
def myths_page_url(self): def myths_page_url(self):
return get_subpage_url(self, Elections2021MythsPage) return get_subpage_url(self, Elections2021MythsPage)
@cached_property
def government_team_page_url(self):
return get_subpage_url(self, Elections2021GovernmentTeamPage)
@cached_property @cached_property
def gdpr_and_cookies_url(self): def gdpr_and_cookies_url(self):
if self.gdpr_and_cookies_page: if self.gdpr_and_cookies_page:
...@@ -2266,3 +2273,78 @@ class Elections2021DownloadsPage(SubpageMixin, MetadataPageMixin, Page): ...@@ -2266,3 +2273,78 @@ class Elections2021DownloadsPage(SubpageMixin, MetadataPageMixin, Page):
class Meta: class Meta:
verbose_name = "Soubory ke stažení" verbose_name = "Soubory ke stažení"
class GovernmentTeamMemberBlock(blocks.StructBlock):
name = blocks.CharBlock(label="jméno")
photo = ImageChooserBlock(label="fotka")
occupation = blocks.CharBlock(label="povolání")
resume = blocks.TextBlock(label="medailonek")
class Meta:
label = "člen vládního týmu"
icon = "user"
template = "elections2021/_government_team_member_block.html"
class GovernmentSectionBlock(blocks.StructBlock):
title = blocks.CharBlock(label="název")
members = blocks.ListBlock(GovernmentTeamMemberBlock())
class Meta:
label = "sekce vládního týmu"
icon = "group"
template = "elections2021/_government_section_block.html"
class Elections2021GovernmentTeamPage(SubpageMixin, MetadataPageMixin, Page):
### FIELDS
photo = models.ForeignKey(
"wagtailimages.Image",
on_delete=models.PROTECT,
blank=True,
null=True,
verbose_name="hlavní fotka",
)
sections = StreamField(
[("section", GovernmentSectionBlock())],
verbose_name="sekce vládního týmu",
blank=True,
)
### PANELS
content_panels = Page.content_panels + [
ImageChooserPanel("photo"),
StreamFieldPanel("sections"),
]
promote_panels = [
MultiFieldPanel(
[
FieldPanel("slug"),
FieldPanel("seo_title"),
FieldPanel("search_description"),
ImageChooserPanel("search_image"),
HelpPanel(help.build(help.NO_SEO_TITLE, NO_SEARCH_IMAGE_USE_PHOTO)),
],
gettext_lazy("Common page configuration"),
),
CommentPanel(),
]
settings_panels = []
### RELATIONS
parent_page_types = ["elections2021.Elections2021HomePage"]
subpage_types = []
### OTHERS
class Meta:
verbose_name = "Vládní tým"
def get_meta_image(self):
return self.search_image or self.photo
This diff is collapsed.
{% load wagtailcore_tags %}
<div id="{{ section.value.title|slugify }}">
<div class="government-section--title mb-5">
<span>{{ section.value.title }}</span>
</div>
{% for member in section.value.members %}
{% include_block member %}
{% endfor %}
</div>
{% load wagtailimages_tags %}
<div class="government-card w-full grid grid-cols-5 grid-flow-row gap-2 mt-8 mb-2 ">
<div class="col-span-2 md:col-span-1">
<div class="avatar avatar--md">
{% image member.photo fill-112x112 %}
</div>
</div>
<div class="col-span-3 md:col-span-4">
<p class="head-heavy-sm mt-2">{{ member.name }}</p>
<p class="para mt-2">{{ member.occupation }}</p>
</div>
<div class="col-span-1">
</div>
<div class="col-span-5 md:col-span-4">
<p class="para opacity-60">{{ member.resume }}</p>
</div>
</div>
<div>
<hr>
</div>
...@@ -70,6 +70,14 @@ ...@@ -70,6 +70,14 @@
</li> </li>
<li class="navbar-menu__item"> <li class="navbar-menu__item">
<a href="{{ page.root_page.candidates_list_page_url }}" class="navbar-menu__link">Vaši lidé</a></li> <a href="{{ page.root_page.candidates_list_page_url }}" class="navbar-menu__link">Vaši lidé</a></li>
{% comment %}
<ui-navbar-subitem label="Vaši lidé" href="{{ page.root_page.candidates_list_page_url }}">
<ul class="navbar-menu__submenu">
<li><a href="{{ page.root_page.candidates_list_page_url }}" class="navbar-menu__link">Kandidáti</a></li>
<li><a href="{{ page.root_page.government_team_page_url }}" class="navbar-menu__link">Vládní tým</a></li>
</ul>
</ui-navbar-subtitem>
{% endcomment %}
</li> </li>
<li class="navbar-menu__item"> <li class="navbar-menu__item">
<a href="{{ page.root_page.questions_page_url }}" class="navbar-menu__link">Časté dotazy</a> <a href="{{ page.root_page.questions_page_url }}" class="navbar-menu__link">Časté dotazy</a>
......
{% extends "elections2021/base.html" %}
{% load static wagtailcore_tags wagtailimages_tags %}
{% block content_header %}
{% include "elections2021/_page_header.html" with title=page.title photo=page.photo %}
{% endblock %}
{% block content %}
<div class="container container-default pt-16 pb-20 grid grid-cols-6 grid-flow-row gap-2">
<div class="col-span-6 xl:col-span-2 pl-5 relative">
<div class="floating-nav-wrapper floating-nav-wrapper--government hidden xl:block" id="floatingNavBarWrapper">
<div class="floating-nav-panel " id="floatingNavBar">
<div class="inner float-panel-inner elevation-2">
<ul>
{% for section in page.sections %}
<li><a href="#{{ section.value.title|slugify }}" class="">{{ section.value.title }}</a></li>
{% endfor %}
</ul>
</div>
</div>
</div>
<script>
window.addEventListener("load", onLoadFunction);
var anchorsArray = [];
function placeUponId(id, space) {
return document.getElementById(id).getBoundingClientRect().top + window.scrollY - space;
}
function onLoadFunction(e) {
var anchorElemsArray;
onResizeFunction();
for (const entry of anchorsArray) {
entry.menuitem.addEventListener("click", clickHandler);
}
function clickHandler(e) {
e.preventDefault();
var id = this.getAttribute("href").replace("#", "");
//console.log(placeUponId(id, 20));
scroll({
top: placeUponId(id, 20),
behavior: "smooth"
});
}
window.addEventListener("resize", onResizeFunction);
}
function onResizeFunction(e) {
var itemsProcessed = 0;
var anchorElemsArray = document.getElementsByClassName("float-panel-inner")[0].querySelectorAll("li a");
anchorsArray = [];
anchorElemsArray.forEach(function(entry) {
var id = entry.getAttribute("href").replace("#", "");
anchorsArray.push({
id: id,
top: placeUponId(id, 200),
menuitem: entry
});
itemsProcessed++;
if (itemsProcessed === anchorElemsArray.length) {
anchorsArray.reverse();
}
});
//console.log(anchorsArray);
}
window.onscroll = function() {
var top = window.pageYOffset || document.documentElement.scrollTop;
var activereached = false;
anchorsArray.forEach(function(entry) {
entry.menuitem.classList.remove("active");
entry.menuitem.classList.remove("passed");
if (top >= placeUponId(entry.id, 200)) {
if (activereached) entry.menuitem.classList.add("passed");
else entry.menuitem.classList.add("active");
activereached = true;
}
});
};
</script>
</div>
<div class="col-span-6 xl:col-span-4">
<div class="w-full xl:w-5/6">
{% for section in page.sections %}
{% include_block section %}
{% endfor %}
</div>
</div>
</div>
{% endblock %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment