12 changed files with 156 additions and 16 deletions
@ -0,0 +1,3 @@ |
|||
from django.contrib import admin |
|||
|
|||
# Register your models here. |
@ -0,0 +1,5 @@ |
|||
from django.apps import AppConfig |
|||
|
|||
|
|||
class ZapisnikConfig(AppConfig): |
|||
name = 'zapisnik' |
@ -0,0 +1,28 @@ |
|||
# Generated by Django 3.1.2 on 2020-10-21 08:42 |
|||
|
|||
from django.db import migrations, models |
|||
import django.db.models.deletion |
|||
import wagtail.core.fields |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
initial = True |
|||
|
|||
dependencies = [ |
|||
('wagtailcore', '0052_pagelogentry'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.CreateModel( |
|||
name='BlogIndexPage', |
|||
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')), |
|||
('intro', wagtail.core.fields.RichTextField(blank=True)), |
|||
], |
|||
options={ |
|||
'abstract': False, |
|||
}, |
|||
bases=('wagtailcore.page',), |
|||
), |
|||
] |
@ -0,0 +1,29 @@ |
|||
# Generated by Django 3.1.2 on 2020-10-21 09:04 |
|||
|
|||
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',), |
|||
), |
|||
] |
@ -0,0 +1,33 @@ |
|||
from django.db import models |
|||
|
|||
# Create your models here. |
|||
|
|||
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): |
|||
intro = RichTextField(blank=True) |
|||
|
|||
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"), |
|||
] |
@ -0,0 +1,18 @@ |
|||
{% extends "base.html" %} |
|||
|
|||
{% load wagtailcore_tags %} |
|||
|
|||
{% block body_class %}template-blogindexpage{% endblock %} |
|||
|
|||
{% block content %} |
|||
<h1>{{ page.title }}</h1> |
|||
|
|||
<div class="intro">{{ page.intro|richtext }}</div> |
|||
|
|||
{% for post in page.get_children %} |
|||
<h2><a href="{% pageurl post %}">{{ post.title }}</a></h2> |
|||
{{ post.specific.intro }} |
|||
{# {{ post.specific.body|richtext }} #} |
|||
{% endfor %} |
|||
|
|||
{% endblock %} |
@ -0,0 +1,17 @@ |
|||
{% extends "base.html" %} |
|||
|
|||
{% load wagtailcore_tags %} |
|||
|
|||
{% block body_class %}template-blogpage{% endblock %} |
|||
|
|||
{% block content %} |
|||
<h1>{{ page.title }}</h1> |
|||
<p class="meta">{{ page.date }}</p> |
|||
|
|||
<div class="intro">{{ page.intro }}</div> |
|||
|
|||
{{ page.body|richtext }} |
|||
|
|||
<p><a href="{{ page.get_parent.url }}">Return to blog</a></p> |
|||
|
|||
{% endblock %} |
@ -0,0 +1,3 @@ |
|||
from django.test import TestCase |
|||
|
|||
# Create your tests here. |
@ -0,0 +1,3 @@ |
|||
from django.shortcuts import render |
|||
|
|||
# Create your views here. |
Loading…
Reference in new issue