Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • to/majak
  • b1242/majak
2 results
Select Git revision
Show changes
Showing
with 1355 additions and 0 deletions
# Generated by Django 5.0.4 on 2024-05-13 16:52
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("district", "0159_rename_main_image_districtpersonpage_profile_image"),
]
operations = [
migrations.RenameField(
model_name="districtpersonpage",
old_name="background_photo",
new_name="main_image",
),
]
# Generated by Django 5.0.4 on 2024-05-13 15:33
import wagtail
from django.db import migrations, models
from wagtail.blocks import CharBlock, ListBlock, PageChooserBlock, StructBlock
def migrate_people_blocks(apps, schema_editor):
# Recreate here because this block has been changed in the future
class PeopleGroupBlock(StructBlock):
title = CharBlock(label="Titulek")
slug = CharBlock(
label="Slug skupiny",
required=False,
help_text="Není třeba vyplňovat, bude automaticky vyplněno",
)
person_list = ListBlock(
PageChooserBlock(
page_type="district.DistrictPersonPage", label="Detail osoby"
),
label="Skupina osob",
)
# Get the page model
DistrictPeoplePage = apps.get_model("district", "DistrictPeoplePage")
DistrictPersonPage = apps.get_model("district", "DistrictPersonPage")
# Iterate over all pages that have the StreamField you want to update
for number, people_page in enumerate(DistrictPeoplePage.objects.all()):
# Get the old content
old_content = people_page.content.get_prep_value()
# Create a new list to store the merged blocks
merged_blocks = []
# Iterate over the old blocks and extract common fields
for old_block in old_content:
if old_block["type"] != "people_group":
continue
title = old_block["value"]["group_title"]
people = []
for person in old_block["value"]["person_list"]:
person_id = (
DistrictPersonPage.objects.filter(id=person["value"]["person"])
.values_list("id", flat=True)
.first()
)
if person_id is None:
continue
people.append(person_id)
person_block_list = []
for person_id in people:
person_block_list.append(person_id)
merged_blocks.append(
PeopleGroupBlock().to_python(
{
"title": title,
"slug": str(number),
"person_list": person_block_list,
}
)
)
for block in merged_blocks:
people_page.people.append(("people_group", block))
people_page.save()
class Migration(migrations.Migration):
dependencies = [
("district", "0160_rename_background_photo_districtpersonpage_main_image"),
]
operations = [
migrations.AlterField(
model_name="districtpeoplepage",
name="people",
field=wagtail.fields.StreamField(
[
(
"people_group",
wagtail.blocks.StructBlock(
[
("title", wagtail.blocks.CharBlock(label="Titulek")),
(
"slug",
wagtail.blocks.CharBlock(
help_text="Není třeba vyplňovat, bude automaticky vyplněno",
label="Slug skupiny",
required=False,
),
),
(
"person_list",
wagtail.blocks.ListBlock(
wagtail.blocks.PageChooserBlock(
label="Detail osoby",
page_type=["district.DistrictPersonPage"],
),
label="Skupina osob",
),
),
],
label="Seznam osob",
),
),
(
"team_group",
wagtail.blocks.StructBlock(
[
(
"title",
wagtail.blocks.CharBlock(label="Název sekce týmů"),
),
(
"slug",
wagtail.blocks.CharBlock(
help_text="Není třeba vyplňovat, bude automaticky vyplněno",
label="Slug sekce",
required=False,
),
),
(
"team_list",
wagtail.blocks.ListBlock(
wagtail.blocks.StructBlock(
[
(
"headline",
wagtail.blocks.CharBlock(
label="Titulek bloku",
required=False,
),
),
(
"card_items",
wagtail.blocks.ListBlock(
wagtail.blocks.StructBlock(
[
(
"image",
wagtail.images.blocks.ImageChooserBlock(
label="Obrázek"
),
),
(
"title",
wagtail.blocks.CharBlock(
label="Titulek",
required=True,
),
),
(
"text",
wagtail.blocks.RichTextBlock(
label="Krátký text pod nadpisem",
required=False,
),
),
(
"page",
wagtail.blocks.PageChooserBlock(
label="Stránka",
page_type=[
"district.DistrictHomePage"
],
required=False,
),
),
(
"link",
wagtail.blocks.URLBlock(
label="Odkaz",
required=False,
),
),
],
template="styleguide2/includes/molecules/boxes/card_box_block.html",
),
label="Karty s odkazy",
),
),
],
label="Karta týmu",
),
label="Týmy",
),
),
]
),
),
],
blank=True,
verbose_name="Lidé a týmy",
),
),
migrations.AddField(
model_name="districtpersonpage",
name="after_name",
field=models.CharField(
blank=True, max_length=16, null=True, verbose_name="Tituly za jménem"
),
),
migrations.AddField(
model_name="districtpersonpage",
name="before_name",
field=models.CharField(
blank=True, max_length=32, null=True, verbose_name="Tituly před jménem"
),
),
migrations.AddField(
model_name="districtpersonpage",
name="perex",
field=models.TextField(default=""),
preserve_default=False,
),
migrations.AddField(
model_name="districtpersonpage",
name="position",
field=models.CharField(
blank=True, max_length=200, null=True, verbose_name="Pozice/povolání"
),
),
migrations.AddField(
model_name="districtpersonpage",
name="primary_group",
field=models.CharField(
blank=True,
help_text="např. 'Europarlament' nebo 'Sněmovna'",
max_length=32,
null=True,
verbose_name="Kategorie",
),
),
migrations.AddField(
model_name="districtpersonpage",
name="related_people",
field=wagtail.fields.StreamField(
[
(
"person",
wagtail.blocks.PageChooserBlock(
label="Detail osoby", page_type=["main.MainPersonPage"]
),
)
],
blank=True,
verbose_name="Další lidé",
),
),
migrations.AddField(
model_name="districtpersonpage",
name="social_links",
field=wagtail.fields.StreamField(
[
(
"social_links",
wagtail.blocks.StructBlock(
[
("text", wagtail.blocks.CharBlock(label="Název")),
("link", wagtail.blocks.URLBlock(label="Odkaz")),
(
"icon",
wagtail.blocks.CharBlock(
help_text="Seznam ikon - https://styleguide.pirati.cz/latest/?p=viewall-atoms-icons <br/>Název ikony zadejte bez tečky na začátku",
label="Ikona",
),
),
]
),
)
],
blank=True,
verbose_name="Odkazy na sociální sítě",
),
),
migrations.RunPython(migrate_people_blocks),
]
# Generated by Django 3.1.2 on 2020-10-26 22:45
# Generated by Django 5.0.4 on 2024-05-09 12:03
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("program2021", "0008_auto_20200812_2117"),
("program2021", "0004_auto_20200930_1156"),
("district", "0161_auto_20240513_1733"),
]
operations = []
# Generated by Django 5.0.4 on 2024-05-14 10:36
import wagtail.blocks
import wagtail.fields
import wagtail.images.blocks
from django.db import migrations
import shared.blocks
class Migration(migrations.Migration):
dependencies = [
("district", "0165_remove_districthomepage_show_calendar_on_hp"),
]
operations = [
migrations.AlterField(
model_name="districthomepage",
name="content",
field=wagtail.fields.StreamField(
[
(
"fullscreen_header_block",
wagtail.blocks.StructBlock(
[
(
"desktop_image",
wagtail.images.blocks.ImageChooserBlock(
help_text="Pokud není vybráno video, ukáže se na desktopu.",
label="Obrázek na pozadí (desktop)",
),
),
(
"mobile_image",
wagtail.images.blocks.ImageChooserBlock(
help_text="Pokud není vybráno video, ukáže se na mobilu.",
label="Obrázek na pozadí (mobil)",
required=False,
),
),
(
"desktop_video_url",
wagtail.blocks.URLBlock(
help_text="Pokud je vybráno, ukáže se na desktopech s povoleným autoplayem místo obrázku.",
label="Video (desktop)",
required=False,
),
),
(
"mobile_video_url",
wagtail.blocks.URLBlock(
help_text="Pokud je vybráno, ukáže se na mobilech s povoleným autoplayem místo obrázku.",
label="Video (mobil)",
required=False,
),
),
(
"desktop_line_1",
wagtail.blocks.TextBlock(
label="Desktop první řádek"
),
),
(
"desktop_line_2",
wagtail.blocks.TextBlock(
label="Desktop druhý řádek", required=False
),
),
(
"mobile_line_1",
wagtail.blocks.TextBlock(
label="První mobilní řádek"
),
),
(
"mobile_line_2",
wagtail.blocks.TextBlock(
label="Druhý mobilní řádek", required=False
),
),
(
"mobile_line_3",
wagtail.blocks.TextBlock(
label="Třetí mobilní řádek", required=False
),
),
(
"button_url",
wagtail.blocks.URLBlock(
help_text="Bez odkazu tlačítko nebude viditelné.",
label="Odkaz tlačítka",
required=False,
),
),
(
"button_text",
wagtail.blocks.CharBlock(
label="Text tlačítka", required=False
),
),
]
),
),
(
"news_block",
wagtail.blocks.StructBlock(
[
(
"title",
wagtail.blocks.CharBlock(
help_text="Nejnovější články se načtou automaticky",
label="Titulek",
),
),
(
"description",
wagtail.blocks.TextBlock(
label="Popis", required=False
),
),
],
template="styleguide2/includes/organisms/articles/district/articles_section.html",
),
),
(
"elections_block",
wagtail.blocks.StructBlock(
[
(
"title",
wagtail.blocks.CharBlock(
label="Titulek", required=True
),
),
(
"text_before_countdown",
wagtail.blocks.CharBlock(
default="Aktuálně zbývá",
label="Text před odpočtem",
required=True,
),
),
(
"countdown_timestamp",
wagtail.blocks.DateTimeBlock(
label="Datum & čas voleb", required=True
),
),
(
"buttons",
wagtail.blocks.ListBlock(
wagtail.blocks.StructBlock(
[
(
"title",
wagtail.blocks.CharBlock(
label="Titulek",
max_length=128,
required=True,
),
),
(
"page",
wagtail.blocks.PageChooserBlock(
label="Stránka", required=False
),
),
(
"link",
wagtail.blocks.URLBlock(
label="Odkaz", required=False
),
),
]
),
label="Tlačítka",
required=False,
),
),
]
),
),
(
"people_block",
wagtail.blocks.StructBlock(
[
(
"title_line_1",
wagtail.blocks.CharBlock(
label="První řádek titulku"
),
),
(
"title_line_2",
wagtail.blocks.CharBlock(
label="Druhý řádek titulku"
),
),
(
"description",
wagtail.blocks.TextBlock(label="Popis"),
),
(
"list",
wagtail.blocks.ListBlock(
shared.blocks.PersonBoxBlock, label="Boxíky"
),
),
],
template="styleguide2/includes/organisms/main_section/district/representatives_section.html",
),
),
(
"calendar_block",
wagtail.blocks.StructBlock(
[
(
"title",
wagtail.blocks.CharBlock(
label="Titulek", required=False
),
)
]
),
),
("newsletter_block", wagtail.blocks.StructBlock([])),
],
blank=True,
verbose_name="Obsah",
),
),
]
# Generated by Django 5.0.4 on 2024-05-14 11:15
import wagtail.blocks
import wagtail.fields
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("district", "0166_alter_districthomepage_content"),
]
operations = [
migrations.AlterField(
model_name="districtcontactpage",
name="contact_people",
field=wagtail.fields.StreamField(
[
(
"item",
wagtail.blocks.StructBlock(
[
(
"position",
wagtail.blocks.CharBlock(
label="Název pozice", required=False
),
),
(
"person",
wagtail.blocks.PageChooserBlock(
label="Osoba", page_type=["main.MainPersonPage"]
),
),
]
),
)
],
blank=True,
verbose_name="Kontakty",
),
),
]
# Generated by Django 3.1.1 on 2020-09-30 09:56
# Generated by Django 5.0.4 on 2024-05-14 11:15
import wagtail.core.blocks
import wagtail.core.fields
import wagtail.blocks
import wagtail.fields
import wagtail.images.blocks
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("program2021", "0003_program2021pointpage_image_title"),
("district", "0167_alter_districtcontactpage_contact_people"),
]
operations = [
migrations.AlterField(
model_name="program2021pointpage",
name="images",
field=wagtail.core.fields.StreamField(
migrations.AddField(
model_name="districtcontactpage",
name="contact_boxes",
field=wagtail.fields.StreamField(
[
(
"item",
wagtail.core.blocks.StructBlock(
wagtail.blocks.StructBlock(
[
("title", wagtail.blocks.CharBlock(label="Titulek")),
(
"image",
wagtail.images.blocks.ImageChooserBlock(
label="ilustrační obrázek"
label="Ikona"
),
),
("title", wagtail.core.blocks.CharBlock(label="popis")),
],
label="obrázek",
(
"subtitle",
wagtail.blocks.CharBlock(label="Podtitulek"),
),
]
),
)
],
blank=True,
verbose_name="ilustrační obrázky",
verbose_name="Kontaktní boxy",
),
),
]
# Generated by Django 5.0.4 on 2024-05-14 11:31
import wagtail.blocks
import wagtail.fields
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("district", "0168_districtcontactpage_contact_boxes"),
]
operations = [
migrations.AlterField(
model_name="districtcontactpage",
name="contact_people",
field=wagtail.fields.StreamField(
[
(
"item",
wagtail.blocks.StructBlock(
[
(
"position",
wagtail.blocks.CharBlock(
label="Název pozice", required=False
),
),
(
"person",
wagtail.blocks.PageChooserBlock(
label="Osoba",
page_type=["district.DistrictPersonPage"],
),
),
]
),
)
],
blank=True,
verbose_name="Kontaktní osoby",
),
),
migrations.AlterField(
model_name="districthomepage",
name="footer_person_list",
field=wagtail.fields.StreamField(
[
(
"person",
wagtail.blocks.StructBlock(
[
(
"position",
wagtail.blocks.CharBlock(
label="Název pozice", required=False
),
),
(
"person",
wagtail.blocks.PageChooserBlock(
label="Osoba",
page_type=["district.DistrictPersonPage"],
),
),
]
),
)
],
blank=True,
verbose_name="Osoby v zápatí webu",
),
),
]
# Generated by Django 5.0.4 on 2024-05-15 09:09
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("district", "0169_alter_districtcontactpage_contact_people_and_more"),
]
operations = []
# Generated by Django 5.0.4 on 2024-05-15 09:15
from django.db import migrations
def add_name_titles(apps, schema_editor):
DistrictPersonPage = apps.get_model("district", "DistrictPersonPage")
for person_page in DistrictPersonPage.objects.all():
title = person_page.title.lower()
if "bc. et bc." in title:
person_page.title = (
person_page.title.replace("Bc. et Bc. ", "")
.replace("BC. et BC. ", "")
.replace("Bc. et Bc.", "")
.replace("BC. et BC.", "")
)
title = person_page.title.lower()
person_page.before_name = "Bc. et Bc."
if "bc." in title:
person_page.title = (
person_page.title.replace("Bc. ", "")
.replace("BC. ", "")
.replace("Bc.", "")
.replace("BC.", "")
)
title = person_page.title.lower()
person_page.before_name = "Bc."
if "ing." in title:
person_page.title = (
person_page.title.replace("Ing. ", "")
.replace("ING. ", "")
.replace("Ing.", "")
.replace("ING.", "")
)
title = person_page.title.lower()
person_page.before_name = "Ing."
if "mgr. et mgr." in title:
person_page.title = (
person_page.title.replace("Mgr. et Mgr. ", "")
.replace("MGR. et MGR. ", "")
.replace("Mgr. et Mgr.", "")
.replace("MGR. et MGR.", "")
)
title = person_page.title.lower()
person_page.before_name = "Mgr. et Mgr."
if "mgr." in title:
person_page.title = (
person_page.title.replace("Mgr. ", "")
.replace("MGR. ", "")
.replace("Mgr.", "")
.replace("MGR.", "")
)
title = person_page.title.lower()
person_page.before_name = "Mgr."
if "mudr. et mudr." in title:
person_page.title = (
person_page.title.replace("MUDr. et MUDr. ", "")
.replace("MUDR. et MUDR. ", "")
.replace("MUDr. et MUDr.", "")
.replace("MUDR. et MUDR.", "")
)
title = person_page.title.lower()
person_page.before_name = "MUDr. et MUDr."
if "mudr." in title:
person_page.title = (
person_page.title.replace("MUDr. ", "")
.replace("MUDR. ", "")
.replace("MUDr.", "")
.replace("MUDR.", "")
)
title = person_page.title.lower()
person_page.before_name = "MUDr."
if "rndr. et rndr." in title:
person_page.title = (
person_page.title.replace("RNDr. et RNDr. ", "")
.replace("RNDR. et RNDR. ", "")
.replace("RNDr. et RNDr.", "")
.replace("RNDR. et RNDR.", "")
)
title = person_page.title.lower()
person_page.before_name = "RNDr. et RNDr"
if "rndr." in title:
person_page.title = (
person_page.title.replace("RNDr. ", "")
.replace("RNDR. ", "")
.replace("RNDr.", "")
.replace("RNDR.", "")
)
title = person_page.title.lower()
person_page.before_name = "RNDr."
if "phdr. et phdr." in title:
person_page.title = (
person_page.title.replace("PhDr. et PhDr. ", "")
.replace("PHDR. et PHDR. ", "")
.replace("PhDr. et PhDr.", "")
.replace("PHDR. et PHDR.", "")
)
title = person_page.title.lower()
person_page.before_name = "PhDr. et PhDr."
if "phdr." in title:
person_page.title = (
person_page.title.replace("PhDr. ", "")
.replace("PHDR. ", "")
.replace("PhDr.", "")
.replace("PHDR.", "")
)
title = person_page.title.lower()
person_page.before_name = "PhDr."
if "ph.d." in title:
person_page.title = (
person_page.title.replace("Ph.D. ", "")
.replace("PH.D. ", "")
.replace("Ph.D.", "")
.replace("PH.D.", "")
)
title = person_page.title.lower()
person_page.after_name = "Ph.D."
if "ph.d. et ph.d." in title:
person_page.title = (
person_page.title.replace("Ph.D. et Ph.D. ", "")
.replace("PH.D. et PH.D. ", "")
.replace("Ph.D. et Ph.D.", "")
.replace("PH.D. et PH.D.", "")
)
title = person_page.title.lower()
person_page.after_name = "Ph.D. et Ph.D."
person_page.save()
class Migration(migrations.Migration):
dependencies = [
("district", "0170_districtpersonpage_after_name_and_more"),
]
operations = [migrations.RunPython(add_name_titles)]
# Generated by Django 5.0.4 on 2024-05-15 10:15
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("district", "0171_auto_20240515_1115"),
]
operations = [
migrations.RemoveField(
model_name="districtpersonpage",
name="position",
),
migrations.RenameField(
model_name="districtpersonpage",
old_name="job_function",
new_name="position",
),
]
# Generated by Django 5.0.4 on 2024-05-15 10:17
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("district", "0172_auto_20240515_1215"),
]
operations = [
migrations.AlterModelOptions(
name="districtpersonpage",
options={"verbose_name": "Detail osoby"},
),
]
# Generated by Django 5.0.4 on 2024-05-15 10:17
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("district", "0173_alter_districtpersonpage_options"),
]
operations = [
migrations.AlterField(
model_name="districtpersonpage",
name="position",
field=models.CharField(
blank=True,
help_text="Např. 'Předseda'",
max_length=200,
null=True,
verbose_name="Funkce",
),
),
]
# Generated by Django 5.0.4 on 2024-05-15 10:40
from django.db import migrations
from shared.blocks import SocialLinkBlock
def add_social_media_blocks(apps, schema_editor):
DistrictPersonPage = apps.get_model("district", "DistrictPersonPage")
for person_page in DistrictPersonPage.objects.all():
if person_page.facebook_url:
person_page.social_links.append(
(
"social_links",
SocialLinkBlock().to_python(
{
"icon": "ico--facebook",
"text": "Facebook",
"link": person_page.facebook_url,
}
),
)
)
if person_page.instagram_url:
person_page.social_links.append(
(
"social_links",
SocialLinkBlock().to_python(
{
"icon": "ico--instagram",
"text": "Instagram",
"link": person_page.instagram_url,
}
),
)
)
if person_page.twitter_url:
person_page.social_links.append(
(
"social_links",
SocialLinkBlock().to_python(
{
"icon": "ico--twitter",
"text": "Twitter",
"link": person_page.twitter_url,
}
),
)
)
if person_page.youtube_url:
person_page.social_links.append(
(
"social_links",
SocialLinkBlock().to_python(
{
"icon": "ico--youtube",
"text": "YouTube",
"link": person_page.youtube_url,
}
),
)
)
if person_page.flickr_url:
person_page.social_links.append(
(
"social_links",
SocialLinkBlock().to_python(
{
"icon": "ico--flickr",
"text": "Flickr",
"link": person_page.flickr_url,
}
),
)
)
if person_page.custom_web_url:
person_page.social_links.append(
(
"social_links",
SocialLinkBlock().to_python(
{
"icon": "ico--globe",
"text": "Stránky",
"link": person_page.custom_web_url,
}
),
)
)
for other_link_block in person_page.other_urls.get_prep_value():
person_page.social_links.append(
(
"social_links",
SocialLinkBlock().to_python(
{
"icon": other_link_block["value"]["custom_icon"],
"text": other_link_block["value"]["title"],
"link": other_link_block["value"]["url"],
}
),
)
)
person_page.save()
class Migration(migrations.Migration):
dependencies = [
("district", "0174_alter_districtpersonpage_position"),
]
operations = [migrations.RunPython(add_social_media_blocks)]
# Generated by Django 5.0.4 on 2024-05-15 10:51
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("district", "0175_auto_20240515_1240"),
("wagtailimages", "0026_delete_uploadedimage"),
]
operations = [
migrations.RemoveField(
model_name="districtpersonpage",
name="custom_web_url",
),
migrations.RemoveField(
model_name="districtpersonpage",
name="facebook_url",
),
migrations.RemoveField(
model_name="districtpersonpage",
name="flickr_url",
),
migrations.RemoveField(
model_name="districtpersonpage",
name="instagram_url",
),
migrations.RemoveField(
model_name="districtpersonpage",
name="other_urls",
),
migrations.RemoveField(
model_name="districtpersonpage",
name="twitter_url",
),
migrations.RemoveField(
model_name="districtpersonpage",
name="youtube_url",
),
migrations.AlterField(
model_name="districtpersonpage",
name="main_image",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="+",
to="wagtailimages.image",
verbose_name="Hlavní obrázek",
),
),
migrations.AlterField(
model_name="districtpersonpage",
name="profile_image",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="+",
to="wagtailimages.image",
verbose_name="Profilový obrázek",
),
),
]
# Generated by Django 5.0.4 on 2024-05-15 10:57
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("district", "0176_remove_districtpersonpage_custom_web_url_and_more"),
]
operations = [
migrations.RemoveField(
model_name="districtpersonpage",
name="show_email",
),
migrations.AlterField(
model_name="districtpersonpage",
name="email",
field=models.CharField(
blank=True, max_length=128, null=True, verbose_name="E-mail"
),
),
migrations.AlterField(
model_name="districtpersonpage",
name="phone",
field=models.CharField(
blank=True, max_length=16, null=True, verbose_name="Telefonní kontakt"
),
),
]
# Generated by Django 5.0.4 on 2024-05-15 13:05
import wagtail
from django.db import migrations, models
def update_person_page_primary_group(apps, schema_editor):
DistrictPeoplePage = apps.get_model("district", "DistrictPeoplePage")
DistrictPersonPage = apps.get_model("district", "DistrictPersonPage")
processed_page_ids = []
for people_page in DistrictPeoplePage.objects.all():
for group_block in people_page.people.get_prep_value():
if group_block["type"] != "people_group":
continue
primary_group = group_block["value"]["title"]
person_page_ids = group_block["value"]["person_list"]
person_pages = []
for id in person_page_ids:
person_pages.append(
DistrictPersonPage.objects.filter(id=id["value"]).first()
)
if len(primary_group) > 64:
continue # Too long!
for page in person_pages:
if page.id in processed_page_ids:
continue
page.primary_group = primary_group
page.save()
processed_page_ids.append(page.id)
class Migration(migrations.Migration):
dependencies = [
("district", "0177_remove_districtpersonpage_show_email_and_more"),
]
operations = [
migrations.AlterField(
model_name="districtpersonpage",
name="primary_group",
field=models.CharField(
blank=True,
help_text="např. 'Europarlament' nebo 'Sněmovna'",
max_length=64,
null=True,
verbose_name="Kategorie",
),
),
migrations.AlterField(
model_name="districtpersonpage",
name="text",
field=wagtail.fields.RichTextField(),
),
migrations.RunPython(update_person_page_primary_group),
]
# Generated by Django 5.0.4 on 2024-05-16 11:15
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("district", "0178_auto_20240515_1505"),
]
operations = [
migrations.RenameField(
model_name="districtcontactpage",
old_name="text",
new_name="text_backup",
),
]
# Generated by Django 5.0.4 on 2024-05-16 11:15
import wagtail.blocks
import wagtail.fields
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("district", "0179_rename_text_districtcontactpage_text_backup"),
]
operations = [
migrations.AddField(
model_name="districtcontactpage",
name="text",
field=wagtail.fields.StreamField(
[
(
"two_columns_text",
wagtail.blocks.StructBlock(
[
(
"text_column_1",
wagtail.blocks.RichTextBlock(
label="První sloupec textu"
),
),
(
"text_column_2",
wagtail.blocks.RichTextBlock(
label="Druhý sloupec textu"
),
),
]
),
)
],
blank=True,
verbose_name="Kontaktní informace",
),
),
]
# Generated by Django 5.0.4 on 2024-05-16 11:15
from django.db import migrations
from shared.blocks import TwoTextColumnBlock
def migrate_contact_page_text(apps, schema_editor):
DistrictContactPage = apps.get_model("district", "DistrictContactPage")
for page in DistrictContactPage.objects.all():
if not page.text_backup:
continue
page.text.append(
(
"two_columns_text",
TwoTextColumnBlock().to_python(
{"text_column_1": page.text_backup, "text_column_2": ""}
),
)
)
page.save()
class Migration(migrations.Migration):
dependencies = [
("district", "0180_districtcontactpage_text"),
]
operations = [migrations.RunPython(migrate_contact_page_text)]
# Generated by Django 5.0.4 on 2024-05-16 12:01
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("district", "0181_auto_20240516_1315"),
("wagtailimages", "0026_delete_uploadedimage"),
]
operations = [
migrations.AlterModelOptions(
name="districtcustompage",
options={"verbose_name": "Jednoduchá stárnka"},
),
migrations.AddField(
model_name="districtcustompage",
name="main_image",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="+",
to="wagtailimages.image",
verbose_name="Obrázek na pozadí hlavičky",
),
),
]