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
Commits on Source (7)
Showing
with 2023 additions and 59 deletions
...@@ -44,6 +44,7 @@ INSTALLED_APPS = [ ...@@ -44,6 +44,7 @@ INSTALLED_APPS = [
"calendar_utils", "calendar_utils",
"users", "users",
"pirates", "pirates",
"pdp",
"tuning", "tuning",
"search", "search",
"regulace_konopi", "regulace_konopi",
......
File moved
from django.apps import AppConfig
class PdpConfig(AppConfig):
name = "pdp"
This diff is collapsed.
This diff is collapsed.
# Generated by Django 3.1.2 on 2020-11-27 10:34
import wagtail.core.blocks
import wagtail.core.fields
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("pdp", "0002_pdpsubpage"),
]
operations = [
migrations.AlterField(
model_name="pdphomepage",
name="top_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=["pdp.PdpHomePage", "pdp.PdpSubPage"],
),
),
]
),
)
],
blank=True,
verbose_name="horní menu",
),
),
]
from django.db import models
from django.utils.translation import gettext_lazy
from wagtail.admin.edit_handlers import (
FieldPanel,
HelpPanel,
MultiFieldPanel,
StreamFieldPanel,
)
from wagtail.core import blocks
from wagtail.core.fields import StreamField
from wagtail.core.models import Page
from wagtail.documents.blocks import DocumentChooserBlock
from wagtail.images.edit_handlers import ImageChooserPanel
from wagtailmetadata.models import MetadataPageMixin
from shared.mixins import MatomoMixin, SharedSubpageMixin
from tuning import help
from uniweb import models as uniweb
class PdpContentMixin(models.Model):
content = StreamField(
uniweb.UNIWEB_STREAM_CHOICES
+ [
(
"jupyter",
DocumentChooserBlock(label="Jupyter notebook", group="ostatní"),
),
],
verbose_name="obsah stránky",
blank=True,
)
class Meta:
abstract = True
class MenuItemBlock(blocks.StructBlock):
name = blocks.CharBlock(label="název")
page = blocks.PageChooserBlock(
label="stránka",
page_type=["pdp.PdpHomePage", "pdp.PdpSubPage"],
)
class Meta:
label = "stránka"
class PdpHomePage(
Page,
PdpContentMixin,
MetadataPageMixin,
MatomoMixin,
):
top_menu = StreamField(
[("item", MenuItemBlock())],
verbose_name="horní menu",
blank=True,
)
content_panels = Page.content_panels + [
StreamFieldPanel("content"),
]
promote_panels = [
MultiFieldPanel(
[
FieldPanel("seo_title"),
FieldPanel("search_description"),
ImageChooserPanel("search_image"),
HelpPanel(help.build(help.IMPORTANT_TITLE)),
],
gettext_lazy("Common page configuration"),
),
]
settings_panels = [
MultiFieldPanel(
[
# definovano v MatomoMixin, TODO obstrahovat rozsireni settings_panels do mixinu
FieldPanel("matomo_id"),
],
"nastavení webu",
),
StreamFieldPanel("top_menu"), # z uniwebTopmenuMixin
]
subpage_types = [
"pdp.PdpSubPage",
]
### OTHERS
class Meta:
verbose_name = "Pirátská datová platforma"
@property
def root_page(self):
return self
class PdpSubPage(Page, PdpContentMixin, SharedSubpageMixin, MetadataPageMixin):
### FIELDS
### PANELS
promote_panels = [
MultiFieldPanel(
[
FieldPanel("slug"),
FieldPanel("seo_title"),
FieldPanel("search_description"),
ImageChooserPanel("search_image"),
HelpPanel(help.build(help.NO_SEO_TITLE, help.NO_SEARCH_IMAGE)),
],
gettext_lazy("Common page configuration"),
),
]
content_panels = Page.content_panels + [
StreamFieldPanel("content"),
]
settings_panels = []
### RELATIONS
parent_page_types = ["pdp.PdpHomePage"]
subpage_types = []
### OTHERS
class Meta:
verbose_name = "Pirátská datová platforma - podstránka"
{% extends "uniweb/base.html" %}
{% load wagtailcore_tags %}
{% block content %}
<main>
{% include "uniweb/snippet_sections.html" %}
</main>
{% endblock %}
{% extends "uniweb/base.html" %}
{% block content %}
<main>
{% include "uniweb/snippet_sections.html" %}
</main>
{% endblock %}
...@@ -28,10 +28,13 @@ def jupyterize(value): ...@@ -28,10 +28,13 @@ def jupyterize(value):
c.TemplateExporter.exclude_output_prompt = ( c.TemplateExporter.exclude_output_prompt = (
True # potlaci prazdne vystupy typu "Out[8]" True # potlaci prazdne vystupy typu "Out[8]"
) )
c.TemplateExporter.exclude_input_prompt = (
True # potlaci prazdne vystupy typu "In[]"
)
c.preprocessors = ["TagRemovePreprocessor"] c.preprocessors = ["TagRemovePreprocessor"]
nb_body, _ = nbconvert.TemplateExporter( nb_body, _ = nbconvert.TemplateExporter(
config=c, template_file="uniweb/templates/jupyter/my.tpl" config=c, template_file="pdp/templates/jupyter/my.tpl"
).from_filename(filename) ).from_filename(filename)
# HACK: fucking ugly. Ale netusim kde se to tam bere, asi nekde v hloubi notebookovskych templates # HACK: fucking ugly. Ale netusim kde se to tam bere, asi nekde v hloubi notebookovskych templates
......
{% load uniweb_filters wagtailcore_tags wagtailimages_tags %} {% load pdp_filters wagtailcore_tags wagtailimages_tags %}
<section class="mb-8 lg:mb-16"> <section class="mb-8 lg:mb-16">
{% for block in page.content %} {% for block in page.content %}
......
from django.db import models
class MatomoMixin(models.Model):
matomo_id = models.IntegerField(
"Matomo ID pro sledování návštěvnosti", blank=True, null=True
)
class Meta:
abstract = True
class SharedSubpageMixin:
"""Must be used in class definition before MetadataPageMixin!"""
@property
def root_page(self):
if not hasattr(self, "_root_page"):
# Vypada to hackove ale lze takto pouzit: dle dokumentace get_ancestors vraci stranky v poradi
# od rootu, tedy domovska stranka je druha v poradi
self._root_page = self.get_ancestors().specific()[1]
return self._root_page
This diff is collapsed.
...@@ -11,11 +11,11 @@ from wagtail.contrib.table_block.blocks import TableBlock ...@@ -11,11 +11,11 @@ from wagtail.contrib.table_block.blocks import TableBlock
from wagtail.core import blocks from wagtail.core import blocks
from wagtail.core.fields import StreamField from wagtail.core.fields import StreamField
from wagtail.core.models import Page from wagtail.core.models import Page
from wagtail.documents.blocks import DocumentChooserBlock
from wagtail.images.blocks import ImageChooserBlock from wagtail.images.blocks import ImageChooserBlock
from wagtail.images.edit_handlers import ImageChooserPanel from wagtail.images.edit_handlers import ImageChooserPanel
from wagtailmetadata.models import MetadataPageMixin from wagtailmetadata.models import MetadataPageMixin
from shared.mixins import MatomoMixin
from tuning import help from tuning import help
from .constants import ( from .constants import (
...@@ -163,56 +163,55 @@ class SubpageMixin: ...@@ -163,56 +163,55 @@ class SubpageMixin:
return self.search_image or self.root_page.get_meta_image() return self.search_image or self.root_page.get_meta_image()
UNIWEB_STREAM_CHOICES = [
(
"title",
blocks.CharBlock(
label="nadpis",
icon="title",
group="nadpisy",
template="uniweb/blocks/title.html",
),
),
("advanced_title", AdvancedTitleBlock()),
("picture_title", PictureTitleBlock()),
(
"text",
blocks.RichTextBlock(
label="text",
features=RICH_TEXT_FEATURES,
group="texty",
template="uniweb/blocks/text.html",
),
),
("advanced_text", AdvancedTextBlock()),
("text_columns", ColumnsTextBlock()),
("advanced_text_columns", AdvancedColumnsTextBlock()),
(
"gallery",
blocks.ListBlock(
ImageChooserBlock(label="obrázek"),
label="galerie",
icon="image",
group="ostatní",
template="uniweb/blocks/gallery.html",
),
),
("picture_list", PictureListBlock()),
(
"table",
TableBlock(
label="tabulka",
group="ostatní",
template="uniweb/blocks/table.html",
),
),
]
class UniwebContentMixin(models.Model): class UniwebContentMixin(models.Model):
content = StreamField( content = StreamField(
[ UNIWEB_STREAM_CHOICES,
(
"title",
blocks.CharBlock(
label="nadpis",
icon="title",
group="nadpisy",
template="uniweb/blocks/title.html",
),
),
("advanced_title", AdvancedTitleBlock()),
("picture_title", PictureTitleBlock()),
(
"text",
blocks.RichTextBlock(
label="text",
features=RICH_TEXT_FEATURES,
group="texty",
template="uniweb/blocks/text.html",
),
),
("advanced_text", AdvancedTextBlock()),
("text_columns", ColumnsTextBlock()),
("advanced_text_columns", AdvancedColumnsTextBlock()),
(
"gallery",
blocks.ListBlock(
ImageChooserBlock(label="obrázek"),
label="galerie",
icon="image",
group="ostatní",
template="uniweb/blocks/gallery.html",
),
),
("picture_list", PictureListBlock()),
(
"table",
TableBlock(
label="tabulka",
group="ostatní",
template="uniweb/blocks/table.html",
),
),
(
"jupyter",
DocumentChooserBlock(label="Jupyter notebook", group="ostatní"),
),
],
verbose_name="obsah stránky", verbose_name="obsah stránky",
blank=True, blank=True,
) )
...@@ -221,18 +220,15 @@ class UniwebContentMixin(models.Model): ...@@ -221,18 +220,15 @@ class UniwebContentMixin(models.Model):
abstract = True abstract = True
class UniwebHomePage(Page, UniwebContentMixin, MetadataPageMixin): class UniwebHomePage(Page, UniwebContentMixin, MetadataPageMixin, MatomoMixin):
### FIELDS ### FIELDS
# settings
matomo_id = models.IntegerField(
"Matomo ID pro sledování návštěvnosti", blank=True, null=True
)
top_menu = StreamField( top_menu = StreamField(
[("item", MenuItemBlock())], [("item", MenuItemBlock())],
verbose_name="horní menu", verbose_name="horní menu",
blank=True, blank=True,
) )
# settings
narrow_layout = models.BooleanField( narrow_layout = models.BooleanField(
"zúžený obsah stránky", "zúžený obsah stránky",
default=False, default=False,
...@@ -260,12 +256,12 @@ class UniwebHomePage(Page, UniwebContentMixin, MetadataPageMixin): ...@@ -260,12 +256,12 @@ class UniwebHomePage(Page, UniwebContentMixin, MetadataPageMixin):
settings_panels = [ settings_panels = [
MultiFieldPanel( MultiFieldPanel(
[ [
FieldPanel("matomo_id"), FieldPanel("matomo_id"), # z MatomoMixin
FieldPanel("narrow_layout"), FieldPanel("narrow_layout"),
], ],
"nastavení webu", "nastavení webu",
), ),
StreamFieldPanel("top_menu"), StreamFieldPanel("top_menu"), # z UniwebTopmenuMixin
] ]
### RELATIONS ### RELATIONS
......