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

elections2021: Myths page

parent 9c949cfb
Branches
No related tags found
2 merge requests!302Release,!301Volby
# Generated by Django 3.2.4 on 2021-06-17 20:25
import django.db.models.deletion
import wagtail.core.blocks
import wagtail.core.fields
import wagtailmetadata.models
from django.db import migrations, models
import shared.models
class Migration(migrations.Migration):
dependencies = [
("wagtailimages", "0023_add_choose_permissions"),
("wagtailcore", "0062_comment_models_and_pagesubscription"),
("elections2021", "0029_auto_20210531_1612"),
]
operations = [
migrations.CreateModel(
name="Elections2021MythsPage",
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",
),
),
(
"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": "Nejčastější mýty",
},
bases=(
shared.models.SubpageMixin,
wagtailmetadata.models.WagtailImageMetadataMixin,
"wagtailcore.page",
models.Model,
),
),
migrations.CreateModel(
name="Elections2021MythPage",
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",
),
),
("perex", models.TextField(verbose_name="perex")),
(
"myth",
wagtail.core.fields.RichTextField(
blank=True, null=True, verbose_name="co se říká?"
),
),
(
"reality",
wagtail.core.fields.RichTextField(
blank=True,
null=True,
verbose_name="co ve skutečnosti prosazujeme",
),
),
(
"related_points",
wagtail.core.fields.StreamField(
[
(
"point",
wagtail.core.blocks.PageChooserBlock(
label="programový bod",
page_type=[
"elections2021.Elections2021ProgramPointPage"
],
),
)
],
blank=True,
verbose_name="související programové body",
),
),
(
"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": "Mýtus",
},
bases=(
shared.models.SubpageMixin,
wagtailmetadata.models.WagtailImageMetadataMixin,
"wagtailcore.page",
models.Model,
),
),
]
......@@ -288,6 +288,7 @@ class Elections2021HomePage(MetadataPageMixin, RoutablePageMixin, Page):
"elections2021.Elections2021ProgramAppPage",
"elections2021.Elections2021TextPage",
"elections2021.Elections2021StrategicListPage",
"elections2021.Elections2021MythsPage",
]
### OTHERS
......@@ -2077,3 +2078,109 @@ class Elections2021StrategicPage(SubpageMixin, MetadataPageMixin, Page):
if block.block_type == "title":
context["navigation"].append((slugify(block.value), block.value))
return context
class Elections2021MythsPage(SubpageMixin, MetadataPageMixin, Page):
### FIELDS
### PANELS
promote_panels = [
MultiFieldPanel(
[
FieldPanel("slug"),
FieldPanel("seo_title"),
FieldPanel("search_description"),
ImageChooserPanel("search_image"),
HelpPanel(help.build(help.NO_SEO_TITLE)),
],
gettext_lazy("Common page configuration"),
),
CommentPanel(),
]
settings_panels = []
### RELATIONS
parent_page_types = ["elections2021.Elections2021HomePage"]
subpage_types = ["elections2021.Elections2021MythPage"]
### OTHERS
class Meta:
verbose_name = "Nejčastější mýty"
def get_context(self, request):
context = super().get_context(request)
context["myths"] = self.get_children().live().specific()
return context
class Elections2021MythPage(SubpageMixin, MetadataPageMixin, Page):
### FIELDS
perex = models.TextField("perex")
myth = RichTextField(
"co se říká?", blank=True, null=True, features=STRATEGIC_RICH_TEXT_FEATURES
)
reality = RichTextField(
"co ve skutečnosti prosazujeme",
blank=True,
null=True,
features=STRATEGIC_RICH_TEXT_FEATURES,
)
related_points = StreamField(
[
(
"point",
blocks.PageChooserBlock(
label="programový bod",
page_type=["elections2021.Elections2021ProgramPointPage"],
),
)
],
verbose_name="související programové body",
blank=True,
)
### PANELS
content_panels = Page.content_panels + [
FieldPanel("perex"),
FieldPanel("myth"),
FieldPanel("reality"),
StreamFieldPanel("related_points"),
]
promote_panels = [
MultiFieldPanel(
[
FieldPanel("slug"),
FieldPanel("seo_title"),
FieldPanel("search_description"),
HelpPanel(help.build(help.NO_SEO_TITLE, help.NO_DESCRIPTION_USE_PEREX)),
],
gettext_lazy("Common page configuration"),
),
CommentPanel(),
]
settings_panels = []
### RELATIONS
parent_page_types = ["elections2021.Elections2021MythsPage"]
subpage_types = []
### OTHERS
class Meta:
verbose_name = "Mýtus"
def get_meta_description(self):
if self.search_description:
return self.search_description
if len(self.perex) > 150:
return str(self.perex)[:150] + "..."
return self.perex
Source diff could not be displayed: it is too large. Options to address this: view the blob.
<svg id="Group_303" data-name="Group 303" xmlns="http://www.w3.org/2000/svg" width="155.491" height="155.491" viewBox="0 0 155.491 155.491">
<path id="Path_165" data-name="Path 165" d="M77.746,0a77.746,77.746,0,1,0,77.746,77.746A77.835,77.835,0,0,0,77.746,0Zm0,136.055A58.377,58.377,0,0,1,19.436,77.746,57.561,57.561,0,0,1,30.23,43.975l81.285,81.285A57.561,57.561,0,0,1,77.746,136.055Zm47.515-24.539L43.975,30.23a57.561,57.561,0,0,1,33.77-10.794,58.377,58.377,0,0,1,58.309,58.309A57.561,57.561,0,0,1,125.261,111.516Z"/>
</svg>
{% load wagtailcore_tags elections2021_extras %}
<a class="hover:no-underline block" href="{% pageurl point %}">
<div class="h-full card icon-card shadow-none bg-grey-125 card--hoveractive hover:elevation-0 hover:bg-acidgreen" data-archetype="{% if show_archetype_icon %}{{ point.archetype }}{% endif %}">
<div class="card__body">
<h1 class="card-headline mb-8">{{ point.title }}</h1>
<div class="card-body-text">{{ point.annotation|richtext|strip_sup }}</div>
</div>
</div>
</a>
{% extends "elections2021/base.html" %}
{% load wagtailcore_tags %}
{% block content %}
<div class="container container--default pt-8 pb-20">
<article>
<header class="w-full">
<div class="pb-2 mt-10 mb-14">
<h1 class="head-alt-md md:head-alt-lg head-alt-highlighted max-w-md mb-4">{{ page.title }}</h1>
</div>
</header>
<div class="mb-16 h-full card shadow-none bg-lemon">
<div class="card__body p-6 sm:p-10">
<h1 class="head-alt-md card-headline mb-8">Co ve skutečnosti prosazujeme?</h1>
<div class="content-block">{{ page.reality|richtext }}</div>
</div>
</div>
<div class="mb-20">
<h2 class="head-alt-md mb-8">Co se říká?</h2>
<div class="content-block">{{ page.myth|richtext }}</div>
</div>
</article>
{% if page.related_points %}
<h2 class="head-alt-md mb-8">Najděte si to v programu</h2>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8 mb-16">
{% for point in page.related_points %}
{% include "elections2021/_program_point_block.html" with point=point.value show_archetype_icon=1 %}
{% endfor %}
</div>
{% endif %}
<h2 class="head-alt-sm mb-8">Sdílet</h2>
<div class="social-icon-group space-x-0/5 ">
<a href="https://www.facebook.com/sharer/sharer.php?u={{ page.full_url|urlencode }}"
onclick="window.open(this.href, 'pop-up', 'left=20,top=20,width=500,height=500,toolbar=1,resizable=0'); return false;"
class="social-icon social-icon--fill bg-brands-facebook text-white social-icon--5 rounded-none inline-block p-2 h-auto w-8 text-center box-content"><i class="ico--facebook align-middle relative -top-0.5"></i></a>
<a href="https://twitter.com/intent/tweet?text={{ page.title|urlencode }}&url={{ page.full_url|urlencode }}"
onclick="window.open(this.href, 'pop-up', 'left=20,top=20,width=500,height=500,toolbar=1,resizable=0'); return false;"
class="social-icon social-icon--fill bg-brands-twitter text-white social-icon--5 rounded-none inline-block p-2 h-auto w-8 text-center box-content"><i class="ico--twitter align-middle relative -top-0.5"></i></a>
{# TODO #}
{# <a href="#" class="social-icon social-icon--fill bg-brands-gmail text-white social-icon--5 rounded-none inline-block p-2 h-auto w-8 text-center box-content"><i class="ico--envelope align-middle relative -top-0.5"></i></a> #}
</div>
</div>
{% endblock %}
{% extends "elections2021/base.html" %}
{% load static wagtailcore_tags %}
{% block content_header %}
<article class=" relative bg-lemon md:bg-split-color px-4 md:pl-8 md:pr-0 2xl:px-8 hero py-0 w-full ">
<div class="2xl:container w-auto bg-lemon md:pl-20 pr-0 grid lg:grid-rows-1 h-40 sm:h-56 md:h-64 lg:grid-cols-7 items-center 2xl:mx-auto">
<div class="lg:row-span-1 lg:col-span-4 order-1 md:pr-20">
<h1 class="head-alt-md sm:head-alt-lg pt-1 max-w-xs">{{ page.title }}</h1>
</div>
<div class="text-center hidden lg:block lg:row-span-2 lg:col-span-3 order-2 h-full 2xl:absolute 2xl:right-0 2xl:w-1/3">
<img class="h-54 py-12 inline-block" src="{% static "elections2021/images/archetype/hoax.svg" %}">
</div>
</div>
</article>
{% endblock %}
{% block content %}
<div class="container container--default pt-8 pb-16 lg:py-24">
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
{% for myth in myths %}
<a class="hover:no-underline block" href="{% pageurl myth %}">
<div class="h-full card icon-card shadow-none bg-grey-125 card--hoveractive hover:elevation-0 hover:bg-acidgreen" data-archetype="hoax">
<div class="card__body">
<h1 class="card-headline mb-8">{{ myth.title }}</h1>
<div class="card-body-text">{{ myth.perex|richtext }}</div>
</div>
</div>
</a>
{% endfor %}
</div>
</div>
{% endblock %}
......@@ -107,14 +107,7 @@
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8 pt-8">
{% for point in points %}
<a class="hover:no-underline block" href="{% pageurl point %}">
<div class="h-full card icon-card shadow-none bg-grey-125 card--hoveractive hover:elevation-0 hover:bg-acidgreen" data-archetype="{% if show_archetype_icon %}{{ point.archetype }}{% endif %}">
<div class="card__body">
<h1 class="card-headline mb-8">{{ point.title }}</h1>
<div class="card-body-text">{{ point.annotation|richtext|strip_sup }}</div>
</div>
</div>
</a>
{% include "elections2021/_program_point_block.html" %}
{% if show_app_banner %}
{% if forloop.counter == 3 or forloop.counter < 3 and forloop.last %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment