diff --git a/majak/settings/base.py b/majak/settings/base.py index 8118ac1c941cb9e6a6bda90eab891f8a50e6c7dd..00ec6c44837fa0e64990ea93a2b17c11f7c7940b 100644 --- a/majak/settings/base.py +++ b/majak/settings/base.py @@ -51,6 +51,7 @@ INSTALLED_APPS = [ "search", "regulace_konopi", "green_deal", + "widget_tweaks", "wagtail.contrib.forms", "wagtail.contrib.redirects", "wagtail.contrib.modeladmin", diff --git a/uniweb/migrations/0015_uniwebformfield_uniwebformpage.py b/uniweb/migrations/0015_uniwebformfield_uniwebformpage.py new file mode 100644 index 0000000000000000000000000000000000000000..cd6ba39d96a837180396159d03d67f1a4bca0214 --- /dev/null +++ b/uniweb/migrations/0015_uniwebformfield_uniwebformpage.py @@ -0,0 +1,1019 @@ +# Generated by Django 3.1.7 on 2021-03-26 14:27 + +import django.db.models.deletion +import modelcluster.fields +import wagtail.contrib.table_block.blocks +import wagtail.core.blocks +import wagtail.core.fields +import wagtail.images.blocks +import wagtailmetadata.models +from django.db import migrations, models + +import shared.models + + +class Migration(migrations.Migration): + + dependencies = [ + ("wagtailcore", "0060_fix_workflow_unique_constraint"), + ("wagtailimages", "0023_add_choose_permissions"), + ("uniweb", "0014_auto_20210217_1316"), + ] + + operations = [ + migrations.CreateModel( + name="UniwebFormPage", + fields=[ + ( + "page_ptr", + models.OneToOneField( + auto_created=True, + on_delete=django.db.models.deletion.CASCADE, + parent_link=True, + primary_key=True, + serialize=False, + to="wagtailcore.page", + ), + ), + ( + "content_before", + wagtail.core.fields.StreamField( + [ + ( + "title", + wagtail.core.blocks.CharBlock( + group="nadpisy", + icon="title", + label="nadpis", + template="uniweb/blocks/title.html", + ), + ), + ( + "advanced_title", + wagtail.core.blocks.StructBlock( + [ + ( + "align", + wagtail.core.blocks.ChoiceBlock( + choices=[ + ("left", "vlevo"), + ("center", "uprostřed"), + ("right", "vpravo"), + ], + label="zarovnání", + ), + ), + ( + "color", + wagtail.core.blocks.ChoiceBlock( + choices=[ + ("black_on_white", "černá na bílé"), + ("white_on_black", "bílá na černé"), + ("white_on_blue", "bílá na modré"), + ( + "white_on_cyan", + "bílá na tyrkysové", + ), + ( + "white_on_violet", + "bílá na fialové", + ), + ], + label="barva", + ), + ), + ( + "title", + wagtail.core.blocks.CharBlock( + label="nadpis" + ), + ), + ] + ), + ), + ( + "picture_title", + wagtail.core.blocks.StructBlock( + [ + ( + "color", + wagtail.core.blocks.ChoiceBlock( + choices=[ + ("black_on_white", "černá na bílé"), + ("white_on_black", "bílá na černé"), + ("white_on_blue", "bílá na modré"), + ( + "white_on_cyan", + "bílá na tyrkysové", + ), + ( + "white_on_violet", + "bílá na fialové", + ), + ], + label="barva", + ), + ), + ( + "title", + wagtail.core.blocks.CharBlock( + label="nadpis" + ), + ), + ( + "picture", + wagtail.images.blocks.ImageChooserBlock( + help_text="rozměr na výšku 75px nebo více (obrázek bude zmenšen na výšku 75px)", + label="obrázek", + ), + ), + ] + ), + ), + ( + "text", + wagtail.core.blocks.RichTextBlock( + features=[ + "h2", + "h3", + "h4", + "h5", + "bold", + "italic", + "ol", + "ul", + "hr", + "link", + "document-link", + "image", + "superscript", + "subscript", + "strikethrough", + "blockquote", + ], + group="texty", + label="text", + template="uniweb/blocks/text.html", + ), + ), + ( + "advanced_text", + wagtail.core.blocks.StructBlock( + [ + ( + "align", + wagtail.core.blocks.ChoiceBlock( + choices=[ + ("left", "vlevo"), + ("center", "uprostřed"), + ("right", "vpravo"), + ], + label="zarovnání", + ), + ), + ( + "color", + wagtail.core.blocks.ChoiceBlock( + choices=[ + ("black_on_white", "černá na bílé"), + ("white_on_black", "bílá na černé"), + ("white_on_blue", "bílá na modré"), + ( + "white_on_cyan", + "bílá na tyrkysové", + ), + ( + "white_on_violet", + "bílá na fialové", + ), + ], + label="barva", + ), + ), + ( + "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", + ), + ), + ] + ), + ), + ( + "advanced_text_columns", + wagtail.core.blocks.StructBlock( + [ + ( + "align", + wagtail.core.blocks.ChoiceBlock( + choices=[ + ("left", "vlevo"), + ("center", "uprostřed"), + ("right", "vpravo"), + ], + label="zarovnání", + ), + ), + ( + "color", + wagtail.core.blocks.ChoiceBlock( + choices=[ + ("black_on_white", "černá na bílé"), + ("white_on_black", "bílá na černé"), + ("white_on_blue", "bílá na modré"), + ( + "white_on_cyan", + "bílá na tyrkysové", + ), + ( + "white_on_violet", + "bílá na fialové", + ), + ], + label="barva", + ), + ), + ( + "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" + ), + group="ostatní", + icon="image", + label="galerie", + template="uniweb/blocks/gallery.html", + ), + ), + ( + "picture_list", + wagtail.core.blocks.StructBlock( + [ + ( + "color", + wagtail.core.blocks.ChoiceBlock( + choices=[ + ("black_on_white", "černá na bílé"), + ("white_on_black", "bílá na černé"), + ("white_on_blue", "bílá na modré"), + ( + "white_on_cyan", + "bílá na tyrkysové", + ), + ( + "white_on_violet", + "bílá na fialové", + ), + ], + label="barva", + ), + ), + ( + "items", + wagtail.core.blocks.ListBlock( + wagtail.core.blocks.RichTextBlock( + features=[ + "h2", + "h3", + "h4", + "h5", + "bold", + "italic", + "ol", + "ul", + "hr", + "link", + "document-link", + "image", + "superscript", + "subscript", + "strikethrough", + "blockquote", + ], + label="odstavec", + ), + label="odstavce", + ), + ), + ( + "picture", + wagtail.images.blocks.ImageChooserBlock( + help_text="rozměr 25x25px nebo více (obrázek bude zmenšen na 25x25px)", + label="obrázek", + ), + ), + ] + ), + ), + ( + "table", + wagtail.contrib.table_block.blocks.TableBlock( + group="ostatní", + label="tabulka", + template="uniweb/blocks/table.html", + ), + ), + ( + "articles", + wagtail.core.blocks.StructBlock( + [ + ( + "page", + wagtail.core.blocks.PageChooserBlock( + label="sekce článků", + page_type=[ + "uniweb.UniwebArticlesIndexPage" + ], + ), + ), + ( + "lines", + wagtail.core.blocks.IntegerBlock( + default=1, + help_text="zobrazí se tři články na řádek", + label="počet řádků", + ), + ), + ] + ), + ), + ], + blank=True, + verbose_name="obsah stránky před formulářem", + ), + ), + ( + "content_after", + wagtail.core.fields.StreamField( + [ + ( + "title", + wagtail.core.blocks.CharBlock( + group="nadpisy", + icon="title", + label="nadpis", + template="uniweb/blocks/title.html", + ), + ), + ( + "advanced_title", + wagtail.core.blocks.StructBlock( + [ + ( + "align", + wagtail.core.blocks.ChoiceBlock( + choices=[ + ("left", "vlevo"), + ("center", "uprostřed"), + ("right", "vpravo"), + ], + label="zarovnání", + ), + ), + ( + "color", + wagtail.core.blocks.ChoiceBlock( + choices=[ + ("black_on_white", "černá na bílé"), + ("white_on_black", "bílá na černé"), + ("white_on_blue", "bílá na modré"), + ( + "white_on_cyan", + "bílá na tyrkysové", + ), + ( + "white_on_violet", + "bílá na fialové", + ), + ], + label="barva", + ), + ), + ( + "title", + wagtail.core.blocks.CharBlock( + label="nadpis" + ), + ), + ] + ), + ), + ( + "picture_title", + wagtail.core.blocks.StructBlock( + [ + ( + "color", + wagtail.core.blocks.ChoiceBlock( + choices=[ + ("black_on_white", "černá na bílé"), + ("white_on_black", "bílá na černé"), + ("white_on_blue", "bílá na modré"), + ( + "white_on_cyan", + "bílá na tyrkysové", + ), + ( + "white_on_violet", + "bílá na fialové", + ), + ], + label="barva", + ), + ), + ( + "title", + wagtail.core.blocks.CharBlock( + label="nadpis" + ), + ), + ( + "picture", + wagtail.images.blocks.ImageChooserBlock( + help_text="rozměr na výšku 75px nebo více (obrázek bude zmenšen na výšku 75px)", + label="obrázek", + ), + ), + ] + ), + ), + ( + "text", + wagtail.core.blocks.RichTextBlock( + features=[ + "h2", + "h3", + "h4", + "h5", + "bold", + "italic", + "ol", + "ul", + "hr", + "link", + "document-link", + "image", + "superscript", + "subscript", + "strikethrough", + "blockquote", + ], + group="texty", + label="text", + template="uniweb/blocks/text.html", + ), + ), + ( + "advanced_text", + wagtail.core.blocks.StructBlock( + [ + ( + "align", + wagtail.core.blocks.ChoiceBlock( + choices=[ + ("left", "vlevo"), + ("center", "uprostřed"), + ("right", "vpravo"), + ], + label="zarovnání", + ), + ), + ( + "color", + wagtail.core.blocks.ChoiceBlock( + choices=[ + ("black_on_white", "černá na bílé"), + ("white_on_black", "bílá na černé"), + ("white_on_blue", "bílá na modré"), + ( + "white_on_cyan", + "bílá na tyrkysové", + ), + ( + "white_on_violet", + "bílá na fialové", + ), + ], + label="barva", + ), + ), + ( + "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", + ), + ), + ] + ), + ), + ( + "advanced_text_columns", + wagtail.core.blocks.StructBlock( + [ + ( + "align", + wagtail.core.blocks.ChoiceBlock( + choices=[ + ("left", "vlevo"), + ("center", "uprostřed"), + ("right", "vpravo"), + ], + label="zarovnání", + ), + ), + ( + "color", + wagtail.core.blocks.ChoiceBlock( + choices=[ + ("black_on_white", "černá na bílé"), + ("white_on_black", "bílá na černé"), + ("white_on_blue", "bílá na modré"), + ( + "white_on_cyan", + "bílá na tyrkysové", + ), + ( + "white_on_violet", + "bílá na fialové", + ), + ], + label="barva", + ), + ), + ( + "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" + ), + group="ostatní", + icon="image", + label="galerie", + template="uniweb/blocks/gallery.html", + ), + ), + ( + "picture_list", + wagtail.core.blocks.StructBlock( + [ + ( + "color", + wagtail.core.blocks.ChoiceBlock( + choices=[ + ("black_on_white", "černá na bílé"), + ("white_on_black", "bílá na černé"), + ("white_on_blue", "bílá na modré"), + ( + "white_on_cyan", + "bílá na tyrkysové", + ), + ( + "white_on_violet", + "bílá na fialové", + ), + ], + label="barva", + ), + ), + ( + "items", + wagtail.core.blocks.ListBlock( + wagtail.core.blocks.RichTextBlock( + features=[ + "h2", + "h3", + "h4", + "h5", + "bold", + "italic", + "ol", + "ul", + "hr", + "link", + "document-link", + "image", + "superscript", + "subscript", + "strikethrough", + "blockquote", + ], + label="odstavec", + ), + label="odstavce", + ), + ), + ( + "picture", + wagtail.images.blocks.ImageChooserBlock( + help_text="rozměr 25x25px nebo více (obrázek bude zmenšen na 25x25px)", + label="obrázek", + ), + ), + ] + ), + ), + ( + "table", + wagtail.contrib.table_block.blocks.TableBlock( + group="ostatní", + label="tabulka", + template="uniweb/blocks/table.html", + ), + ), + ( + "articles", + wagtail.core.blocks.StructBlock( + [ + ( + "page", + wagtail.core.blocks.PageChooserBlock( + label="sekce článků", + page_type=[ + "uniweb.UniwebArticlesIndexPage" + ], + ), + ), + ( + "lines", + wagtail.core.blocks.IntegerBlock( + default=1, + help_text="zobrazí se tři články na řádek", + label="počet řádků", + ), + ), + ] + ), + ), + ], + blank=True, + verbose_name="obsah stránky za formulářem", + ), + ), + ( + "search_image", + models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.SET_NULL, + related_name="+", + to="wagtailimages.image", + verbose_name="Search image", + ), + ), + ], + options={ + "verbose_name": "Formulářová stránka", + }, + bases=( + "wagtailcore.page", + shared.models.SubpageMixin, + wagtailmetadata.models.WagtailImageMetadataMixin, + models.Model, + ), + ), + migrations.CreateModel( + name="UniwebFormField", + fields=[ + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ( + "sort_order", + models.IntegerField(blank=True, editable=False, null=True), + ), + ( + "clean_name", + models.CharField( + blank=True, + default="", + help_text="Safe name of the form field, the label converted to ascii_snake_case", + max_length=255, + verbose_name="name", + ), + ), + ( + "label", + models.CharField( + help_text="The label of the form field", + max_length=255, + verbose_name="label", + ), + ), + ( + "field_type", + models.CharField( + choices=[ + ("singleline", "Single line text"), + ("multiline", "Multi-line text"), + ("email", "Email"), + ("number", "Number"), + ("url", "URL"), + ("checkbox", "Checkbox"), + ("checkboxes", "Checkboxes"), + ("dropdown", "Drop down"), + ("multiselect", "Multiple select"), + ("radio", "Radio buttons"), + ("date", "Date"), + ("datetime", "Date/time"), + ("hidden", "Hidden field"), + ], + max_length=16, + verbose_name="field type", + ), + ), + ( + "required", + models.BooleanField(default=True, verbose_name="required"), + ), + ( + "choices", + models.TextField( + blank=True, + help_text="Comma separated list of choices. Only applicable in checkboxes, radio and dropdown.", + verbose_name="choices", + ), + ), + ( + "default_value", + models.CharField( + blank=True, + help_text="Default value. Comma separated values supported for checkboxes.", + max_length=255, + verbose_name="default value", + ), + ), + ( + "help_text", + models.CharField( + blank=True, max_length=255, verbose_name="help text" + ), + ), + ( + "page", + modelcluster.fields.ParentalKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="form_fields", + to="uniweb.uniwebformpage", + ), + ), + ], + options={ + "ordering": ["sort_order"], + "abstract": False, + }, + ), + ] diff --git a/uniweb/migrations/0016_auto_20210326_1801.py b/uniweb/migrations/0016_auto_20210326_1801.py new file mode 100644 index 0000000000000000000000000000000000000000..1929e2167c8e0a405f7a6efeb8134be180886b31 --- /dev/null +++ b/uniweb/migrations/0016_auto_20210326_1801.py @@ -0,0 +1,441 @@ +# Generated by Django 3.1.7 on 2021-03-26 17:01 + +import wagtail.contrib.table_block.blocks +import wagtail.core.blocks +import wagtail.core.fields +import wagtail.images.blocks +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("uniweb", "0015_uniwebformfield_uniwebformpage"), + ] + + operations = [ + migrations.AddField( + model_name="uniwebformpage", + name="content_landing", + field=wagtail.core.fields.StreamField( + [ + ( + "title", + wagtail.core.blocks.CharBlock( + group="nadpisy", + icon="title", + label="nadpis", + template="uniweb/blocks/title.html", + ), + ), + ( + "advanced_title", + wagtail.core.blocks.StructBlock( + [ + ( + "align", + wagtail.core.blocks.ChoiceBlock( + choices=[ + ("left", "vlevo"), + ("center", "uprostřed"), + ("right", "vpravo"), + ], + label="zarovnání", + ), + ), + ( + "color", + wagtail.core.blocks.ChoiceBlock( + choices=[ + ("black_on_white", "černá na bílé"), + ("white_on_black", "bílá na černé"), + ("white_on_blue", "bílá na modré"), + ("white_on_cyan", "bílá na tyrkysové"), + ("white_on_violet", "bílá na fialové"), + ], + label="barva", + ), + ), + ( + "title", + wagtail.core.blocks.CharBlock(label="nadpis"), + ), + ] + ), + ), + ( + "picture_title", + wagtail.core.blocks.StructBlock( + [ + ( + "color", + wagtail.core.blocks.ChoiceBlock( + choices=[ + ("black_on_white", "černá na bílé"), + ("white_on_black", "bílá na černé"), + ("white_on_blue", "bílá na modré"), + ("white_on_cyan", "bílá na tyrkysové"), + ("white_on_violet", "bílá na fialové"), + ], + label="barva", + ), + ), + ( + "title", + wagtail.core.blocks.CharBlock(label="nadpis"), + ), + ( + "picture", + wagtail.images.blocks.ImageChooserBlock( + help_text="rozměr na výšku 75px nebo více (obrázek bude zmenšen na výšku 75px)", + label="obrázek", + ), + ), + ] + ), + ), + ( + "text", + wagtail.core.blocks.RichTextBlock( + features=[ + "h2", + "h3", + "h4", + "h5", + "bold", + "italic", + "ol", + "ul", + "hr", + "link", + "document-link", + "image", + "superscript", + "subscript", + "strikethrough", + "blockquote", + ], + group="texty", + label="text", + template="uniweb/blocks/text.html", + ), + ), + ( + "advanced_text", + wagtail.core.blocks.StructBlock( + [ + ( + "align", + wagtail.core.blocks.ChoiceBlock( + choices=[ + ("left", "vlevo"), + ("center", "uprostřed"), + ("right", "vpravo"), + ], + label="zarovnání", + ), + ), + ( + "color", + wagtail.core.blocks.ChoiceBlock( + choices=[ + ("black_on_white", "černá na bílé"), + ("white_on_black", "bílá na černé"), + ("white_on_blue", "bílá na modré"), + ("white_on_cyan", "bílá na tyrkysové"), + ("white_on_violet", "bílá na fialové"), + ], + label="barva", + ), + ), + ( + "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", + ), + ), + ] + ), + ), + ( + "advanced_text_columns", + wagtail.core.blocks.StructBlock( + [ + ( + "align", + wagtail.core.blocks.ChoiceBlock( + choices=[ + ("left", "vlevo"), + ("center", "uprostřed"), + ("right", "vpravo"), + ], + label="zarovnání", + ), + ), + ( + "color", + wagtail.core.blocks.ChoiceBlock( + choices=[ + ("black_on_white", "černá na bílé"), + ("white_on_black", "bílá na černé"), + ("white_on_blue", "bílá na modré"), + ("white_on_cyan", "bílá na tyrkysové"), + ("white_on_violet", "bílá na fialové"), + ], + label="barva", + ), + ), + ( + "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"), + group="ostatní", + icon="image", + label="galerie", + template="uniweb/blocks/gallery.html", + ), + ), + ( + "picture_list", + wagtail.core.blocks.StructBlock( + [ + ( + "color", + wagtail.core.blocks.ChoiceBlock( + choices=[ + ("black_on_white", "černá na bílé"), + ("white_on_black", "bílá na černé"), + ("white_on_blue", "bílá na modré"), + ("white_on_cyan", "bílá na tyrkysové"), + ("white_on_violet", "bílá na fialové"), + ], + label="barva", + ), + ), + ( + "items", + wagtail.core.blocks.ListBlock( + wagtail.core.blocks.RichTextBlock( + features=[ + "h2", + "h3", + "h4", + "h5", + "bold", + "italic", + "ol", + "ul", + "hr", + "link", + "document-link", + "image", + "superscript", + "subscript", + "strikethrough", + "blockquote", + ], + label="odstavec", + ), + label="odstavce", + ), + ), + ( + "picture", + wagtail.images.blocks.ImageChooserBlock( + help_text="rozměr 25x25px nebo více (obrázek bude zmenšen na 25x25px)", + label="obrázek", + ), + ), + ] + ), + ), + ( + "table", + wagtail.contrib.table_block.blocks.TableBlock( + group="ostatní", + label="tabulka", + template="uniweb/blocks/table.html", + ), + ), + ( + "articles", + wagtail.core.blocks.StructBlock( + [ + ( + "page", + wagtail.core.blocks.PageChooserBlock( + label="sekce článků", + page_type=["uniweb.UniwebArticlesIndexPage"], + ), + ), + ( + "lines", + wagtail.core.blocks.IntegerBlock( + default=1, + help_text="zobrazí se tři články na řádek", + label="počet řádků", + ), + ), + ] + ), + ), + ], + blank=True, + verbose_name="obsah stránky po vyplnění formuláře", + ), + ), + migrations.AlterField( + model_name="uniwebhomepage", + 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=[ + "uniweb.UniwebHomePage", + "uniweb.UniwebFlexiblePage", + "uniweb.UniwebArticlesIndexPage", + "uniweb.UniwebFormPage", + ], + ), + ), + ] + ), + ) + ], + blank=True, + verbose_name="horní menu", + ), + ), + ] diff --git a/uniweb/migrations/0017_auto_20210329_0120.py b/uniweb/migrations/0017_auto_20210329_0120.py new file mode 100644 index 0000000000000000000000000000000000000000..0150f48d006d0fe08be18577326f8453203d1eda --- /dev/null +++ b/uniweb/migrations/0017_auto_20210329_0120.py @@ -0,0 +1,411 @@ +# Generated by Django 3.1.7 on 2021-03-28 23:20 + +import wagtail.contrib.table_block.blocks +import wagtail.core.blocks +import wagtail.core.fields +import wagtail.images.blocks +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("uniweb", "0016_auto_20210326_1801"), + ] + + operations = [ + migrations.AlterField( + model_name="uniwebformpage", + name="content_landing", + field=wagtail.core.fields.StreamField( + [ + ( + "title", + wagtail.core.blocks.CharBlock( + group="nadpisy", + icon="title", + label="nadpis", + template="uniweb/blocks/title.html", + ), + ), + ( + "advanced_title", + wagtail.core.blocks.StructBlock( + [ + ( + "align", + wagtail.core.blocks.ChoiceBlock( + choices=[ + ("left", "vlevo"), + ("center", "uprostřed"), + ("right", "vpravo"), + ], + label="zarovnání", + ), + ), + ( + "color", + wagtail.core.blocks.ChoiceBlock( + choices=[ + ("black_on_white", "černá na bílé"), + ("white_on_black", "bílá na černé"), + ("white_on_blue", "bílá na modré"), + ("white_on_cyan", "bílá na tyrkysové"), + ("white_on_violet", "bílá na fialové"), + ], + label="barva", + ), + ), + ( + "title", + wagtail.core.blocks.CharBlock(label="nadpis"), + ), + ] + ), + ), + ( + "picture_title", + wagtail.core.blocks.StructBlock( + [ + ( + "color", + wagtail.core.blocks.ChoiceBlock( + choices=[ + ("black_on_white", "černá na bílé"), + ("white_on_black", "bílá na černé"), + ("white_on_blue", "bílá na modré"), + ("white_on_cyan", "bílá na tyrkysové"), + ("white_on_violet", "bílá na fialové"), + ], + label="barva", + ), + ), + ( + "title", + wagtail.core.blocks.CharBlock(label="nadpis"), + ), + ( + "picture", + wagtail.images.blocks.ImageChooserBlock( + help_text="rozměr na výšku 75px nebo více (obrázek bude zmenšen na výšku 75px)", + label="obrázek", + ), + ), + ] + ), + ), + ( + "text", + wagtail.core.blocks.RichTextBlock( + features=[ + "h2", + "h3", + "h4", + "h5", + "bold", + "italic", + "ol", + "ul", + "hr", + "link", + "document-link", + "image", + "superscript", + "subscript", + "strikethrough", + "blockquote", + ], + group="texty", + label="text", + template="uniweb/blocks/text.html", + ), + ), + ( + "advanced_text", + wagtail.core.blocks.StructBlock( + [ + ( + "align", + wagtail.core.blocks.ChoiceBlock( + choices=[ + ("left", "vlevo"), + ("center", "uprostřed"), + ("right", "vpravo"), + ], + label="zarovnání", + ), + ), + ( + "color", + wagtail.core.blocks.ChoiceBlock( + choices=[ + ("black_on_white", "černá na bílé"), + ("white_on_black", "bílá na černé"), + ("white_on_blue", "bílá na modré"), + ("white_on_cyan", "bílá na tyrkysové"), + ("white_on_violet", "bílá na fialové"), + ], + label="barva", + ), + ), + ( + "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", + ), + ), + ] + ), + ), + ( + "advanced_text_columns", + wagtail.core.blocks.StructBlock( + [ + ( + "align", + wagtail.core.blocks.ChoiceBlock( + choices=[ + ("left", "vlevo"), + ("center", "uprostřed"), + ("right", "vpravo"), + ], + label="zarovnání", + ), + ), + ( + "color", + wagtail.core.blocks.ChoiceBlock( + choices=[ + ("black_on_white", "černá na bílé"), + ("white_on_black", "bílá na černé"), + ("white_on_blue", "bílá na modré"), + ("white_on_cyan", "bílá na tyrkysové"), + ("white_on_violet", "bílá na fialové"), + ], + label="barva", + ), + ), + ( + "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"), + group="ostatní", + icon="image", + label="galerie", + template="uniweb/blocks/gallery.html", + ), + ), + ( + "picture_list", + wagtail.core.blocks.StructBlock( + [ + ( + "color", + wagtail.core.blocks.ChoiceBlock( + choices=[ + ("black_on_white", "černá na bílé"), + ("white_on_black", "bílá na černé"), + ("white_on_blue", "bílá na modré"), + ("white_on_cyan", "bílá na tyrkysové"), + ("white_on_violet", "bílá na fialové"), + ], + label="barva", + ), + ), + ( + "items", + wagtail.core.blocks.ListBlock( + wagtail.core.blocks.RichTextBlock( + features=[ + "h2", + "h3", + "h4", + "h5", + "bold", + "italic", + "ol", + "ul", + "hr", + "link", + "document-link", + "image", + "superscript", + "subscript", + "strikethrough", + "blockquote", + ], + label="odstavec", + ), + label="odstavce", + ), + ), + ( + "picture", + wagtail.images.blocks.ImageChooserBlock( + help_text="rozměr 25x25px nebo více (obrázek bude zmenšen na 25x25px)", + label="obrázek", + ), + ), + ] + ), + ), + ( + "table", + wagtail.contrib.table_block.blocks.TableBlock( + group="ostatní", + label="tabulka", + template="uniweb/blocks/table.html", + ), + ), + ( + "articles", + wagtail.core.blocks.StructBlock( + [ + ( + "page", + wagtail.core.blocks.PageChooserBlock( + label="sekce článků", + page_type=["uniweb.UniwebArticlesIndexPage"], + ), + ), + ( + "lines", + wagtail.core.blocks.IntegerBlock( + default=1, + help_text="zobrazí se tři články na řádek", + label="počet řádků", + ), + ), + ] + ), + ), + ], + blank=True, + verbose_name="obsah stránky zobrazené po odeslání formuláře", + ), + ), + ] diff --git a/uniweb/models.py b/uniweb/models.py index 51f582d1710f03ace1f2f65c7c4465d771c7dbb0..b13707051020bb097241b06fa2f63fd1e6a29480 100644 --- a/uniweb/models.py +++ b/uniweb/models.py @@ -8,12 +8,15 @@ from taggit.models import TaggedItemBase from wagtail.admin.edit_handlers import ( FieldPanel, HelpPanel, + InlinePanel, MultiFieldPanel, ObjectList, PublishingPanel, StreamFieldPanel, TabbedInterface, ) +from wagtail.contrib.forms.edit_handlers import FormSubmissionsPanel +from wagtail.contrib.forms.models import AbstractForm, AbstractFormField from wagtail.contrib.table_block.blocks import TableBlock from wagtail.core import blocks from wagtail.core.fields import StreamField @@ -185,6 +188,7 @@ class MenuItemBlock(blocks.StructBlock): "uniweb.UniwebHomePage", "uniweb.UniwebFlexiblePage", "uniweb.UniwebArticlesIndexPage", + "uniweb.UniwebFormPage", ], ) @@ -192,68 +196,64 @@ class MenuItemBlock(blocks.StructBlock): label = "stránka" -class UniwebContentMixin(models.Model): - content = StreamField( - [ - ( - "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", - ), - ), - ("articles", ArticlesBlock()), - ], - verbose_name="obsah stránky", - blank=True, - ) - - class Meta: - abstract = True +CONTENT_STREAM_BLOCKS = [ + ( + "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", + ), + ), + ("articles", ArticlesBlock()), +] class UniwebArticleTag(TaggedItemBase): content_object = ParentalKey("uniweb.UniwebArticlePage", on_delete=models.CASCADE) -class UniwebHomePage(Page, UniwebContentMixin, MetadataPageMixin): +class UniwebHomePage(Page, MetadataPageMixin): ### FIELDS + content = StreamField( + CONTENT_STREAM_BLOCKS, verbose_name="obsah stránky", blank=True + ) + # settings matomo_id = models.IntegerField( "Matomo ID pro sledování návštěvnosti", blank=True, null=True @@ -315,6 +315,7 @@ class UniwebHomePage(Page, UniwebContentMixin, MetadataPageMixin): subpage_types = [ "uniweb.UniwebFlexiblePage", "uniweb.UniwebArticlesIndexPage", + "uniweb.UniwebFormPage", ] ### OTHERS @@ -327,9 +328,13 @@ class UniwebHomePage(Page, UniwebContentMixin, MetadataPageMixin): return self -class UniwebFlexiblePage(Page, UniwebContentMixin, SubpageMixin, MetadataPageMixin): +class UniwebFlexiblePage(Page, SubpageMixin, MetadataPageMixin): ### FIELDS + content = StreamField( + CONTENT_STREAM_BLOCKS, verbose_name="obsah stránky", blank=True + ) + ### PANELS promote_panels = [ @@ -353,8 +358,12 @@ class UniwebFlexiblePage(Page, UniwebContentMixin, SubpageMixin, MetadataPageMix ### RELATIONS - parent_page_types = ["uniweb.UniwebHomePage", "uniweb.UniwebFlexiblePage"] - subpage_types = ["uniweb.UniwebFlexiblePage"] + parent_page_types = [ + "uniweb.UniwebHomePage", + "uniweb.UniwebFlexiblePage", + "uniweb.UniwebFormPage", + ] + subpage_types = ["uniweb.UniwebFlexiblePage", "uniweb.UniwebFormPage"] ### OTHERS @@ -454,3 +463,74 @@ class UniwebArticlePage(Page, ArticleMixin, SubpageMixin, MetadataPageMixin): .order_by("-uniwebarticlepage__date")[:3] ) return context + + +class UniwebFormField(AbstractFormField): + page = ParentalKey( + "UniwebFormPage", on_delete=models.CASCADE, related_name="form_fields" + ) + + +class UniwebFormPage(AbstractForm, SubpageMixin, MetadataPageMixin): + ### FIELDS + + content_before = StreamField( + CONTENT_STREAM_BLOCKS, verbose_name="obsah stránky před formulářem", blank=True + ) + content_after = StreamField( + CONTENT_STREAM_BLOCKS, verbose_name="obsah stránky za formulářem", blank=True + ) + content_landing = StreamField( + CONTENT_STREAM_BLOCKS, + verbose_name="obsah stránky zobrazené po odeslání formuláře", + blank=True, + ) + + ### PANELS + + content_panels = AbstractForm.content_panels + [ + FormSubmissionsPanel(), + StreamFieldPanel("content_before"), + InlinePanel("form_fields", label="formulář"), + StreamFieldPanel("content_after"), + StreamFieldPanel("content_landing"), + ] + + 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"), + ), + ] + + submissions_panels = [ + FormSubmissionsPanel(), + ] + + edit_handler = TabbedInterface( + [ + ObjectList(content_panels, heading=gettext_lazy("Content")), + ObjectList(promote_panels, heading=gettext_lazy("Promote")), + ObjectList(submissions_panels, heading="Data z formuláře"), + ] + ) + + ### RELATIONS + + parent_page_types = [ + "uniweb.UniwebHomePage", + "uniweb.UniwebFlexiblePage", + "uniweb.UniwebFormPage", + ] + subpage_types = ["uniweb.UniwebFlexiblePage", "uniweb.UniwebFormPage"] + + ### OTHERS + + class Meta: + verbose_name = "Formulářová stránka" diff --git a/uniweb/templates/uniweb/snippet_sections.html b/uniweb/templates/uniweb/snippet_sections.html index f05dfd24820440949fb56f24a3d1fad2d72f968d..f2ee0e512551a8563ea0db304b847576c553340a 100644 --- a/uniweb/templates/uniweb/snippet_sections.html +++ b/uniweb/templates/uniweb/snippet_sections.html @@ -1,4 +1,4 @@ -{% load wagtailcore_tags wagtailimages_tags %} +{% load wagtailcore_tags %} {% for block in page.content %} diff --git a/uniweb/templates/uniweb/uniweb_form_page.html b/uniweb/templates/uniweb/uniweb_form_page.html new file mode 100644 index 0000000000000000000000000000000000000000..a1b8c0947f9d0920f1ef7108c325f6eb26505cd4 --- /dev/null +++ b/uniweb/templates/uniweb/uniweb_form_page.html @@ -0,0 +1,91 @@ +{% extends "uniweb/base.html" %} +{% load wagtailcore_tags widget_tweaks %} + +{% block content %} +<main> + + {% for block in page.content_before %} + {% include_block block with first=forloop.first %} + {% endfor %} + + <div class="content-block px-4 py-2 clearfix"> + <form action="{% pageurl page %}" method="post"> + {% csrf_token %} + + {% for hidden_field in form.hidden_fields %} + {{ hidden_field.errors }} + {{ hidden_field }} + {% endfor %} + + <div class="grid grid-cols-2 gap-4 row-gap-6 max-w-xl"> + {% for field in form.visible_fields %} + <div class="form-field col-span-2 {% if field.field.required %}form-field--required{% endif %}"> + + {% if field.widget_type == "select" %} + <label class="form-field__label" for="{{ field.id_for_label }}">{{ field.label }}</label> + <div class="form-field__wrapper form-field__wrapper--shadowed"> + <div class="select"> + {{ field|add_class:"select__control form-field__control" }} + </div> + </div> + {% elif field.widget_type == "radioselect" %} + <label class="form-field__label" for="{{ field.id_for_label }}">{{ field.label }}</label> + <div class="form-field__wrapper py-1 flex flex-col"> + {% for radio in field %} + <div class="my-1"> + <div class="radio form-field__control"> + {{ radio }} + </div> + </div> + {% endfor %} + </div> + {% elif field.widget_type == "checkboxselectmultiple" %} + <label class="form-field__label mt-2" for="{{ field.id_for_label }}">{{ field.label }}</label> + <div class="form-field__wrapper py-1 flex flex-col"> + {% for checkbox in field %} + <div class="my-1"> + <div class="checkbox form-field__control"> + {{ checkbox.tag }} + <label for="{{ checkbox.id_for_label }}">{{ checkbox.choice_label }}</label> + </div> + </div> + {% endfor %} + </div> + {% elif field.widget_type == "checkbox" %} + <div class="form-field__wrapper mt-2"> + <div class="checkbox form-field__control"> + {{ field }} + <label class="form-field__label" for="{{ field.id_for_label }}">{{ field.label }}</label> + </div> + </div> + {% else %} + <label class="form-field__label" for="{{ field.id_for_label }}">{{ field.label }} ({{ field.widget_type }})</label> + <div class="form-field__wrapper form-field__wrapper--shadowed"> + {{ field|add_class:"text-input form-field__control" }} + </div> + {% endif %} + + {% if field.help_text %} + <div class="form-field__help-text">{{ field.help_text }}</div> + {% endif %} + + {% if field.errors %} + <div class="form-field__error">{{ field.errors }}</div> + {% endif %} + + </div> + {% endfor %} + </div> + + <button class="btn text-lg mt-6 mb-4 btn--black-100"> + <div class="btn__body ">odeslat</div> + </button> + </form> + </div> + + {% for block in page.content_after %} + {% include_block block %} + {% endfor %} + +</main> +{% endblock %} diff --git a/uniweb/templates/uniweb/uniweb_form_page_landing.html b/uniweb/templates/uniweb/uniweb_form_page_landing.html new file mode 100644 index 0000000000000000000000000000000000000000..2f20c8fdc793fc95d06346e1dbe2583641f0eb73 --- /dev/null +++ b/uniweb/templates/uniweb/uniweb_form_page_landing.html @@ -0,0 +1,12 @@ +{% extends "uniweb/base.html" %} +{% load wagtailcore_tags %} + +{% block content %} +<main> + + {% for block in page.content_landing %} + {% include_block block with first=forloop.first %} + {% endfor %} + +</main> +{% endblock %}