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

elections2021: Program page with resorts and plans

parent f5b8bbc3
No related branches found
No related tags found
2 merge requests!231Test,!229Volby
Pipeline #3595 passed
This commit is part of merge request !229. Comments created here will be created in the context of that merge request.
Showing
with 611 additions and 44 deletions
...@@ -150,3 +150,4 @@ static_files/ ...@@ -150,3 +150,4 @@ static_files/
update_election_statics.sh update_election_statics.sh
download_static.sh download_static.sh
matice.csv
...@@ -51,9 +51,9 @@ RESTRICTED_FEATURES = ["superscript", "italic", "link"] ...@@ -51,9 +51,9 @@ RESTRICTED_FEATURES = ["superscript", "italic", "link"]
STANDARD_FEATURES = ["h4", "ul-elections2021", "superscript", "link", "italic"] STANDARD_FEATURES = ["h4", "ul-elections2021", "superscript", "link", "italic"]
EXTRA_FEATURES = ["h4", "ul-program-elections2021", "superscript", "link", "italic"] EXTRA_FEATURES = ["h4", "ul-program-elections2021", "superscript", "link", "italic"]
ARTICLES_PER_PAGE = 9 ARTICLES_PER_PAGE = 9
TOP_CANDIDATES_NUM = 12 TOP_CANDIDATES_NUM = 12
PROGRAM_POINTS_PER_PAGE = 12
REGION_PHA = "PHA" REGION_PHA = "PHA"
REGION_JHC = "JHC" REGION_JHC = "JHC"
...@@ -147,28 +147,89 @@ TARGET_CHOICES = ( ...@@ -147,28 +147,89 @@ TARGET_CHOICES = (
(EDUCATION, "vzdělávání"), (EDUCATION, "vzdělávání"),
) )
PLAN_ECONOMICS = "plan_economics" PLAN_ECONOMICS = "moderni-ekonomika"
PLAN_DIGITAL = "plan_digital" PLAN_DIGITAL = "digitalni-revoluce"
PLAN_CORRUPTION = "plan_corruption" PLAN_CORRUPTION = "razantni-boj-s-korupci"
PLAN_CLIMATE = "plan_climate" PLAN_CLIMATE = "duraz-na-klima"
PLAN_COUNTRYSIDE = "plan_countryside" PLAN_COUNTRYSIDE = "rovnocene-regiony"
PLAN_MANAGEMENT = "plan_management" PLAN_MANAGEMENT = "profesionalni-stat"
PLAN_SAFE_COUNTRY = "sebevedoma-a-bezpecna-zeme"
MINISTRY_TRANSPORT = "ministry_transport" PLAN_CARE = "jistota-pece-a-pomoci"
MINISTRY_FINANCES = "ministry_finances"
MINISTRY_CULTURE = "ministry_culture" PLAN_CHOICES = (
MINISTRY_DEFENSE = "ministry_defense" (PLAN_ECONOMICS, "Moderní ekonomika"),
MINISTRY_SOCIAL = "ministry_social" (PLAN_DIGITAL, "Digitální revoluce"),
MINISTRY_COUNTRYSIDE = "ministry_countryside" (PLAN_CORRUPTION, "Razantní boj s korupcí"),
MINISTRY_BUSINESS = "ministry_business" (PLAN_CLIMATE, "Důraz na klima"),
MINISTRY_JUSTICE = "ministry_justice" (PLAN_COUNTRYSIDE, "Rovnocenné regiony"),
MINISTRY_SCHOOLS = "ministry_schools" (PLAN_MANAGEMENT, "Profesionální stát"),
MINISTRY_INTERIOR = "ministry_interior" (PLAN_SAFE_COUNTRY, "Sebevědomá a bezpečná země"),
MINISTRY_FOREIGN = "ministry_foreign" (PLAN_CARE, "Jistota péče a pomoci"),
MINISTRY_HEALTH = "ministry_health" )
MINISTRY_AGRICULTURE = "ministry_agriculture"
MINISTRY_ENVIRONMENT = "ministry_environment" PLAN_OPTIONS = [code for code, _ in PLAN_CHOICES]
PLAN_ARCHETYPES = {
PLAN_ECONOMICS: "finance",
PLAN_DIGITAL: "vnitro",
PLAN_CORRUPTION: "spravedlnost",
PLAN_CLIMATE: "prostredi",
PLAN_COUNTRYSIDE: "rozvoj",
PLAN_MANAGEMENT: "prumysl",
PLAN_SAFE_COUNTRY: "obrana",
PLAN_CARE: "prace",
}
MINISTRY_TRANSPORT = "doprava"
MINISTRY_FINANCES = "finance"
MINISTRY_CULTURE = "kultura"
MINISTRY_DEFENSE = "obrana"
MINISTRY_SOCIAL = "prace-a-socialni-veci"
MINISTRY_COUNTRYSIDE = "mistni-rozvoj"
MINISTRY_BUSINESS = "prumysl-a-obchod"
MINISTRY_JUSTICE = "spravedlnost"
MINISTRY_SCHOOLS = "skolstvi-mladez-a-telovychova"
MINISTRY_INTERIOR = "vnitro"
MINISTRY_FOREIGN = "zahranicni-veci"
MINISTRY_HEALTH = "zdravotnictvi"
MINISTRY_AGRICULTURE = "zemedelstvi"
MINISTRY_ENVIRONMENT = "zivotni-prostredi"
MINISTRY_CHOICES = (
(MINISTRY_TRANSPORT, "Doprava"),
(MINISTRY_FINANCES, "Finance"),
(MINISTRY_CULTURE, "Kultura"),
(MINISTRY_DEFENSE, "Obrana"),
(MINISTRY_SOCIAL, "Práce a sociální věci"),
(MINISTRY_COUNTRYSIDE, "Místní rozvoj"),
(MINISTRY_BUSINESS, "Průmysl a obchod"),
(MINISTRY_JUSTICE, "Spravedlnost"),
(MINISTRY_SCHOOLS, "Školství, mládež a tělovýchova"),
(MINISTRY_INTERIOR, "Vnitro"),
(MINISTRY_FOREIGN, "Zahraniční věci"),
(MINISTRY_HEALTH, "Zdravotnictví"),
(MINISTRY_AGRICULTURE, "Zemědělství"),
(MINISTRY_ENVIRONMENT, "Životní prostředí"),
)
MINISTRY_OPTIONS = [code for code, _ in MINISTRY_CHOICES]
MINISTRY_ARCHETYPES = {
MINISTRY_TRANSPORT: "doprava",
MINISTRY_FINANCES: "finance",
MINISTRY_CULTURE: "kultura",
MINISTRY_DEFENSE: "obrana",
MINISTRY_SOCIAL: "prace",
MINISTRY_COUNTRYSIDE: "rozvoj",
MINISTRY_BUSINESS: "prumysl",
MINISTRY_JUSTICE: "spravedlnost",
MINISTRY_SCHOOLS: "vzdelani",
MINISTRY_INTERIOR: "vnitro",
MINISTRY_FOREIGN: "vztahy",
MINISTRY_HEALTH: "zdravotnictvi",
MINISTRY_AGRICULTURE: "zemedelstvi",
MINISTRY_ENVIRONMENT: "prostredi",
}
BENEFITS = ( BENEFITS = (
# (id, název, pracovní název) # (id, název, pracovní název)
......
...@@ -28,12 +28,14 @@ from ...constants import ( ...@@ -28,12 +28,14 @@ from ...constants import (
MINISTRY_TRANSPORT, MINISTRY_TRANSPORT,
NATURE, NATURE,
PARENTS, PARENTS,
PLAN_CARE,
PLAN_CLIMATE, PLAN_CLIMATE,
PLAN_CORRUPTION, PLAN_CORRUPTION,
PLAN_COUNTRYSIDE, PLAN_COUNTRYSIDE,
PLAN_DIGITAL, PLAN_DIGITAL,
PLAN_ECONOMICS, PLAN_ECONOMICS,
PLAN_MANAGEMENT, PLAN_MANAGEMENT,
PLAN_SAFE_COUNTRY,
SELF_EMPLOYED, SELF_EMPLOYED,
SENIORS, SENIORS,
SOCIALLY_WEAK, SOCIALLY_WEAK,
...@@ -51,7 +53,6 @@ FIELDNAMES = ( ...@@ -51,7 +53,6 @@ FIELDNAMES = (
OLD_TITLE, OLD_TITLE,
TITLE, TITLE,
"x2", "x2",
"x3",
CHILDLESS, CHILDLESS,
PARENTS, PARENTS,
MATURE, MATURE,
...@@ -74,6 +75,8 @@ FIELDNAMES = ( ...@@ -74,6 +75,8 @@ FIELDNAMES = (
PLAN_CLIMATE, PLAN_CLIMATE,
PLAN_COUNTRYSIDE, PLAN_COUNTRYSIDE,
PLAN_MANAGEMENT, PLAN_MANAGEMENT,
PLAN_SAFE_COUNTRY,
PLAN_CARE,
MINISTRY_TRANSPORT, MINISTRY_TRANSPORT,
MINISTRY_FINANCES, MINISTRY_FINANCES,
MINISTRY_CULTURE, MINISTRY_CULTURE,
...@@ -133,6 +136,8 @@ class Command(BaseCommand): ...@@ -133,6 +136,8 @@ class Command(BaseCommand):
page.weight_plan_climate = int(row[PLAN_CLIMATE]) page.weight_plan_climate = int(row[PLAN_CLIMATE])
page.weight_plan_countryside = int(row[PLAN_COUNTRYSIDE]) page.weight_plan_countryside = int(row[PLAN_COUNTRYSIDE])
page.weight_plan_management = int(row[PLAN_MANAGEMENT]) page.weight_plan_management = int(row[PLAN_MANAGEMENT])
page.weight_plan_safe_country = int(row[PLAN_SAFE_COUNTRY])
page.weight_plan_care = int(row[PLAN_CARE])
page.weight_ministry_transport = int(row[MINISTRY_TRANSPORT]) page.weight_ministry_transport = int(row[MINISTRY_TRANSPORT])
page.weight_ministry_finances = int(row[MINISTRY_FINANCES]) page.weight_ministry_finances = int(row[MINISTRY_FINANCES])
page.weight_ministry_culture = int(row[MINISTRY_CULTURE]) page.weight_ministry_culture = int(row[MINISTRY_CULTURE])
......
# Generated by Django 3.2.2 on 2021-05-13 21:01
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("elections2021", "0008_elections2021questionspage"),
]
operations = [
migrations.AddField(
model_name="elections2021programpointpage",
name="weight_plan_care",
field=models.IntegerField(default=0, verbose_name="váha plán jistota péče"),
),
migrations.AddField(
model_name="elections2021programpointpage",
name="weight_plan_safe_country",
field=models.IntegerField(
default=0, verbose_name="váha plán sebevědomá země"
),
),
]
# Generated by Django 3.2.2 on 2021-05-13 23:15
import wagtail.core.fields
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("elections2021", "0009_auto_20210513_2301"),
]
operations = [
migrations.AddField(
model_name="elections2021programpage",
name="plan_care_text",
field=wagtail.core.fields.RichTextField(
blank=True, null=True, verbose_name="Jistota péče a pomoci"
),
),
migrations.AddField(
model_name="elections2021programpage",
name="plan_climate_text",
field=wagtail.core.fields.RichTextField(
blank=True, null=True, verbose_name="Důraz na klima"
),
),
migrations.AddField(
model_name="elections2021programpage",
name="plan_corruption_text",
field=wagtail.core.fields.RichTextField(
blank=True, null=True, verbose_name="Razantní boj s korupcí"
),
),
migrations.AddField(
model_name="elections2021programpage",
name="plan_countryside_text",
field=wagtail.core.fields.RichTextField(
blank=True, null=True, verbose_name="Rovnocenné regiony"
),
),
migrations.AddField(
model_name="elections2021programpage",
name="plan_digital_text",
field=wagtail.core.fields.RichTextField(
blank=True, null=True, verbose_name="Digitální revoluce"
),
),
migrations.AddField(
model_name="elections2021programpage",
name="plan_economics_text",
field=wagtail.core.fields.RichTextField(
blank=True, null=True, verbose_name="Moderní ekonomika"
),
),
migrations.AddField(
model_name="elections2021programpage",
name="plan_management_text",
field=wagtail.core.fields.RichTextField(
blank=True, null=True, verbose_name="Profesionální stát"
),
),
migrations.AddField(
model_name="elections2021programpage",
name="plan_safe_country_text",
field=wagtail.core.fields.RichTextField(
blank=True, null=True, verbose_name="Sebevědomá a bezpečná země"
),
),
]
...@@ -18,6 +18,7 @@ from wagtail.admin.edit_handlers import ( ...@@ -18,6 +18,7 @@ from wagtail.admin.edit_handlers import (
StreamFieldPanel, StreamFieldPanel,
TabbedInterface, TabbedInterface,
) )
from wagtail.contrib.routable_page.models import RoutablePageMixin, route
from wagtail.core import blocks from wagtail.core import blocks
from wagtail.core.fields import RichTextField, StreamField from wagtail.core.fields import RichTextField, StreamField
from wagtail.core.models import Page from wagtail.core.models import Page
...@@ -34,9 +35,38 @@ from .constants import ( ...@@ -34,9 +35,38 @@ from .constants import (
BENEFITS_CHOICES, BENEFITS_CHOICES,
CANDIDATE_RICH_TEXT_FEATURES, CANDIDATE_RICH_TEXT_FEATURES,
EXTRA_FEATURES, EXTRA_FEATURES,
MINISTRY_AGRICULTURE,
MINISTRY_ARCHETYPES,
MINISTRY_BUSINESS,
MINISTRY_CHOICES,
MINISTRY_COUNTRYSIDE,
MINISTRY_CULTURE,
MINISTRY_DEFENSE,
MINISTRY_ENVIRONMENT,
MINISTRY_FINANCES,
MINISTRY_FOREIGN,
MINISTRY_HEALTH,
MINISTRY_INTERIOR,
MINISTRY_JUSTICE,
MINISTRY_OPTIONS,
MINISTRY_SCHOOLS,
MINISTRY_SOCIAL,
MINISTRY_TRANSPORT,
PARTY_CHOICES, PARTY_CHOICES,
PARTY_NAME, PARTY_NAME,
PIRATES, PIRATES,
PLAN_ARCHETYPES,
PLAN_CARE,
PLAN_CHOICES,
PLAN_CLIMATE,
PLAN_CORRUPTION,
PLAN_COUNTRYSIDE,
PLAN_DIGITAL,
PLAN_ECONOMICS,
PLAN_MANAGEMENT,
PLAN_OPTIONS,
PLAN_SAFE_COUNTRY,
PROGRAM_POINTS_PER_PAGE,
REGION_CHOICES, REGION_CHOICES,
REGION_NAME_VARIANT, REGION_NAME_VARIANT,
REGION_PHA, REGION_PHA,
...@@ -473,7 +503,9 @@ class Elections2021CandidatePage(SubpageMixin, MetadataPageMixin, Page): ...@@ -473,7 +503,9 @@ class Elections2021CandidatePage(SubpageMixin, MetadataPageMixin, Page):
return self.party == PIRATES return self.party == PIRATES
class Elections2021ProgramPage(SubpageMixin, MetadataPageMixin, Page): class Elections2021ProgramPage(
SubpageMixin, MetadataPageMixin, RoutablePageMixin, Page
):
### FIELDS ### FIELDS
photo = models.ForeignKey( photo = models.ForeignKey(
...@@ -483,6 +515,33 @@ class Elections2021ProgramPage(SubpageMixin, MetadataPageMixin, Page): ...@@ -483,6 +515,33 @@ class Elections2021ProgramPage(SubpageMixin, MetadataPageMixin, Page):
null=True, null=True,
verbose_name="hlavní fotka", verbose_name="hlavní fotka",
) )
plan_economics_text = RichTextField(
"Moderní ekonomika", blank=True, null=True, features=RESTRICTED_FEATURES
)
plan_digital_text = RichTextField(
"Digitální revoluce", blank=True, null=True, features=RESTRICTED_FEATURES
)
plan_corruption_text = RichTextField(
"Razantní boj s korupcí", blank=True, null=True, features=RESTRICTED_FEATURES
)
plan_climate_text = RichTextField(
"Důraz na klima", blank=True, null=True, features=RESTRICTED_FEATURES
)
plan_countryside_text = RichTextField(
"Rovnocenné regiony", blank=True, null=True, features=RESTRICTED_FEATURES
)
plan_management_text = RichTextField(
"Profesionální stát", blank=True, null=True, features=RESTRICTED_FEATURES
)
plan_safe_country_text = RichTextField(
"Sebevědomá a bezpečná země",
blank=True,
null=True,
features=RESTRICTED_FEATURES,
)
plan_care_text = RichTextField(
"Jistota péče a pomoci", blank=True, null=True, features=RESTRICTED_FEATURES
)
### PANELS ### PANELS
...@@ -499,9 +558,27 @@ class Elections2021ProgramPage(SubpageMixin, MetadataPageMixin, Page): ...@@ -499,9 +558,27 @@ class Elections2021ProgramPage(SubpageMixin, MetadataPageMixin, Page):
], ],
gettext_lazy("Common page configuration"), gettext_lazy("Common page configuration"),
), ),
CommentPanel(),
] ]
settings_panels = [CommentPanel()] plan_panels = [
FieldPanel("plan_economics_text"),
FieldPanel("plan_digital_text"),
FieldPanel("plan_corruption_text"),
FieldPanel("plan_climate_text"),
FieldPanel("plan_countryside_text"),
FieldPanel("plan_management_text"),
FieldPanel("plan_safe_country_text"),
FieldPanel("plan_care_text"),
]
edit_handler = TabbedInterface(
[
ObjectList(content_panels, heading=gettext_lazy("Content")),
ObjectList(promote_panels, heading=gettext_lazy("Promote")),
ObjectList(plan_panels, heading="plány"),
]
)
### RELATIONS ### RELATIONS
...@@ -516,6 +593,173 @@ class Elections2021ProgramPage(SubpageMixin, MetadataPageMixin, Page): ...@@ -516,6 +593,173 @@ class Elections2021ProgramPage(SubpageMixin, MetadataPageMixin, Page):
def get_meta_image(self): def get_meta_image(self):
return self.search_image or self.photo return self.search_image or self.photo
def get_context(self, request, parent_context=None):
context = super().get_context(request, parent_context=parent_context)
context["plan_choices"] = PLAN_CHOICES
context["ministry_choices"] = MINISTRY_CHOICES
context["show_archetype_icon"] = True
points = self.get_children().live().specific()
context["points"] = Paginator(points, PROGRAM_POINTS_PER_PAGE).get_page(
request.GET.get("page")
)
return context
@staticmethod
def get_archetype_image(archetype):
return f"elections2021/images/archetype/{archetype}.svg"
@route(r"^plan/([a-z-]+)/$")
def plan_detail(self, request, param=None):
plan = param if param in PLAN_OPTIONS else None
title = None
head_text = ""
head_image = ""
if plan:
title = next(title for key, title in PLAN_CHOICES if key == plan)
head_image = self.get_archetype_image(PLAN_ARCHETYPES[plan])
points = self.get_children().live().specific()
if plan == PLAN_ECONOMICS:
head_text = self.plan_economics_text
points = points.filter(
elections2021programpointpage__weight_plan_economics__gt=0
).order_by("-elections2021programpointpage__weight_plan_economics")
elif plan == PLAN_DIGITAL:
head_text = self.plan_digital_text
points = points.filter(
elections2021programpointpage__weight_plan_digital__gt=0
).order_by("-elections2021programpointpage__weight_plan_digital")
elif plan == PLAN_CORRUPTION:
head_text = self.plan_corruption_text
points = points.filter(
elections2021programpointpage__weight_plan_corruption__gt=0
).order_by("-elections2021programpointpage__weight_plan_corruption")
elif plan == PLAN_CLIMATE:
head_text = self.plan_climate_text
points = points.filter(
elections2021programpointpage__weight_plan_climate__gt=0
).order_by("-elections2021programpointpage__weight_plan_climate")
elif plan == PLAN_COUNTRYSIDE:
head_text = self.plan_countryside_text
points = points.filter(
elections2021programpointpage__weight_plan_countryside__gt=0
).order_by("-elections2021programpointpage__weight_plan_countryside")
elif plan == PLAN_MANAGEMENT:
head_text = self.plan_management_text
points = points.filter(
elections2021programpointpage__weight_plan_management__gt=0
).order_by("-elections2021programpointpage__weight_plan_management")
elif plan == PLAN_SAFE_COUNTRY:
head_text = self.plan_safe_country_text
points = points.filter(
elections2021programpointpage__weight_plan_safe_country__gt=0
).order_by("-elections2021programpointpage__weight_plan_safe_country")
elif plan == PLAN_CARE:
head_text = self.plan_care_text
points = points.filter(
elections2021programpointpage__weight_plan_care__gt=0
).order_by("-elections2021programpointpage__weight_plan_care")
points = Paginator(points, PROGRAM_POINTS_PER_PAGE).get_page(
request.GET.get("page")
)
context = {
"active_plan": plan,
"title": title,
"head_image": head_image,
"head_text": head_text,
"points": points,
}
return self.render(request, context_overrides=context)
@route(r"^resort/([a-z-]+)/$")
def ministry_detail(self, request, param=None):
ministry = param if param in MINISTRY_OPTIONS else None
title = None
head_text = ""
head_image = ""
if ministry:
title = next(title for key, title in MINISTRY_CHOICES if key == ministry)
head_image = self.get_archetype_image(MINISTRY_ARCHETYPES[ministry])
points = self.get_children().live().specific()
if ministry == MINISTRY_TRANSPORT:
points = points.filter(
elections2021programpointpage__weight_ministry_transport__gt=0
).order_by("-elections2021programpointpage__weight_ministry_transport")
elif ministry == MINISTRY_FINANCES:
points = points.filter(
elections2021programpointpage__weight_ministry_finances__gt=0
).order_by("-elections2021programpointpage__weight_ministry_finances")
elif ministry == MINISTRY_CULTURE:
points = points.filter(
elections2021programpointpage__weight_ministry_culture__gt=0
).order_by("-elections2021programpointpage__weight_ministry_culture")
elif ministry == MINISTRY_DEFENSE:
points = points.filter(
elections2021programpointpage__weight_ministry_defense__gt=0
).order_by("-elections2021programpointpage__weight_ministry_defense")
elif ministry == MINISTRY_SOCIAL:
points = points.filter(
elections2021programpointpage__weight_ministry_social__gt=0
).order_by("-elections2021programpointpage__weight_ministry_social")
elif ministry == MINISTRY_COUNTRYSIDE:
points = points.filter(
elections2021programpointpage__weight_ministry_countryside__gt=0
).order_by("-elections2021programpointpage__weight_ministry_countryside")
elif ministry == MINISTRY_BUSINESS:
points = points.filter(
elections2021programpointpage__weight_ministry_business__gt=0
).order_by("-elections2021programpointpage__weight_ministry_business")
elif ministry == MINISTRY_JUSTICE:
points = points.filter(
elections2021programpointpage__weight_ministry_justice__gt=0
).order_by("-elections2021programpointpage__weight_ministry_justice")
elif ministry == MINISTRY_SCHOOLS:
points = points.filter(
elections2021programpointpage__weight_ministry_schools__gt=0
).order_by("-elections2021programpointpage__weight_ministry_schools")
elif ministry == MINISTRY_INTERIOR:
points = points.filter(
elections2021programpointpage__weight_ministry_interior__gt=0
).order_by("-elections2021programpointpage__weight_ministry_interior")
elif ministry == MINISTRY_FOREIGN:
points = points.filter(
elections2021programpointpage__weight_ministry_foreign__gt=0
).order_by("-elections2021programpointpage__weight_ministry_foreign")
elif ministry == MINISTRY_HEALTH:
points = points.filter(
elections2021programpointpage__weight_ministry_health__gt=0
).order_by("-elections2021programpointpage__weight_ministry_health")
elif ministry == MINISTRY_AGRICULTURE:
points = points.filter(
elections2021programpointpage__weight_ministry_agriculture__gt=0
).order_by("-elections2021programpointpage__weight_ministry_agriculture")
elif ministry == MINISTRY_ENVIRONMENT:
points = points.filter(
elections2021programpointpage__weight_ministry_environment__gt=0
).order_by("-elections2021programpointpage__weight_ministry_environment")
points = Paginator(points, PROGRAM_POINTS_PER_PAGE).get_page(
request.GET.get("page")
)
context = {
"active_ministry": ministry,
"title": title,
"head_image": head_image,
"head_text": head_text,
"points": points,
"show_archetype_icon": False,
}
return self.render(request, context_overrides=context)
class QuestionBlock(blocks.StructBlock): class QuestionBlock(blocks.StructBlock):
question = blocks.CharBlock(label="otázka") question = blocks.CharBlock(label="otázka")
...@@ -641,6 +885,10 @@ class Elections2021ProgramPointPage(SubpageMixin, MetadataPageMixin, Page): ...@@ -641,6 +885,10 @@ class Elections2021ProgramPointPage(SubpageMixin, MetadataPageMixin, Page):
weight_plan_climate = models.IntegerField("váha plán klima", default=0) weight_plan_climate = models.IntegerField("váha plán klima", default=0)
weight_plan_countryside = models.IntegerField("váha plán rozvoj regionů", default=0) weight_plan_countryside = models.IntegerField("váha plán rozvoj regionů", default=0)
weight_plan_management = models.IntegerField("váha plán řízení státu", default=0) weight_plan_management = models.IntegerField("váha plán řízení státu", default=0)
weight_plan_safe_country = models.IntegerField(
"váha plán sebevědomá země", default=0
)
weight_plan_care = models.IntegerField("váha plán jistota péče", default=0)
weight_ministry_transport = models.IntegerField( weight_ministry_transport = models.IntegerField(
"váha ministerstvo dopravy", default=0 "váha ministerstvo dopravy", default=0
) )
...@@ -765,6 +1013,8 @@ class Elections2021ProgramPointPage(SubpageMixin, MetadataPageMixin, Page): ...@@ -765,6 +1013,8 @@ class Elections2021ProgramPointPage(SubpageMixin, MetadataPageMixin, Page):
FieldPanel("weight_plan_climate"), FieldPanel("weight_plan_climate"),
FieldPanel("weight_plan_countryside"), FieldPanel("weight_plan_countryside"),
FieldPanel("weight_plan_management"), FieldPanel("weight_plan_management"),
FieldPanel("weight_plan_safe_country"),
FieldPanel("weight_plan_care"),
], ],
"plány", "plány",
), ),
...@@ -826,6 +1076,38 @@ class Elections2021ProgramPointPage(SubpageMixin, MetadataPageMixin, Page): ...@@ -826,6 +1076,38 @@ class Elections2021ProgramPointPage(SubpageMixin, MetadataPageMixin, Page):
class Meta: class Meta:
verbose_name = "Programový bod" verbose_name = "Programový bod"
@property
def archetype(self):
if self.weight_ministry_transport:
return MINISTRY_ARCHETYPES[MINISTRY_TRANSPORT]
if self.weight_ministry_finances:
return MINISTRY_ARCHETYPES[MINISTRY_FINANCES]
if self.weight_ministry_culture:
return MINISTRY_ARCHETYPES[MINISTRY_CULTURE]
if self.weight_ministry_defense:
return MINISTRY_ARCHETYPES[MINISTRY_DEFENSE]
if self.weight_ministry_social:
return MINISTRY_ARCHETYPES[MINISTRY_SOCIAL]
if self.weight_ministry_countryside:
return MINISTRY_ARCHETYPES[MINISTRY_COUNTRYSIDE]
if self.weight_ministry_business:
return MINISTRY_ARCHETYPES[MINISTRY_BUSINESS]
if self.weight_ministry_justice:
return MINISTRY_ARCHETYPES[MINISTRY_JUSTICE]
if self.weight_ministry_schools:
return MINISTRY_ARCHETYPES[MINISTRY_SCHOOLS]
if self.weight_ministry_interior:
return MINISTRY_ARCHETYPES[MINISTRY_INTERIOR]
if self.weight_ministry_foreign:
return MINISTRY_ARCHETYPES[MINISTRY_FOREIGN]
if self.weight_ministry_health:
return MINISTRY_ARCHETYPES[MINISTRY_HEALTH]
if self.weight_ministry_agriculture:
return MINISTRY_ARCHETYPES[MINISTRY_AGRICULTURE]
if self.weight_ministry_environment:
return MINISTRY_ARCHETYPES[MINISTRY_ENVIRONMENT]
return ""
class RichQuestionBlock(blocks.StructBlock): class RichQuestionBlock(blocks.StructBlock):
question = blocks.CharBlock(label="otázka") question = blocks.CharBlock(label="otázka")
......
This diff is collapsed.
...@@ -5,8 +5,10 @@ ...@@ -5,8 +5,10 @@
<h1 class="head-alt-md sm:head-alt-lg pt-1 max-w-sm">{{ page.title }}</h1> <h1 class="head-alt-md sm:head-alt-lg pt-1 max-w-sm">{{ page.title }}</h1>
</div> </div>
<div class="hidden lg:block lg:row-span-2 lg:col-span-3 order-2 h-full 2xl:absolute 2xl:right-0 2xl:w-1/3"> <div class="hidden lg:block lg:row-span-2 lg:col-span-3 order-2 h-full 2xl:absolute 2xl:right-0 2xl:w-1/3">
{% if page.photo %}
{% image page.photo fill-618x256 as img %} {% image page.photo fill-618x256 as img %}
<img class="object-cover w-full h-full" src="{{ img.url }}"> <img class="object-cover w-full h-full" src="{{ img.url }}">
{% endif %}
</div> </div>
</div> </div>
</article> </article>
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<nav class="pagination space-x-1"> <nav class="pagination space-x-1">
{% if paginator.has_previous %} {% if paginator.has_previous %}
<a href="{% pageurl page %}?page={{ paginator.previous_page_number }}" class="btn btn--icon btn--grey-125 btn--hoveractive btn--to-black btn--condensed btn--inverted-icon"> <a href="?page={{ paginator.previous_page_number }}" class="btn btn--icon btn--grey-125 btn--hoveractive btn--to-black btn--condensed btn--inverted-icon">
<div class="btn__body-wrap"> <div class="btn__body-wrap">
<div class="btn__body ">předchozí</div> <div class="btn__body ">předchozí</div>
<div class="btn__icon "> <div class="btn__icon ">
...@@ -14,18 +14,20 @@ ...@@ -14,18 +14,20 @@
</a> </a>
{% endif %} {% endif %}
{% if paginator.paginator.num_pages > 1 %}
{% for i in paginator.paginator.page_range %} {% for i in paginator.paginator.page_range %}
{% if i == paginator.number %} {% if i == paginator.number %}
<a href="{% pageurl page %}?page={{ i }}" class="btn btn--grey-500 btn--condensed hidden md:inline-block"> <a href="?page={{ i }}" class="btn btn--grey-500 btn--condensed hidden md:inline-block">
{% else %} {% else %}
<a href="{% pageurl page %}?page={{ i }}" class="btn btn--grey-125 btn--hoveractive btn--to-black btn--condensed hidden md:inline-block"> <a href="?page={{ i }}" class="btn btn--grey-125 btn--hoveractive btn--to-black btn--condensed hidden md:inline-block">
{% endif %} {% endif %}
<div class="btn__body ">{{ i }}</div> <div class="btn__body ">{{ i }}</div>
</a> </a>
{% endfor %} {% endfor %}
{% endif %}
{% if paginator.has_next %} {% if paginator.has_next %}
<a href="{% pageurl page %}?page={{ paginator.next_page_number }}" class="btn btn--icon btn--grey-125 btn--hoveractive btn--to-black btn--condensed"> <a href="?page={{ paginator.next_page_number }}" class="btn btn--icon btn--grey-125 btn--hoveractive btn--to-black btn--condensed">
<div class="btn__body-wrap"> <div class="btn__body-wrap">
<div class="btn__body ">další</div> <div class="btn__body ">další</div>
<div class="btn__icon "> <div class="btn__icon ">
......
<div class="lead-collector inline-flex col-span-1 md:col-span-2 lg:col-span-3 mx-auto">
<div class="lead-collector-icon bg-acidgreen max-w-max p-10 hidden md:flex" style="height: max-content">
<i class="ico--app text-black" style="font-size: 51px"></i>
</div>
<div class="lead-collector-body bg-lemon py-10 px-8 w-full">
<p class="head-alt-lg text-black mb-4">Vyselektujte si programové body díky naší programové aplikaci</p>
<button class="btn btn--icon ">
<div class="btn__body-wrap">
<div class="btn__body bg-acidgreen text-black py-4">Programová aplikace</div>
<div class="btn__icon ">
<i class="ico--chevron-right"></i>
</div>
</div>
</button>
</div>
</div>
{% extends "elections2021/base.html" %} {% extends "elections2021/base.html" %}
{% load wagtailcore_tags wagtailimages_tags %} {% load static wagtailcore_tags wagtailimages_tags %}
{% block content %} {% block content %}
<div class="py-16">
{% if active_ministry or active_plan %}
<article class="relative w-full ">
<div class="grid grid-cols-12">
<div class="col-span-12 lg:col-span-5 grid grid-cols-12">
<div class="col-span-8 lg:col-span-12 bg-acidgreen pl-16 md:pl-24 lg:pl-32 pr-16 py-4 md:py-12">
<h1 class="head-alt-md sm:head-alt-lg max-w-xs">{{ title }}</h1>
</div>
<div class="col-span-4 lg:col-span-12 bg-black text-white pl-8 md:pl-24 lg:pl-32 pr-4 md:pr-16 py-4 md:py-12">
<img src="{% static head_image %}" height="128" style="filter:invert(1)" width="128">
</div>
</div>
<div class="content-block col-span-12 lg:col-span-7 bg-lemon pl-16 pr-16 lg:pr-32 py-12">
{{ head_text|richtext }}
</div>
</div>
</article>
{% else %}
{% include "elections2021/_page_header.html" %}
{% endif %}
<div class="relative">
<main>
<div class="container container--default pt-8 pb-16 lg:py-24">
<div class="text-center">
{% comment %}
<!-- set data-chosen of #progamswitch container by serverside script based on current url-->
<div id="progamswitch" class="switch mb-4" data-chosen="mujprogram">
<a class="switch__item switch__item--active" data-chosen="mujprogram">Můj program</a>
<a class="switch__item" data-chosen="celyprogram">Celý program</a>
</div> </div>
{% endcomment %}
<div class="filters">
<div class="select inline-flex w-auto {% if active_ministry %}text-black{% else %}text-white{% endif %}">
<select id="select_ministry" class="select__control form-field__control bg-black block filter-pirati-stan" data-chosen="{{ active_ministry }}">
<option value="x" {% if not active_ministry %}selected="selected"{% endif %}>Podle resortu</option>
{% for val, name in ministry_choices %}
<option value="{{ val }}" {% if active_ministry == val %}selected="selected"{% endif %}>{{ name }}</option>
{% endfor %}
</select>
</div>
<div class="select inline-flex w-auto {% if active_plan %}text-black{% else %}text-white{% endif %}">
<select id="select_plan" class="select__control form-field__control bg-black block filter-pirati-stan" data-chosen="{{ active_plan }}">
<option value="x">Podle plánu</option>
{% for val, name in plan_choices %}
<option value="{{ val }}" {% if active_plan == val %}selected=""{% endif %}>{{ name }}</option>
{% endfor %}
</select>
</div>
</div>
</div>
<script>
var baseUrl = "{% pageurl page %}";
var selectMinistry = document.getElementById("select_ministry");
var selectPlan = document.getElementById("select_plan");
selectMinistry.addEventListener("change", function(e) {
if (this.value == "x") {
location.href = baseUrl;
}
else {
location.href = baseUrl + "resort/" + this.value + "/";
}
});
selectPlan.addEventListener("change", function(e) {
if (this.value == "x") {
location.href = baseUrl;
}
else {
location.href = baseUrl + "plan/" + this.value + "/";
}
});
</script>
<h1 class="head-alt-md text-center py-8 lg:pt-24 lg:pb-8">Volební program</h1>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
{% for point in points %}
<div class="card icon-card shadow-none bg-grey-125 card--hoveractive" data-archetype="{% if show_archetype_icon %}{{ point.archetype }}{% endif %}">
<div class="card__body">
<h1 class="card-headline mb-8 pr-12"><a href="{% pageurl point %}">{{ point.title }}</a></h1>
<p class="card-body-text content-block">{{ point.annotation|richtext }}</p>
</div>
</div>
{% if forloop.counter == 3 or forloop.counter < 3 and forloop.last %}
{% include "elections2021/_program_app_banner.html" %}
{% endif %}
{% endfor %}
</div>
<div class="text-center mt-16">
{% include "elections2021/_pagination.html" with paginator=points %}
</div>
</div>
</main>
</div>
{% endblock %} {% endblock %}
...@@ -58,6 +58,7 @@ INSTALLED_APPS = [ ...@@ -58,6 +58,7 @@ INSTALLED_APPS = [
"wagtail.contrib.redirects", "wagtail.contrib.redirects",
"wagtail.contrib.modeladmin", "wagtail.contrib.modeladmin",
"wagtail.contrib.table_block", "wagtail.contrib.table_block",
"wagtail.contrib.routable_page",
"wagtail.embeds", "wagtail.embeds",
"wagtail.sites", "wagtail.sites",
"wagtail.users", "wagtail.users",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment