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

add button to homepage

parent e4d1e1a2
Branches
No related tags found
2 merge requests!882Release,!879Add button to homepage
Pipeline #16293 passed
Showing
with 564 additions and 29 deletions
from shared.forms import JekyllImportForm as SharedJekyllImportForm
import os
from django import forms
from shared.forms import JekyllImportForm as SharedJekyllImportForm
from .tasks import import_jekyll_articles
......
import logging
from celery import shared_task
from shared.jekyll_import import JekyllArticleImporter
logger = logging.getLogger(__name__)
......
from shared.forms import JekyllImportForm as SharedJekyllImportForm
import os
from shared.forms import JekyllImportForm as SharedJekyllImportForm
from .tasks import import_jekyll_articles
......
......@@ -46,9 +46,9 @@ from shared.models import ( # MenuMixin,
)
from shared.utils import make_promote_panels, subscribe_to_newsletter
from tuning import admin_help
from .forms import JekyllImportForm
from . import blocks
from .forms import JekyllImportForm
class ElectionsHomePage(MainHomePageMixin):
......
import logging
from celery import shared_task
from shared.jekyll_import import JekyllArticleImporter
logger = logging.getLogger(__name__)
......
......@@ -97,6 +97,15 @@ class HomePageCarouseSlideBlock(StructBlock):
mobile_line_2 = TextBlock(label="Druhý mobilní řádek")
mobile_line_3 = TextBlock(label="Třetí mobilní řádek")
image = ImageChooserBlock(label="Obrázek nahrazující animaci", required=False)
button_url = URLBlock(
label="Odkaz tlačítka",
help_text="Bez odkazu tlačítko nebude viditelné.",
required=False,
)
button_text = CharBlock(label="Text tlačítka", required=False)
class Meta:
template = "styleguide2/includes/molecules/menus/carousel.html"
icon = "form"
......
from shared.forms import JekyllImportForm as SharedJekyllImportForm
import os
from shared.forms import JekyllImportForm as SharedJekyllImportForm
from .tasks import import_jekyll_articles
......
# Generated by Django 4.1.10 on 2024-01-17 10:49
import wagtail.blocks
import wagtail.fields
import wagtail.images.blocks
from django.db import migrations
import main.blocks
class Migration(migrations.Migration):
dependencies = [
("main", "0065_alter_mainarticlepage_content_and_more"),
]
operations = [
migrations.AlterField(
model_name="mainhomepage",
name="content",
field=wagtail.fields.StreamField(
[
(
"carousel",
wagtail.blocks.StructBlock(
[
(
"image",
wagtail.images.blocks.ImageChooserBlock(
label="Obrázek nahrazující animaci",
required=False,
),
),
(
"desktop_line_1",
wagtail.blocks.TextBlock(
label="Desktop první řádek"
),
),
(
"desktop_line_2",
wagtail.blocks.TextBlock(
label="Desktop druhý řádek"
),
),
(
"mobile_line_1",
wagtail.blocks.TextBlock(
label="První mobilní řádek"
),
),
(
"mobile_line_2",
wagtail.blocks.TextBlock(
label="Druhý mobilní řádek"
),
),
(
"mobile_line_3",
wagtail.blocks.TextBlock(
label="Třetí mobilní řádek"
),
),
]
),
),
(
"news",
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"),
),
],
template="styleguide2/includes/organisms/articles/articles_section.html",
),
),
("europarl_news", wagtail.blocks.StructBlock([])),
(
"people",
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(
main.blocks.BoxBlock, label="Boxíky"
),
),
]
),
),
(
"regions",
wagtail.blocks.StructBlock(
[
(
"title",
wagtail.blocks.CharBlock(
help_text="Články pro regiony se načtou automaticky",
label="Titulek",
),
)
]
),
),
(
"boxes",
wagtail.blocks.StructBlock(
[
("title", wagtail.blocks.CharBlock(label="Nadpis")),
(
"list",
wagtail.blocks.ListBlock(
main.blocks.BoxBlock, label="Boxíky"
),
),
(
"image",
wagtail.images.blocks.ImageChooserBlock(
label="Obrázek pozadí", required=False
),
),
]
),
),
],
blank=True,
use_json_field=True,
verbose_name="Hlavní obsah",
),
),
]
# Generated by Django 4.1.10 on 2024-01-17 10:52
import wagtail.blocks
import wagtail.fields
import wagtail.images.blocks
from django.db import migrations
import main.blocks
class Migration(migrations.Migration):
dependencies = [
("main", "0066_alter_mainhomepage_content"),
]
operations = [
migrations.AlterField(
model_name="mainhomepage",
name="content",
field=wagtail.fields.StreamField(
[
(
"carousel",
wagtail.blocks.StructBlock(
[
(
"desktop_line_1",
wagtail.blocks.TextBlock(
label="Desktop první řádek"
),
),
(
"desktop_line_2",
wagtail.blocks.TextBlock(
label="Desktop druhý řádek"
),
),
(
"mobile_line_1",
wagtail.blocks.TextBlock(
label="První mobilní řádek"
),
),
(
"mobile_line_2",
wagtail.blocks.TextBlock(
label="Druhý mobilní řádek"
),
),
(
"mobile_line_3",
wagtail.blocks.TextBlock(
label="Třetí mobilní řádek"
),
),
(
"image",
wagtail.images.blocks.ImageChooserBlock(
label="Obrázek nahrazující animaci",
required=False,
),
),
]
),
),
(
"news",
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"),
),
],
template="styleguide2/includes/organisms/articles/articles_section.html",
),
),
("europarl_news", wagtail.blocks.StructBlock([])),
(
"people",
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(
main.blocks.BoxBlock, label="Boxíky"
),
),
]
),
),
(
"regions",
wagtail.blocks.StructBlock(
[
(
"title",
wagtail.blocks.CharBlock(
help_text="Články pro regiony se načtou automaticky",
label="Titulek",
),
)
]
),
),
(
"boxes",
wagtail.blocks.StructBlock(
[
("title", wagtail.blocks.CharBlock(label="Nadpis")),
(
"list",
wagtail.blocks.ListBlock(
main.blocks.BoxBlock, label="Boxíky"
),
),
(
"image",
wagtail.images.blocks.ImageChooserBlock(
label="Obrázek pozadí", required=False
),
),
]
),
),
],
blank=True,
use_json_field=True,
verbose_name="Hlavní obsah",
),
),
]
# Generated by Django 4.1.10 on 2024-01-17 11:05
import wagtail.blocks
import wagtail.fields
import wagtail.images.blocks
from django.db import migrations
import main.blocks
class Migration(migrations.Migration):
dependencies = [
("main", "0067_alter_mainhomepage_content"),
]
operations = [
migrations.AlterField(
model_name="mainhomepage",
name="content",
field=wagtail.fields.StreamField(
[
(
"carousel",
wagtail.blocks.StructBlock(
[
(
"desktop_line_1",
wagtail.blocks.TextBlock(
label="Desktop první řádek"
),
),
(
"desktop_line_2",
wagtail.blocks.TextBlock(
label="Desktop druhý řádek"
),
),
(
"mobile_line_1",
wagtail.blocks.TextBlock(
label="První mobilní řádek"
),
),
(
"mobile_line_2",
wagtail.blocks.TextBlock(
label="Druhý mobilní řádek"
),
),
(
"mobile_line_3",
wagtail.blocks.TextBlock(
label="Třetí mobilní řádek"
),
),
(
"image",
wagtail.images.blocks.ImageChooserBlock(
label="Obrázek nahrazující animaci",
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",
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"),
),
],
template="styleguide2/includes/organisms/articles/articles_section.html",
),
),
("europarl_news", wagtail.blocks.StructBlock([])),
(
"people",
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(
main.blocks.BoxBlock, label="Boxíky"
),
),
]
),
),
(
"regions",
wagtail.blocks.StructBlock(
[
(
"title",
wagtail.blocks.CharBlock(
help_text="Články pro regiony se načtou automaticky",
label="Titulek",
),
)
]
),
),
(
"boxes",
wagtail.blocks.StructBlock(
[
("title", wagtail.blocks.CharBlock(label="Nadpis")),
(
"list",
wagtail.blocks.ListBlock(
main.blocks.BoxBlock, label="Boxíky"
),
),
(
"image",
wagtail.images.blocks.ImageChooserBlock(
label="Obrázek pozadí", required=False
),
),
]
),
),
],
blank=True,
use_json_field=True,
verbose_name="Hlavní obsah",
),
),
]
......@@ -46,9 +46,9 @@ from shared.models import ( # MenuMixin,
)
from shared.utils import make_promote_panels, subscribe_to_newsletter
from tuning import admin_help
from .forms import JekyllImportForm
from . import blocks
from .forms import JekyllImportForm
class MainHomePage(MainHomePageMixin):
......
import logging
from celery import shared_task
from shared.jekyll_import import JekyllArticleImporter
logger = logging.getLogger(__name__)
......
from django import forms
from wagtail.admin.forms import WagtailAdminPageForm
from wagtail.models.collections import Collection
import os
class SubscribeForm(forms.Form):
......
......@@ -13,7 +13,6 @@ from io import StringIO
from typing import List
from urllib.error import HTTPError
from uuid import uuid4
import os
import bleach
import markdown.serializers
......@@ -344,9 +343,12 @@ class JekyllArticleImporter:
# Computed proprs
import time
time.sleep(5)
self.article_parent_page = self.article_parent_page_model.objects.filter(id=self.article_parent_page_id).first()
self.article_parent_page = self.article_parent_page_model.objects.filter(
id=self.article_parent_page_id
).first()
self.path, self.repo_name = get_path_and_repo_name(self.url, self.use_git)
self.site = self.article_parent_page.get_site()
......
......@@ -266,8 +266,7 @@ class MainHomePageMixin(
context["article_data_list"] = self.materialize_shared_articles_query(
self.append_all_shared_articles_query(
self.article_page_model.objects.live().all()
)
.order_by("-union_date")[:3]
).order_by("-union_date")[:3]
)
return context
......@@ -446,8 +445,7 @@ class MainArticlesPageMixin(
return self.materialize_shared_articles_query(
self.append_all_shared_articles_query(
self.root_page.article_page_model.objects.filter(filter).live().all()
)
.order_by("-union_date")
).order_by("-union_date")
)
def get_article_data_list(
......@@ -458,17 +456,16 @@ class MainArticlesPageMixin(
if search_filter is None:
search_filter = models.Q()
target_date_list = (
self.append_all_shared_articles_query(
target_date_list = self.append_all_shared_articles_query(
self.root_page.article_page_model.objects.filter(search_filter).live()
)
.order_by("-union_date")
)
).order_by("-union_date")
if not target_date_list:
return []
target_date = target_date_list[0]["union_date"] - relativedelta(months=months_back)
target_date = target_date_list[0]["union_date"] - relativedelta(
months=months_back
)
first_day_of_target_month = target_date.replace(day=1)
filter = models.Q(date__gte=first_day_of_target_month) & search_filter
......@@ -544,9 +541,12 @@ class MainArticlesPageMixin(
) != 0 and (
self.materialize_shared_articles_query(
self.append_all_shared_articles_query(
self.root_page.article_page_model.objects.filter(search_filter).live().all()
)
.order_by("union_date")[:2] # LIMIT 2
self.root_page.article_page_model.objects.filter(search_filter)
.live()
.all()
).order_by("union_date")[
:2
] # LIMIT 2
)[0]
not in article_timeline_list[-1]["articles"]
)
......@@ -590,9 +590,12 @@ class MainArticlesPageMixin(
self.append_all_shared_articles_query(
self.root_page.article_page_model.objects.filter(
search_filter
).live().all()
)
.order_by("union_date")[:2] # LIMIT 2
.live()
.all()
).order_by("union_date")[
:2
] # LIMIT 2
)[0]
not in article_timeline_list[-1]["articles"]
)
......
{% extends "styleguide2/includes/atoms/buttons/round_button.html" %}
{% block element_opener %}button{% endblock %}
{% block element_closer %}button{% endblock %}
{% block href %}{% endblock %}
{% load static %}
{% load static wagtailimages_tags %}
<div>
<div class="header-carousel">
<div class="h-[700px] xl:h-screen relative">
<{% if self.button_url %}a{% else %}div{% endif %}
class="
block h-[700px] xl:h-screen relative
{% if self.button_url %}group cursor-pointer{% endif %}
"
{% if self.button_url %}
href="{{ self.button_url }}"
{% endif %}
>
<img
class="
header-carousel--image
lg:hidden
"
{% if not self.image %}
src="{% static 'styleguide2/images/background-images/bg-flag-mobile.gif' %}"
{% else %}
{% image self.image original as background_image %}
src="{{ background_image.url }}"
{% endif %}
draggable="false"
>
......@@ -35,8 +53,17 @@
<div>{{ self.desktop_line_2 }}</div>
</h1>
{% if self.button_url %}
<div class="ml-4 text-lg group">
{% firstof self.button_text "Více informací" as button_text %}
{% include "styleguide2/includes/atoms/buttons/round_button_without_url.html" with button_text=button_text %}
</div>
{% endif %}
</div>
</div>
</{% if self.button_url %}a{% else %}div{% endif %}>
</div>
</div>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment