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

elections2021: Date in PDF export

parent b6e256ee
No related branches found
No related tags found
2 merge requests!318elections2021: Date in PDF export,!317elections2021: Date in PDF export
Pipeline #4519 passed
import re import re
from datetime import date
from io import BytesIO
from pathlib import Path from pathlib import Path
from django.core.management.base import BaseCommand, CommandError from django.core.management.base import BaseCommand, CommandError
...@@ -107,11 +109,14 @@ def fancy_export(output_file): ...@@ -107,11 +109,14 @@ def fancy_export(output_file):
content = render_to_string( content = render_to_string(
"elections2021/export_program_fancy.html", {"points": points} "elections2021/export_program_fancy.html", {"points": points}
) )
today = date.today().strftime("%d.%m.%Y")
extra_css = '@page { @bottom-left { content: "%s" }}' % today
font_config = FontConfiguration() font_config = FontConfiguration()
html = HTML(string=content, url_fetcher=local_fetcher) html = HTML(string=content, url_fetcher=local_fetcher)
css = CSS(str(STATICS_DIR / "style.css"), font_config=font_config) css = CSS(str(STATICS_DIR / "style.css"), font_config=font_config)
document = html.render(stylesheets=[css], font_config=font_config) css2 = CSS(BytesIO(extra_css.encode("utf-8")), font_config=font_config)
document = html.render(stylesheets=[css, css2], font_config=font_config)
document.write_pdf(tmp_file) document.write_pdf(tmp_file)
merger = PdfFileMerger() merger = PdfFileMerger()
......
# Generated by Django 3.2.5 on 2021-07-15 21:54
import wagtail.core.blocks
import wagtail.core.fields
import wagtail.images.blocks
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("elections2021", "0033_elections2021governmentteampage"),
]
operations = [
migrations.AlterField(
model_name="elections2021homepage",
name="carousel",
field=wagtail.core.fields.StreamField(
[
(
"slide",
wagtail.core.blocks.StructBlock(
[
(
"title",
wagtail.core.blocks.CharBlock(label="titulek"),
),
(
"photo",
wagtail.images.blocks.ImageChooserBlock(
label="fotka"
),
),
(
"button_label",
wagtail.core.blocks.CharBlock(
label="text tlačítka"
),
),
(
"page",
wagtail.core.blocks.PageChooserBlock(
label="stránka do tlačítka",
page_type=[
"elections2021.Elections2021ArticlesPage",
"elections2021.Elections2021CandidatesListPage",
"elections2021.Elections2021CandidatesMapPage",
"elections2021.Elections2021ProgramPage",
"elections2021.Elections2021QuestionsPage",
"elections2021.Elections2021ProgramAppPage",
"elections2021.Elections2021TextPage",
"elections2021.Elections2021StrategicListPage",
"elections2021.Elections2021StrategicPage",
"elections2021.Elections2021MythsPage",
"elections2021.Elections2021DownloadsPage",
"elections2021.Elections2021GovernmentTeamPage",
],
required=False,
),
),
(
"raw_url",
wagtail.core.blocks.CharBlock(
label="ručně zadaný odkaz do tlačítka (místo stránky)",
required=False,
),
),
]
),
)
],
blank=True,
verbose_name="obsah slideru",
),
),
migrations.AlterField(
model_name="elections2021homepage",
name="footer_menu",
field=wagtail.core.fields.StreamField(
[
(
"item",
wagtail.core.blocks.StructBlock(
[
("name", wagtail.core.blocks.CharBlock(label="název")),
(
"page",
wagtail.core.blocks.PageChooserBlock(
label="stránka",
page_type=[
"elections2021.Elections2021ArticlesPage",
"elections2021.Elections2021CandidatesListPage",
"elections2021.Elections2021CandidatesMapPage",
"elections2021.Elections2021ProgramPage",
"elections2021.Elections2021QuestionsPage",
"elections2021.Elections2021ProgramAppPage",
"elections2021.Elections2021TextPage",
"elections2021.Elections2021StrategicListPage",
"elections2021.Elections2021StrategicPage",
"elections2021.Elections2021MythsPage",
"elections2021.Elections2021DownloadsPage",
"elections2021.Elections2021GovernmentTeamPage",
],
),
),
]
),
)
],
blank=True,
verbose_name="menu projděte si v zápatí",
),
),
]
...@@ -34,14 +34,12 @@ ...@@ -34,14 +34,12 @@
background-repeat: no-repeat; background-repeat: no-repeat;
background-position: center; background-position: center;
width: 100%; width: 100%;
content: string(chapter);
height: 5.5mm; height: 5.5mm;
text-align: left; text-align: left;
padding: 2.2mm 3mm 1.8mm; padding: 2.2mm 3mm 1.8mm;
box-sizing: border-box; box-sizing: border-box;
font-family: 'Bebas Neue', Helvetica, Arial, sans-serif; font-family: 'Roboto', Arial, sans-serif;
font-size: 9pt; font-size: 8pt;
letter-spacing: 0.2pt;
} }
@bottom-right{ @bottom-right{
width: 100%; width: 100%;
...@@ -69,7 +67,7 @@ table,tr{ ...@@ -69,7 +67,7 @@ table,tr{
} }
#chaptertitle{ #chaptertitle{
string-set: chapter content(); string-set: chapter "fujaja" content();
font-size: 16.5mm; font-size: 16.5mm;
line-height: 1.1; line-height: 1.1;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment