Skip to content
Snippets Groups Projects
Commit ad45c8a7 authored by Tomáš Valenta's avatar Tomáš Valenta
Browse files

fix unpublished articles appearing on homepage

parent 2cb41a9d
No related branches found
No related tags found
2 merge requests!726fix unpublished articles appearing on homepage,!725Fix unpublished articles appearing on homepage
Pipeline #11547 passed
# Generated by Django 4.1.5 on 2023-02-14 13:33 # Generated by Django 4.1.5 on 2023-02-14 13:33
from django.db import migrations
import wagtail.blocks import wagtail.blocks
import wagtail.fields import wagtail.fields
import wagtail.images.blocks import wagtail.images.blocks
from django.db import migrations
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
('main', '0044_alter_mainprogrampage_program'), ("main", "0044_alter_mainprogrampage_program"),
] ]
operations = [ operations = [
migrations.AlterField( migrations.AlterField(
model_name='mainprogrampage', model_name="mainprogrampage",
name='program', name="program",
field=wagtail.fields.StreamField([('program_group', wagtail.blocks.StructBlock([('title', wagtail.blocks.CharBlock(label='Titulek části programu')), ('slug', wagtail.blocks.CharBlock(help_text='Není třeba vyplňovat, bude automaticky vyplněno', label='Slug části programu', required=False)), ('perex', wagtail.blocks.RichTextBlock(features=['h3', 'h4', 'h5', 'bold', 'italic', 'ol', 'ul', 'hr', 'link', 'document-link', 'image', 'superscript', 'subscript', 'strikethrough', 'blockquote', 'embed'], label='Perex části programu', required=False)), ('point_list', wagtail.blocks.ListBlock(wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock(label='Odkaz pokrývající celou tuto část', required=False)), ('icon', wagtail.images.blocks.ImageChooserBlock(label='Ikona', required=False)), ('title', wagtail.blocks.CharBlock(label='Titulek článku programu')), ('text', wagtail.blocks.RichTextBlock(features=['h3', 'h4', 'h5', 'bold', 'italic', 'ol', 'ul', 'hr', 'link', 'document-link', 'image', 'superscript', 'subscript', 'strikethrough', 'blockquote', 'embed'], label='Obsah'))]), label='Jednotlivé články programu'))])), ('program_group_crossroad', wagtail.blocks.StructBlock([('title', wagtail.blocks.CharBlock(label='Titulek části programu')), ('slug', wagtail.blocks.CharBlock(help_text='Není třeba vyplňovat, bude automaticky vyplněno', label='Slug části programu', required=False)), ('perex', wagtail.blocks.RichTextBlock(features=['h3', 'h4', 'h5', 'bold', 'italic', 'ol', 'ul', 'hr', 'link', 'document-link', 'image', 'superscript', 'subscript', 'strikethrough', 'blockquote', 'embed'], label='Perex části programu', required=False)), ('point_list', 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=['main.MainArticlesPage', 'main.MainArticlePage', 'main.MainProgramPage', 'main.MainPeoplePage', 'main.MainPersonPage', 'main.MainSimplePage', 'main.MainContactPage', 'main.MainCrossroadPage'], required=False)), ('link', wagtail.blocks.URLBlock(label='Odkaz', required=False))]), label='Karty programu'))])), ('program_group_popout', wagtail.blocks.StructBlock([('title', wagtail.blocks.CharBlock(label='Titulek části programu')), ('slug', wagtail.blocks.CharBlock(help_text='Není třeba vyplňovat, bude automaticky vyplněno', label='Slug části programu', required=False)), ('perex', wagtail.blocks.RichTextBlock(features=['h3', 'h4', 'h5', 'bold', 'italic', 'ol', 'ul', 'hr', 'link', 'document-link', 'image', 'superscript', 'subscript', 'strikethrough', 'blockquote', 'embed'], label='Perex části programu', required=False)), ('categories', wagtail.blocks.ListBlock(wagtail.blocks.StructBlock([('name', wagtail.blocks.CharBlock(label='Název')), ('icon', wagtail.images.blocks.ImageChooserBlock(label='Ikona', required=False)), ('point_list', wagtail.blocks.ListBlock(wagtail.blocks.StructBlock([('title', wagtail.blocks.CharBlock(label='Titulek vyskakovacího bloku')), ('content', wagtail.blocks.RichTextBlock(features=['h3', 'h4', 'h5', 'bold', 'italic', 'ol', 'ul', 'hr', 'link', 'document-link', 'image', 'superscript', 'subscript', 'strikethrough', 'blockquote', 'embed'], label='Obsah'))]), label='Jednotlivé bloky programu'))]), label='Kategorie programu'))]))], blank=True, use_json_field=True, verbose_name='Program'), field=wagtail.fields.StreamField(
[
(
"program_group",
wagtail.blocks.StructBlock(
[
(
"title",
wagtail.blocks.CharBlock(
label="Titulek části programu"
),
),
(
"slug",
wagtail.blocks.CharBlock(
help_text="Není třeba vyplňovat, bude automaticky vyplněno",
label="Slug části programu",
required=False,
),
),
(
"perex",
wagtail.blocks.RichTextBlock(
features=[
"h3",
"h4",
"h5",
"bold",
"italic",
"ol",
"ul",
"hr",
"link",
"document-link",
"image",
"superscript",
"subscript",
"strikethrough",
"blockquote",
"embed",
],
label="Perex části programu",
required=False,
),
),
(
"point_list",
wagtail.blocks.ListBlock(
wagtail.blocks.StructBlock(
[
(
"url",
wagtail.blocks.URLBlock(
label="Odkaz pokrývající celou tuto část",
required=False,
),
),
(
"icon",
wagtail.images.blocks.ImageChooserBlock(
label="Ikona", required=False
),
),
(
"title",
wagtail.blocks.CharBlock(
label="Titulek článku programu"
),
),
(
"text",
wagtail.blocks.RichTextBlock(
features=[
"h3",
"h4",
"h5",
"bold",
"italic",
"ol",
"ul",
"hr",
"link",
"document-link",
"image",
"superscript",
"subscript",
"strikethrough",
"blockquote",
"embed",
],
label="Obsah",
),
),
]
),
label="Jednotlivé články programu",
),
),
]
),
),
(
"program_group_crossroad",
wagtail.blocks.StructBlock(
[
(
"title",
wagtail.blocks.CharBlock(
label="Titulek části programu"
),
),
(
"slug",
wagtail.blocks.CharBlock(
help_text="Není třeba vyplňovat, bude automaticky vyplněno",
label="Slug části programu",
required=False,
),
),
(
"perex",
wagtail.blocks.RichTextBlock(
features=[
"h3",
"h4",
"h5",
"bold",
"italic",
"ol",
"ul",
"hr",
"link",
"document-link",
"image",
"superscript",
"subscript",
"strikethrough",
"blockquote",
"embed",
],
label="Perex části programu",
required=False,
),
),
(
"point_list",
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=[
"main.MainArticlesPage",
"main.MainArticlePage",
"main.MainProgramPage",
"main.MainPeoplePage",
"main.MainPersonPage",
"main.MainSimplePage",
"main.MainContactPage",
"main.MainCrossroadPage",
],
required=False,
),
),
(
"link",
wagtail.blocks.URLBlock(
label="Odkaz", required=False
),
),
]
),
label="Karty programu",
),
),
]
),
),
(
"program_group_popout",
wagtail.blocks.StructBlock(
[
(
"title",
wagtail.blocks.CharBlock(
label="Titulek části programu"
),
),
(
"slug",
wagtail.blocks.CharBlock(
help_text="Není třeba vyplňovat, bude automaticky vyplněno",
label="Slug části programu",
required=False,
),
),
(
"perex",
wagtail.blocks.RichTextBlock(
features=[
"h3",
"h4",
"h5",
"bold",
"italic",
"ol",
"ul",
"hr",
"link",
"document-link",
"image",
"superscript",
"subscript",
"strikethrough",
"blockquote",
"embed",
],
label="Perex části programu",
required=False,
),
),
(
"categories",
wagtail.blocks.ListBlock(
wagtail.blocks.StructBlock(
[
(
"name",
wagtail.blocks.CharBlock(
label="Název"
),
),
(
"icon",
wagtail.images.blocks.ImageChooserBlock(
label="Ikona", required=False
),
),
(
"point_list",
wagtail.blocks.ListBlock(
wagtail.blocks.StructBlock(
[
(
"title",
wagtail.blocks.CharBlock(
label="Titulek vyskakovacího bloku"
),
),
(
"content",
wagtail.blocks.RichTextBlock(
features=[
"h3",
"h4",
"h5",
"bold",
"italic",
"ol",
"ul",
"hr",
"link",
"document-link",
"image",
"superscript",
"subscript",
"strikethrough",
"blockquote",
"embed",
],
label="Obsah",
),
),
]
),
label="Jednotlivé bloky programu",
),
),
]
),
label="Kategorie programu",
),
),
]
),
),
],
blank=True,
use_json_field=True,
verbose_name="Program",
),
), ),
] ]
...@@ -214,13 +214,17 @@ class MainHomePage( ...@@ -214,13 +214,17 @@ class MainHomePage(
context["regions"] = REGION_CHOICES context["regions"] = REGION_CHOICES
context["article_data_list"] = MainArticlePage.objects.filter( context["article_data_list"] = (
region__isnull=False MainArticlePage.objects.filter(region__isnull=False)
).order_by("-date")[:3] .live()
.order_by("-date")[:3]
)
articles_for_article_section = MainArticlePage.objects.filter( articles_for_article_section = (
article_type=ARTICLE_TYPES.PRESS_RELEASE MainArticlePage.objects.filter(article_type=ARTICLE_TYPES.PRESS_RELEASE)
).order_by("-date") .live()
.order_by("-date")
)
context["article_main"] = ( context["article_main"] = (
articles_for_article_section[0] if articles_for_article_section else None articles_for_article_section[0] if articles_for_article_section else None
) )
...@@ -401,9 +405,14 @@ class MainArticlesPage( ...@@ -401,9 +405,14 @@ class MainArticlesPage(
target_date = target_date_list[0] - relativedelta(months=months_back) target_date = target_date_list[0] - relativedelta(months=months_back)
first_day_of_target_month = target_date.replace(day=1) first_day_of_target_month = target_date.replace(day=1)
sorted_article_qs = MainArticlePage.objects.filter( sorted_article_qs = (
date__gt=first_day_of_target_month, article_type=ARTICLE_TYPES.WORK_TIMELINE MainArticlePage.objects.filter(
).order_by("-date") date__gt=first_day_of_target_month,
article_type=ARTICLE_TYPES.WORK_TIMELINE,
)
.live()
.order_by("-date")
)
article_data_list = [] article_data_list = []
...@@ -433,11 +442,11 @@ class MainArticlesPage( ...@@ -433,11 +442,11 @@ class MainArticlesPage(
article_type=ARTICLE_TYPES.WORK_TIMELINE article_type=ARTICLE_TYPES.WORK_TIMELINE
).count() > len(article_timeline_list) ).count() > len(article_timeline_list)
article_list = MainArticlePage.objects.filter( article_list = (
article_type=ARTICLE_TYPES.PRESS_RELEASE MainArticlePage.objects.filter(article_type=ARTICLE_TYPES.PRESS_RELEASE)
).order_by("-date")[ .order_by("-date")
:11 .live()[:11]
] # dám LIMIT +1, abych věděl, jestli má cenu show_next ) # dám LIMIT +1, abych věděl, jestli má cenu show_next
ctx["article_article_list"] = article_list[:10] ctx["article_article_list"] = article_list[:10]
ctx["show_next_article"] = len(article_list) > 10 ctx["show_next_article"] = len(article_list) > 10
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment