diff --git a/zapisnik/migrations/0002_blogpage.py b/zapisnik/migrations/0002_blogpage.py new file mode 100644 index 0000000..5240d1e --- /dev/null +++ b/zapisnik/migrations/0002_blogpage.py @@ -0,0 +1,29 @@ +# Generated by Django 3.1.2 on 2020-10-21 09:11 + +from django.db import migrations, models +import django.db.models.deletion +import wagtail.core.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('wagtailcore', '0052_pagelogentry'), + ('zapisnik', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='BlogPage', + 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')), + ('date', models.DateField(verbose_name='Post date')), + ('intro', models.CharField(max_length=250)), + ('body', wagtail.core.fields.RichTextField(blank=True)), + ], + options={ + 'abstract': False, + }, + bases=('wagtailcore.page',), + ), + ] diff --git a/zapisnik/models.py b/zapisnik/models.py index 85c22ab..333eec6 100644 --- a/zapisnik/models.py +++ b/zapisnik/models.py @@ -5,6 +5,7 @@ from django.db import models from wagtail.core.models import Page from wagtail.core.fields import RichTextField from wagtail.admin.edit_handlers import FieldPanel +from wagtail.search import index class BlogIndexPage(Page): @@ -13,3 +14,19 @@ class BlogIndexPage(Page): content_panels = Page.content_panels + [ FieldPanel('intro', classname="full") ] + +class BlogPage(Page): + date = models.DateField("Post date") + intro = models.CharField(max_length=250) + body = RichTextField(blank=True) + + search_fields = Page.search_fields + [ + index.SearchField('intro'), + index.SearchField('body'), + ] + + content_panels = Page.content_panels + [ + FieldPanel('date'), + FieldPanel('intro'), + FieldPanel('body', classname="full"), + ] diff --git a/zapisnik/templates/zapisnik/blog_index_page.html b/zapisnik/templates/zapisnik/blog_index_page.html index bb6b843..18a3a65 100644 --- a/zapisnik/templates/zapisnik/blog_index_page.html +++ b/zapisnik/templates/zapisnik/blog_index_page.html @@ -12,7 +12,7 @@ {% for post in page.get_children %}

{{ post.title }}

{{ post.specific.intro }} - {{ post.specific.body|richtext }} + {# {{ post.specific.body|richtext }} #} {% endfor %} {% endblock %} \ No newline at end of file diff --git a/zapisnik/templates/zapisnik/blog_page.html b/zapisnik/templates/zapisnik/blog_page.html new file mode 100644 index 0000000..bf7da56 --- /dev/null +++ b/zapisnik/templates/zapisnik/blog_page.html @@ -0,0 +1,17 @@ +{% extends "base.html" %} + +{% load wagtailcore_tags %} + +{% block body_class %}template-blogpage{% endblock %} + +{% block content %} +

{{ page.title }}

+

{{ page.date }}

+ +
{{ page.intro }}
+ + {{ page.body|richtext }} + +

Return to blog

+ +{% endblock %} \ No newline at end of file