diff --git a/uniweb/migrations/0007_auto_20200915_0812.py b/uniweb/migrations/0007_auto_20200915_0812.py new file mode 100644 index 0000000000000000000000000000000000000000..0eb3436d64b624a63db5fe482235c6d2ebda342b --- /dev/null +++ b/uniweb/migrations/0007_auto_20200915_0812.py @@ -0,0 +1,131 @@ +# Generated by Django 3.1.1 on 2020-09-15 06:12 + +import wagtail.contrib.table_block.blocks +import wagtail.core.blocks +import wagtail.core.fields +import wagtail.documents.blocks +import wagtail.images.blocks +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("uniweb", "0006_auto_20200911_1426"), + ] + + operations = [ + migrations.AlterField( + model_name="uniwebflexiblepage", + name="content", + field=wagtail.core.fields.StreamField( + [ + ( + "title", + wagtail.core.blocks.CharBlock(icon="title", label="nadpis"), + ), + ( + "text", + wagtail.core.blocks.RichTextBlock( + features=[ + "h2", + "h3", + "h4", + "h5", + "bold", + "italic", + "ol", + "ul", + "hr", + "link", + "document-link", + "image", + "superscript", + "subscript", + "strikethrough", + "blockquote", + ], + label="text", + ), + ), + ( + "text_columns", + wagtail.core.blocks.StructBlock( + [ + ( + "left_text", + wagtail.core.blocks.RichTextBlock( + features=[ + "h2", + "h3", + "h4", + "h5", + "bold", + "italic", + "ol", + "ul", + "hr", + "link", + "document-link", + "image", + "superscript", + "subscript", + "strikethrough", + "blockquote", + ], + label="levý sloupec", + ), + ), + ( + "right_text", + wagtail.core.blocks.RichTextBlock( + features=[ + "h2", + "h3", + "h4", + "h5", + "bold", + "italic", + "ol", + "ul", + "hr", + "link", + "document-link", + "image", + "superscript", + "subscript", + "strikethrough", + "blockquote", + ], + label="pravý sloupec", + ), + ), + ] + ), + ), + ( + "gallery", + wagtail.core.blocks.ListBlock( + wagtail.images.blocks.ImageChooserBlock(label="obrázek"), + icon="image", + label="galerie", + ), + ), + ( + "table", + wagtail.contrib.table_block.blocks.TableBlock( + label="tabulka", template="uniweb/snippet_table.html" + ), + ), + ( + "jupyter", + wagtail.documents.blocks.DocumentChooserBlock( + label="Jupyter notebook" + ), + ), + ], + blank=True, + verbose_name="obsah stránky", + ), + ), + ] diff --git a/uniweb/models.py b/uniweb/models.py index 6c6539e42c550423e72032188c87ecf8d4c219de..720f3bf4ab0b774800682945d277dc0ca9da9af7 100644 --- a/uniweb/models.py +++ b/uniweb/models.py @@ -10,6 +10,7 @@ from wagtail.contrib.table_block.blocks import TableBlock 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.blocks import ImageChooserBlock from wagtail.images.edit_handlers import ImageChooserPanel from wagtailmetadata.models import MetadataPageMixin @@ -158,6 +159,7 @@ class UniwebFlexiblePage(Page, SubpageMixin, MetadataPageMixin): "table", TableBlock(label="tabulka", template="uniweb/snippet_table.html",), ), + ("jupyter", DocumentChooserBlock(label="Jupyter notebook")), ], verbose_name="obsah stránky", blank=True, diff --git a/uniweb/templates/uniweb/base.html b/uniweb/templates/uniweb/base.html index e7960a3d35ccfbdc4274049566e9c4b827a27e27..a9a7ed11ec664fa04992b3df7b3fa2ff1cde54d9 100644 --- a/uniweb/templates/uniweb/base.html +++ b/uniweb/templates/uniweb/base.html @@ -1,4 +1,4 @@ -{% load static wagtailcore_tags wagtailimages_tags wagtailmetadata_tags %} +{% load uniweb_filters static wagtailcore_tags wagtailimages_tags wagtailmetadata_tags %} <!doctype html> <html lang="cs"> <head> diff --git a/uniweb/templates/uniweb/snippet_sections.html b/uniweb/templates/uniweb/snippet_sections.html index fc8db88896967539cfe16b5083a63a45849625e0..3f535a06b4f6dae1aac45375f89cb8a860a85bd1 100644 --- a/uniweb/templates/uniweb/snippet_sections.html +++ b/uniweb/templates/uniweb/snippet_sections.html @@ -42,5 +42,11 @@ </div> {% endif %} + {% if block.block_type == "jupyter" %} + <div class="content-block my-4 clearfix{% if forloop.first %} mt-8 lg:mt-12{% endif %}"> + {{ block.value|jupyterize }} + </div> + {% endif %} + {% endfor %} </section> diff --git a/uniweb/templatetags/__init__.py b/uniweb/templatetags/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/uniweb/templatetags/uniweb_filters.py b/uniweb/templatetags/uniweb_filters.py new file mode 100644 index 0000000000000000000000000000000000000000..63241b3e68644da490b0e09ff3fea0889fb057b6 --- /dev/null +++ b/uniweb/templatetags/uniweb_filters.py @@ -0,0 +1,10 @@ +# definice vlastnich tagu pro templates + +from django import template + +register = template.Library() + + +@register.filter() +def jupyterize(value): + return value.value + " HIHI"