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

elections2021: Resort photos

parent 37ddd17a
Branches
No related tags found
2 merge requests!244elections2021: Resort photos,!243elections2021: Resort photos
Pipeline #3644 passed
# Generated by Django 3.2.2 on 2021-05-15 23:27
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("wagtailimages", "0023_add_choose_permissions"),
("elections2021", "0014_auto_20210516_0059"),
]
operations = [
migrations.AddField(
model_name="elections2021programpage",
name="ministry_agriculture_photo",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="+",
to="wagtailimages.image",
verbose_name="zemědělství foto",
),
),
migrations.AddField(
model_name="elections2021programpage",
name="ministry_business_photo",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="+",
to="wagtailimages.image",
verbose_name="průmysl a obchod foto",
),
),
migrations.AddField(
model_name="elections2021programpage",
name="ministry_countryside_photo",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="+",
to="wagtailimages.image",
verbose_name="místní rozvoj foto",
),
),
migrations.AddField(
model_name="elections2021programpage",
name="ministry_culture_photo",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="+",
to="wagtailimages.image",
verbose_name="kultura foto",
),
),
migrations.AddField(
model_name="elections2021programpage",
name="ministry_defense_photo",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="+",
to="wagtailimages.image",
verbose_name="obrana foto",
),
),
migrations.AddField(
model_name="elections2021programpage",
name="ministry_environment_photo",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="+",
to="wagtailimages.image",
verbose_name="životní prostředí foto",
),
),
migrations.AddField(
model_name="elections2021programpage",
name="ministry_finances_photo",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="+",
to="wagtailimages.image",
verbose_name="finance foto",
),
),
migrations.AddField(
model_name="elections2021programpage",
name="ministry_foreign_photo",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="+",
to="wagtailimages.image",
verbose_name="zahraniční věci foto",
),
),
migrations.AddField(
model_name="elections2021programpage",
name="ministry_health_photo",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="+",
to="wagtailimages.image",
verbose_name="zdravotnictví foto",
),
),
migrations.AddField(
model_name="elections2021programpage",
name="ministry_interior_photo",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="+",
to="wagtailimages.image",
verbose_name="vnitro foto",
),
),
migrations.AddField(
model_name="elections2021programpage",
name="ministry_justice_photo",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="+",
to="wagtailimages.image",
verbose_name="spravedlnost foto",
),
),
migrations.AddField(
model_name="elections2021programpage",
name="ministry_schools_photo",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="+",
to="wagtailimages.image",
verbose_name="školství, mládež a tělovýchova foto",
),
),
migrations.AddField(
model_name="elections2021programpage",
name="ministry_social_photo",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="+",
to="wagtailimages.image",
verbose_name="práce a sociální věci foto",
),
),
migrations.AddField(
model_name="elections2021programpage",
name="ministry_transport_photo",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="+",
to="wagtailimages.image",
verbose_name="doprava foto",
),
),
]
...@@ -661,6 +661,119 @@ class Elections2021ProgramPage( ...@@ -661,6 +661,119 @@ class Elections2021ProgramPage(
related_name="+", related_name="+",
) )
ministry_transport_photo = models.ForeignKey(
"wagtailimages.Image",
on_delete=models.PROTECT,
blank=True,
null=True,
verbose_name="doprava foto",
related_name="+",
)
ministry_finances_photo = models.ForeignKey(
"wagtailimages.Image",
on_delete=models.PROTECT,
blank=True,
null=True,
verbose_name="finance foto",
related_name="+",
)
ministry_culture_photo = models.ForeignKey(
"wagtailimages.Image",
on_delete=models.PROTECT,
blank=True,
null=True,
verbose_name="kultura foto",
related_name="+",
)
ministry_defense_photo = models.ForeignKey(
"wagtailimages.Image",
on_delete=models.PROTECT,
blank=True,
null=True,
verbose_name="obrana foto",
related_name="+",
)
ministry_social_photo = models.ForeignKey(
"wagtailimages.Image",
on_delete=models.PROTECT,
blank=True,
null=True,
verbose_name="práce a sociální věci foto",
related_name="+",
)
ministry_countryside_photo = models.ForeignKey(
"wagtailimages.Image",
on_delete=models.PROTECT,
blank=True,
null=True,
verbose_name="místní rozvoj foto",
related_name="+",
)
ministry_business_photo = models.ForeignKey(
"wagtailimages.Image",
on_delete=models.PROTECT,
blank=True,
null=True,
verbose_name="průmysl a obchod foto",
related_name="+",
)
ministry_justice_photo = models.ForeignKey(
"wagtailimages.Image",
on_delete=models.PROTECT,
blank=True,
null=True,
verbose_name="spravedlnost foto",
related_name="+",
)
ministry_schools_photo = models.ForeignKey(
"wagtailimages.Image",
on_delete=models.PROTECT,
blank=True,
null=True,
verbose_name="školství, mládež a tělovýchova foto",
related_name="+",
)
ministry_interior_photo = models.ForeignKey(
"wagtailimages.Image",
on_delete=models.PROTECT,
blank=True,
null=True,
verbose_name="vnitro foto",
related_name="+",
)
ministry_foreign_photo = models.ForeignKey(
"wagtailimages.Image",
on_delete=models.PROTECT,
blank=True,
null=True,
verbose_name="zahraniční věci foto",
related_name="+",
)
ministry_health_photo = models.ForeignKey(
"wagtailimages.Image",
on_delete=models.PROTECT,
blank=True,
null=True,
verbose_name="zdravotnictví foto",
related_name="+",
)
ministry_agriculture_photo = models.ForeignKey(
"wagtailimages.Image",
on_delete=models.PROTECT,
blank=True,
null=True,
verbose_name="zemědělství foto",
related_name="+",
)
ministry_environment_photo = models.ForeignKey(
"wagtailimages.Image",
on_delete=models.PROTECT,
blank=True,
null=True,
verbose_name="životní prostředí foto",
related_name="+",
)
### PANELS ### PANELS
content_panels = Page.content_panels + [ImageChooserPanel("photo")] content_panels = Page.content_panels + [ImageChooserPanel("photo")]
...@@ -735,12 +848,30 @@ class Elections2021ProgramPage( ...@@ -735,12 +848,30 @@ class Elections2021ProgramPage(
), ),
] ]
ministry_panels = [
ImageChooserPanel("ministry_transport_photo"),
ImageChooserPanel("ministry_finances_photo"),
ImageChooserPanel("ministry_culture_photo"),
ImageChooserPanel("ministry_defense_photo"),
ImageChooserPanel("ministry_social_photo"),
ImageChooserPanel("ministry_countryside_photo"),
ImageChooserPanel("ministry_business_photo"),
ImageChooserPanel("ministry_justice_photo"),
ImageChooserPanel("ministry_schools_photo"),
ImageChooserPanel("ministry_interior_photo"),
ImageChooserPanel("ministry_foreign_photo"),
ImageChooserPanel("ministry_health_photo"),
ImageChooserPanel("ministry_agriculture_photo"),
ImageChooserPanel("ministry_environment_photo"),
]
edit_handler = TabbedInterface( edit_handler = TabbedInterface(
[ [
ObjectList(content_panels, heading=gettext_lazy("Content")), ObjectList(content_panels, heading=gettext_lazy("Content")),
ObjectList(promote_panels, heading=gettext_lazy("Promote")), ObjectList(promote_panels, heading=gettext_lazy("Promote")),
ObjectList(plan_panels, heading="plány"), ObjectList(plan_panels, heading="plány"),
ObjectList(archetype_panels, heading="archetypy"), ObjectList(archetype_panels, heading="archetypy"),
ObjectList(ministry_panels, heading="rezorty"),
] ]
) )
...@@ -844,8 +975,7 @@ class Elections2021ProgramPage( ...@@ -844,8 +975,7 @@ class Elections2021ProgramPage(
def ministry_detail(self, request, param=None): def ministry_detail(self, request, param=None):
ministry = param if param in MINISTRY_OPTIONS else None ministry = param if param in MINISTRY_OPTIONS else None
title = None title = None
head_text = "" head_photo = None
head_image = ""
if ministry: if ministry:
title = next(title for key, title in MINISTRY_CHOICES if key == ministry) title = next(title for key, title in MINISTRY_CHOICES if key == ministry)
...@@ -853,38 +983,51 @@ class Elections2021ProgramPage( ...@@ -853,38 +983,51 @@ class Elections2021ProgramPage(
if ministry == MINISTRY_TRANSPORT: if ministry == MINISTRY_TRANSPORT:
weights = ["weight_ministry_transport"] weights = ["weight_ministry_transport"]
head_photo = self.ministry_transport_photo
elif ministry == MINISTRY_FINANCES: elif ministry == MINISTRY_FINANCES:
weights = ["weight_ministry_finances"] weights = ["weight_ministry_finances"]
head_photo = self.ministry_finances_photo
elif ministry == MINISTRY_CULTURE: elif ministry == MINISTRY_CULTURE:
weights = ["weight_ministry_culture"] weights = ["weight_ministry_culture"]
head_photo = self.ministry_culture_photo
elif ministry == MINISTRY_DEFENSE: elif ministry == MINISTRY_DEFENSE:
weights = ["weight_ministry_defense"] weights = ["weight_ministry_defense"]
head_photo = self.ministry_defense_photo
elif ministry == MINISTRY_SOCIAL: elif ministry == MINISTRY_SOCIAL:
weights = ["weight_ministry_social"] weights = ["weight_ministry_social"]
head_photo = self.ministry_social_photo
elif ministry == MINISTRY_COUNTRYSIDE: elif ministry == MINISTRY_COUNTRYSIDE:
weights = ["weight_ministry_countryside"] weights = ["weight_ministry_countryside"]
head_photo = self.ministry_countryside_photo
elif ministry == MINISTRY_BUSINESS: elif ministry == MINISTRY_BUSINESS:
weights = ["weight_ministry_business"] weights = ["weight_ministry_business"]
head_photo = self.ministry_business_photo
elif ministry == MINISTRY_JUSTICE: elif ministry == MINISTRY_JUSTICE:
weights = ["weight_ministry_justice"] weights = ["weight_ministry_justice"]
head_photo = self.ministry_justice_photo
elif ministry == MINISTRY_SCHOOLS: elif ministry == MINISTRY_SCHOOLS:
weights = ["weight_ministry_schools"] weights = ["weight_ministry_schools"]
head_photo = self.ministry_schools_photo
elif ministry == MINISTRY_INTERIOR: elif ministry == MINISTRY_INTERIOR:
weights = ["weight_ministry_interior"] weights = ["weight_ministry_interior"]
head_photo = self.ministry_interior_photo
elif ministry == MINISTRY_FOREIGN: elif ministry == MINISTRY_FOREIGN:
weights = ["weight_ministry_foreign"] weights = ["weight_ministry_foreign"]
head_photo = self.ministry_foreign_photo
elif ministry == MINISTRY_HEALTH: elif ministry == MINISTRY_HEALTH:
weights = ["weight_ministry_health"] weights = ["weight_ministry_health"]
head_photo = self.ministry_health_photo
elif ministry == MINISTRY_AGRICULTURE: elif ministry == MINISTRY_AGRICULTURE:
weights = ["weight_ministry_agriculture"] weights = ["weight_ministry_agriculture"]
head_photo = self.ministry_agriculture_photo
elif ministry == MINISTRY_ENVIRONMENT: elif ministry == MINISTRY_ENVIRONMENT:
weights = ["weight_ministry_environment"] weights = ["weight_ministry_environment"]
head_photo = self.ministry_environment_photo
context = { context = {
"active_ministry": ministry, "active_ministry": ministry,
"title": title, "title": title,
"head_image": head_image, "head_photo": head_photo,
"head_text": head_text,
"points": Elections2021ProgramPointPage.filter_by_weights(weights), "points": Elections2021ProgramPointPage.filter_by_weights(weights),
"show_archetype_icon": False, "show_archetype_icon": False,
"show_app_banner": False, "show_app_banner": False,
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
</div> </div>
</article> </article>
{% elif active_ministry %} {% elif active_ministry %}
{% include "elections2021/_page_header.html" with title=title %} {% include "elections2021/_page_header.html" with title=title photo=head_photo %}
{% elif active_my_program %} {% elif active_my_program %}
<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 "> <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-2 lg:grid-cols-7 items-center 2xl:mx-auto"> <div class="2xl:container w-auto bg-lemon md:pl-20 pr-0 grid lg:grid-rows-2 lg:grid-cols-7 items-center 2xl:mx-auto">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment