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

elections2021: Program page archetypes

parent 8e305850
No related branches found
No related tags found
2 merge requests!242elections2021: Program page archetypes,!241elections2021: Program page archetypes
Pipeline #3641 passed
# Generated by Django 3.2.2 on 2021-05-15 22:59
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("wagtailimages", "0023_add_choose_permissions"),
("elections2021", "0013_elections2021programpointpage_weight_technology"),
]
operations = [
migrations.AddField(
model_name="elections2021programpage",
name="archetype_childless_photo",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="+",
to="wagtailimages.image",
verbose_name="bezdětní foto",
),
),
migrations.AddField(
model_name="elections2021programpage",
name="archetype_childless_title",
field=models.CharField(
blank=True, max_length=50, null=True, verbose_name="bezdětní titulek"
),
),
migrations.AddField(
model_name="elections2021programpage",
name="archetype_mature_photo",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="+",
to="wagtailimages.image",
verbose_name="zralí foto",
),
),
migrations.AddField(
model_name="elections2021programpage",
name="archetype_mature_title",
field=models.CharField(
blank=True, max_length=50, null=True, verbose_name="zralí titulek"
),
),
migrations.AddField(
model_name="elections2021programpage",
name="archetype_parents_photo",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="+",
to="wagtailimages.image",
verbose_name="rodiče foto",
),
),
migrations.AddField(
model_name="elections2021programpage",
name="archetype_parents_title",
field=models.CharField(
blank=True, max_length=50, null=True, verbose_name="rodiče titulek"
),
),
migrations.AddField(
model_name="elections2021programpage",
name="archetype_seniors_photo",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="+",
to="wagtailimages.image",
verbose_name="senioři foto",
),
),
migrations.AddField(
model_name="elections2021programpage",
name="archetype_seniors_title",
field=models.CharField(
blank=True, max_length=50, null=True, verbose_name="senioři titulek"
),
),
migrations.AddField(
model_name="elections2021programpage",
name="archetype_students_photo",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="+",
to="wagtailimages.image",
verbose_name="studenti foto",
),
),
migrations.AddField(
model_name="elections2021programpage",
name="archetype_students_title",
field=models.CharField(
blank=True, max_length=50, null=True, verbose_name="studenti titulek"
),
),
migrations.AddField(
model_name="elections2021programpage",
name="archetype_working_seniors_photo",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="+",
to="wagtailimages.image",
verbose_name="pracující senioři foto",
),
),
migrations.AddField(
model_name="elections2021programpage",
name="archetype_working_seniors_title",
field=models.CharField(
blank=True,
max_length=50,
null=True,
verbose_name="pracující senioři titulek",
),
),
]
...@@ -594,6 +594,73 @@ class Elections2021ProgramPage( ...@@ -594,6 +594,73 @@ class Elections2021ProgramPage(
"Jistota péče a pomoci", blank=True, null=True, features=RESTRICTED_FEATURES "Jistota péče a pomoci", blank=True, null=True, features=RESTRICTED_FEATURES
) )
archetype_childless_title = models.CharField(
"bezdětní titulek", null=True, blank=True, max_length=50
)
archetype_childless_photo = models.ForeignKey(
"wagtailimages.Image",
on_delete=models.PROTECT,
blank=True,
null=True,
verbose_name="bezdětní foto",
related_name="+",
)
archetype_parents_title = models.CharField(
"rodiče titulek", null=True, blank=True, max_length=50
)
archetype_parents_photo = models.ForeignKey(
"wagtailimages.Image",
on_delete=models.PROTECT,
blank=True,
null=True,
verbose_name="rodiče foto",
related_name="+",
)
archetype_mature_title = models.CharField(
"zralí titulek", null=True, blank=True, max_length=50
)
archetype_mature_photo = models.ForeignKey(
"wagtailimages.Image",
on_delete=models.PROTECT,
blank=True,
null=True,
verbose_name="zralí foto",
related_name="+",
)
archetype_seniors_title = models.CharField(
"senioři titulek", null=True, blank=True, max_length=50
)
archetype_seniors_photo = models.ForeignKey(
"wagtailimages.Image",
on_delete=models.PROTECT,
blank=True,
null=True,
verbose_name="senioři foto",
related_name="+",
)
archetype_working_seniors_title = models.CharField(
"pracující senioři titulek", null=True, blank=True, max_length=50
)
archetype_working_seniors_photo = models.ForeignKey(
"wagtailimages.Image",
on_delete=models.PROTECT,
blank=True,
null=True,
verbose_name="pracující senioři foto",
related_name="+",
)
archetype_students_title = models.CharField(
"studenti titulek", null=True, blank=True, max_length=50
)
archetype_students_photo = models.ForeignKey(
"wagtailimages.Image",
on_delete=models.PROTECT,
blank=True,
null=True,
verbose_name="studenti foto",
related_name="+",
)
### PANELS ### PANELS
content_panels = Page.content_panels + [ImageChooserPanel("photo")] content_panels = Page.content_panels + [ImageChooserPanel("photo")]
...@@ -623,11 +690,57 @@ class Elections2021ProgramPage( ...@@ -623,11 +690,57 @@ class Elections2021ProgramPage(
FieldPanel("plan_care_text"), FieldPanel("plan_care_text"),
] ]
archetype_panels = [
MultiFieldPanel(
[
FieldPanel("archetype_childless_title"),
ImageChooserPanel("archetype_childless_photo"),
],
"archetyp bezdětní",
),
MultiFieldPanel(
[
FieldPanel("archetype_parents_title"),
ImageChooserPanel("archetype_parents_photo"),
],
"archetyp rodiče",
),
MultiFieldPanel(
[
FieldPanel("archetype_mature_title"),
ImageChooserPanel("archetype_mature_photo"),
],
"archetyp zralí",
),
MultiFieldPanel(
[
FieldPanel("archetype_seniors_title"),
ImageChooserPanel("archetype_seniors_photo"),
],
"archetyp senioři",
),
MultiFieldPanel(
[
FieldPanel("archetype_working_seniors_title"),
ImageChooserPanel("archetype_working_seniors_photo"),
],
"archetyp pracující senioři",
),
MultiFieldPanel(
[
FieldPanel("archetype_students_title"),
ImageChooserPanel("archetype_students_photo"),
],
"archetyp studenti",
),
]
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"),
] ]
) )
...@@ -794,16 +907,28 @@ class Elections2021ProgramPage( ...@@ -794,16 +907,28 @@ class Elections2021ProgramPage(
archetype = get_archetype(selection) archetype = get_archetype(selection)
if archetype == CHILDLESS: if archetype == CHILDLESS:
weights.append("weight_childless") weights.append("weight_childless")
archetype_title = self.archetype_childless_title
archetype_photo = self.archetype_childless_photo
elif archetype == PARENTS: elif archetype == PARENTS:
weights.append("weight_parents") weights.append("weight_parents")
archetype_title = self.archetype_parents_title
archetype_photo = self.archetype_parents_photo
elif archetype == MATURE: elif archetype == MATURE:
weights.append("weight_mature") weights.append("weight_mature")
archetype_title = self.archetype_mature_title
archetype_photo = self.archetype_mature_photo
elif archetype == STUDENTS: elif archetype == STUDENTS:
weights.append("weight_students") weights.append("weight_students")
archetype_title = self.archetype_students_title
archetype_photo = self.archetype_students_photo
elif archetype == SENIORS: elif archetype == SENIORS:
weights.append("weight_seniors") weights.append("weight_seniors")
archetype_title = self.archetype_seniors_title
archetype_photo = self.archetype_seniors_photo
elif archetype == WORKING_SENIORS: elif archetype == WORKING_SENIORS:
weights.append("weight_working_seniors") weights.append("weight_working_seniors")
archetype_title = self.archetype_working_seniors_title
archetype_photo = self.archetype_working_seniors_photo
if selection["occupation"] == OCCUPATION_BUSINESS: if selection["occupation"] == OCCUPATION_BUSINESS:
weights.append("weight_self_employed") weights.append("weight_self_employed")
...@@ -837,6 +962,8 @@ class Elections2021ProgramPage( ...@@ -837,6 +962,8 @@ class Elections2021ProgramPage(
"points": points, "points": points,
"show_app_banner": False, "show_app_banner": False,
"active_my_program": True, "active_my_program": True,
"archetype_title": archetype_title,
"archetype_photo": archetype_photo,
} }
return self.render(request, context_overrides=context) return self.render(request, context_overrides=context)
......
...@@ -22,7 +22,26 @@ ...@@ -22,7 +22,26 @@
{% elif active_ministry %} {% elif active_ministry %}
{% include "elections2021/_page_header.html" with title=title %} {% include "elections2021/_page_header.html" with title=title %}
{% elif active_my_program %} {% elif active_my_program %}
{% include "elections2021/_page_header.html" with title=title %} <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="lg:row-span-1 lg:col-span-4 order-1 pt-14 md:pr-20">
<h1 class="head-alt-md sm:head-alt-lg max-w-sm">{{ title }}</h1>
</div>
<div class="lg:row-span-1 lg:col-span-4 order-3 pb-14 md:pr-20">
<p class="head-alt-2xs max-w-xs mt-8">
Vybrané programové body pro:
</p>
<h2 class="head-alt-md pt-2">
{{ archetype_title }}
</h2>
</div>
{% if archetype_photo %}
<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">
{% image archetype_photo fill-618x256 class="object-cover w-full h-full" %}
</div>
{% endif %}
</div>
</article>
{% else %} {% else %}
{% include "elections2021/_page_header.html" with title=page.title photo=page.photo %} {% include "elections2021/_page_header.html" with title=page.title photo=page.photo %}
{% endif %} {% endif %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment