diff --git a/main/blocks.py b/main/blocks.py index 9a3beaa18e5262d6bf724ba5fb7bd16d75a39e2c..3df435b742965cb2e4a1053a073378a08ab21496 100644 --- a/main/blocks.py +++ b/main/blocks.py @@ -7,6 +7,7 @@ from wagtail.core.blocks import ( URLBlock, ) from wagtail.images.blocks import ImageChooserBlock +from wagtail.documents.blocks import DocumentChooserBlock class CTAMixin: @@ -36,7 +37,8 @@ class HomePageCarouselBlock(StructBlock): class PeopleGroupBlock(StructBlock): title = CharBlock(label="Titulek") - person_list = ListBlock(PageChooserBlock(page_type="main.MainPersonPage", label="Detail osoby"), label="Seznam osob") + person_list = ListBlock(PageChooserBlock(page_type="main.MainPersonPage", label="Detail osoby"), + label="Seznam osob") class ProgramBlock(StructBlock): @@ -92,4 +94,31 @@ class SocialLinkBlock(LinkBlock): icon = CharBlock(label="Ikona") # TODO CSS class name or somthing better? +# ARTICLE BLOCKS +class ArticleQuoteBlock(StructBlock): + quote = CharBlock(label="Citace") + autor_name = CharBlock(label="Jméno autora") + + class Meta: + icon = "user" + label = "Blok citace" + + +class ArticleImageBlock(StructBlock): + image = ImageChooserBlock(label="Obrázek") + href = URLBlock(label="Odkaz k textu") + text = CharBlock(label="Text") + + class Meta: + icon = "user" + label = "Obrázek s textem a odkazem" + + +class ArticleDownloadBlock(StructBlock): + file = DocumentChooserBlock(label="Stáhnutelný soubor") + + class Meta: + icon = "user" + label = "Blok stáhnutelného dokumentu" + # TwitterCarouselBlock diff --git a/main/migrations/0010_alter_mainarticlepage_content.py b/main/migrations/0010_alter_mainarticlepage_content.py new file mode 100644 index 0000000000000000000000000000000000000000..0e3b901e6eb153a2ab6b21211c9ba9243f9b04d2 --- /dev/null +++ b/main/migrations/0010_alter_mainarticlepage_content.py @@ -0,0 +1,22 @@ +# Generated by Django 4.0.7 on 2022-08-23 20:29 + +from django.db import migrations +import wagtail.blocks +import wagtail.documents.blocks +import wagtail.fields +import wagtail.images.blocks + + +class Migration(migrations.Migration): + + dependencies = [ + ('main', '0009_rename_footer_social_links_mainhomepage_social_links'), + ] + + operations = [ + migrations.AlterField( + model_name='mainarticlepage', + name='content', + field=wagtail.fields.StreamField([('text', wagtail.blocks.RichTextBlock()), ('quote', wagtail.blocks.StructBlock([('quote', wagtail.blocks.CharBlock(label='Citace')), ('autor_name', wagtail.blocks.CharBlock(label='Jméno autora'))])), ('download', wagtail.blocks.StructBlock([('file', wagtail.documents.blocks.DocumentChooserBlock(label='Stáhnutelný soubor'))])), ('image', wagtail.blocks.StructBlock([('image', wagtail.images.blocks.ImageChooserBlock(label='Obrázek')), ('href', wagtail.blocks.URLBlock(label='Odkaz k textu')), ('text', wagtail.blocks.CharBlock(label='Text'))]))], blank=True, use_json_field=None, verbose_name='Článek'), + ), + ] diff --git a/main/models.py b/main/models.py index 3f57c94e8f3cbe66863389ba795699fe3c8bcc5f..e7f4af26afe0c90d18f04b5146b85cbd1e3e218b 100644 --- a/main/models.py +++ b/main/models.py @@ -12,7 +12,7 @@ from modelcluster.fields import ParentalKey from taggit.models import TaggedItemBase from wagtail.admin.edit_handlers import FieldPanel, ObjectList, TabbedInterface from wagtail.contrib.routable_page.models import RoutablePageMixin, route -from wagtail.core.blocks import CharBlock, PageChooserBlock +from wagtail.core.blocks import CharBlock, PageChooserBlock, RichTextBlock from wagtail.core.fields import RichTextField, StreamField from wagtail.core.models import Page from wagtailmetadata.models import MetadataPageMixin @@ -252,6 +252,17 @@ class MainArticlePage( ### FIELDS + content = StreamField( + [ + ('text', RichTextBlock(template="")), + ('quote', blocks.ArticleQuoteBlock()), + ('download', blocks.ArticleDownloadBlock()), + ('image', blocks.ArticleImageBlock()) + ], + verbose_name="Článek", + blank=True, + ) + author_page = models.ForeignKey( "main.MainPersonPage", on_delete=models.SET_NULL, @@ -274,6 +285,7 @@ class MainArticlePage( FieldPanel("author_page"), FieldPanel("region"), FieldPanel("tags"), + FieldPanel("content"), ] promote_panels = make_promote_panels( diff --git a/main/templates/main/main_article_page.html b/main/templates/main/main_article_page.html index 31a0f12f4893045101cac20bc2a617885335b15f..33f47140a50927d04d605f12328c4cb552117403 100644 --- a/main/templates/main/main_article_page.html +++ b/main/templates/main/main_article_page.html @@ -2,49 +2,94 @@ {% load static wagtailcore_tags wagtailimages_tags wagtailroutablepage_tags %} {% block content %} - {% routablepageurl page.root_page.articles_page "tags" as articles_tag_page_url %} - - <article> - <link itemprop="mainEntityOfPage" href="{{ page.url }}"> - <meta itemprop="datePublished" content="{{ page.last_published_at }}"> - <meta itemprop="dateModified" content="{{ page.latest_revision_created_at }}"> - - <header> - <h1 class=""> - {{ page.title }} - </h1> - </header> - - <div> - <div> - {{ page.author_page.title }} - {{ page.author_page.socials }} - </div> - <div itemprop="description" class=""> - <p> - {{ page.perex }} - </p> + {# {% routablepageurl page.root_page.articles_page "tags" as articles_tag_page_url %}#} + <main role="main" class="mb-10 xl:mb-32"> + <div class="grid-container mb-2 lg:mb-12"> + <div class="grid-left-side h-full bg-grey-150 left-tab"> + <div class="p-6"> + <span class="font-bold 3xl:text-xl">AUTOR ČLÁNKU: <br> {{ page.autor }}</span><br> + </div> + </div> + <div class="grid-content leading-6"> + <h2 class="head-xl"> + {{ page.perex }} + </h2> + </div> + <div class="hidden grid-right-side h-full bg-grey-150 right-tab xl:block"></div> + </div> {% for block in page.content %} - {% include_block block %} + {% if block.block_type == 'quote' %} + <div class="grid-container px-4 mb-4 bg-grey-150 pt-10 lg:mb-20"> + <div class="grid-left-side flex justify-start xl:justify-end"> + <i class="ico--code text-7xl mr-12"></i> + </div> + <div class="flex flex-col grid-content"> + <span class="head-4xl">{{ block.value.quote }}</span> + <span class="font-alt text-turquoise-500 mb-6">– {{ block.value.autor_name }}</span> + </div> + </div> + {% endif %} + {% if block.block_type == 'text' %} + <div class="grid-container mb-2 lg:mb-12"> + <div class="grid-content"> + <p class="3xl:text-lg"> + {{ block.text|richtext }} + </p> + </div> + </div> + + {% endif %} + {% if block.block_type == 'download' %} + <div class="grid-container px-4 mb-4 bg-grey-150 xl:mb-20"> + <div class="flex justify-start xl:justify-end grid-left-side"> + <i class="ico--download text-6xl mr-12 pt-5 pb-5"></i> + </div> + <div class="grid-content flex items-center flex-wrap gap-3"> + <div class="flex items-center bg-white p-3 h-11 mr-3"> + <span class="font-bold mr-1">Stáhnout soubor: </span> + <span>{{ block.value.file }}</span> + </div> + <a href="" class="btn btn__slide__wrap h-11 p-0"> + <span class="btn text-sm bg-black text-white w-32 lg:text-base">Stáhnout</span> + <span class="btn text-sm bg-white text-black w-32 lg:text-base">Stáhnout</span> + </a> + </div> + </div> + {% endif %} + {% if block.block_type == 'image' %} + <div class="grid-container px-3 pt-3 mb-4 bg-grey-150 xl:pt-0 xl:mb-20"> + <div class="grid-content-with-right-side flex flex-wrap gap-3 xl:gap-5"> + <img src="{{ block.value.image }}" + alt="" class="w-full max-w-sm"> + <div class="flex flex-col justify-between"> + <a href="" class="mt-0 xl:mt-8 mb-2 font-bold hover:no-underline leading-5"> + {{ block.value.text }} + </a> + <span class="text-sm text-grey-200 uppercase mb-0 xl:mb-6">zdroj: {{ block.value.href }}</span> + </div> + </div> + </div> + {% endif %} {% endfor %} - </div> - </div> - </article> + </main> - {# {% if related_articles|length %}#} - {# <section class="mt-16 md:mt-24">#} - {# <h1 class="head-alt-base md:head-alt-md pb-4">#} - {# Další podobné články#} - {# </h1>#} - {##} - {# <div class="article-card-list grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4 lg:gap-8">#} - {# {% for article in related_articles %}#} - {# {% include "shared/article_preview.html" %}#} - {# {% endfor %}#} - {# </div>#} - {##} - {# {% include "shared/more_articles_snippet.html" %}#} - {# </section>#} - {# {% endif %}#} + {# {% if related_articles|length %}#} + {# <section class="mt-16 md:mt-24">#} + {# <h1 class="head-alt-base md:head-alt-md pb-4">#} + {# Další podobné články#} + {# </h1>#} + {##} + {# <div class="article-card-list grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4 lg:gap-8">#} + {# {% for article in related_articles %}#} + {# {% include "shared/article_preview.html" %}#} + {# {% endfor %}#} + {# </div>#} + {##} + {# {% include "shared/more_articles_snippet.html" %}#} + {# </section>#} + {# {% endif %}#} {% endblock %} + + +