diff --git a/blog/settings/base.py b/blog/settings/base.py index 95f0f94..d8d9965 100644 --- a/blog/settings/base.py +++ b/blog/settings/base.py @@ -49,6 +49,8 @@ INSTALLED_APPS = [ 'django.contrib.messages', 'django.contrib.staticfiles', 'zapisnik', + 'stranky', + ] MIDDLEWARE = [ diff --git a/blog/static/img/blank-image.jpg b/blog/static/img/blank-image.jpg new file mode 100644 index 0000000..2aebdcf Binary files /dev/null and b/blog/static/img/blank-image.jpg differ diff --git a/blog/templates/base.html b/blog/templates/base.html index d53d141..0852996 100644 --- a/blog/templates/base.html +++ b/blog/templates/base.html @@ -31,27 +31,23 @@
diff --git a/stranky/__init__.py b/stranky/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/stranky/admin.py b/stranky/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/stranky/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/stranky/apps.py b/stranky/apps.py new file mode 100644 index 0000000..0220a40 --- /dev/null +++ b/stranky/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class StrankyConfig(AppConfig): + name = 'stranky' diff --git a/stranky/migrations/0001_initial.py b/stranky/migrations/0001_initial.py new file mode 100644 index 0000000..cc11431 --- /dev/null +++ b/stranky/migrations/0001_initial.py @@ -0,0 +1,44 @@ +# Generated by Django 3.1.3 on 2020-11-06 10:19 + +from django.db import migrations, models +import django.db.models.deletion +import modelcluster.fields +import wagtail.core.fields + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('wagtailimages', '0022_uploadedimage'), + ('wagtailcore', '0059_apply_collection_ordering'), + ] + + operations = [ + migrations.CreateModel( + name='StrankaPage', + 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')), + ('body', wagtail.core.fields.RichTextField(blank=True)), + ], + options={ + 'abstract': False, + }, + bases=('wagtailcore.page',), + ), + migrations.CreateModel( + name='StrankaPageGalleryImage', + 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)), + ('caption', models.CharField(blank=True, max_length=250)), + ('image', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='+', to='wagtailimages.image')), + ('page', modelcluster.fields.ParentalKey(on_delete=django.db.models.deletion.CASCADE, related_name='gallery_images', to='stranky.strankapage')), + ], + options={ + 'ordering': ['sort_order'], + 'abstract': False, + }, + ), + ] diff --git a/stranky/migrations/__init__.py b/stranky/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/stranky/models.py b/stranky/models.py new file mode 100644 index 0000000..2b275cc --- /dev/null +++ b/stranky/models.py @@ -0,0 +1,35 @@ +from django.db import models + +from modelcluster.fields import ParentalKey + +from wagtail.core.models import Page, Orderable +from wagtail.core.fields import RichTextField +from wagtail.admin.edit_handlers import FieldPanel, InlinePanel +from wagtail.images.edit_handlers import ImageChooserPanel +from wagtail.search import index + +class StrankaPage(Page): + body = RichTextField(blank=True) + + search_fields = Page.search_fields + [ + index.SearchField('body'), + ] + + content_panels = Page.content_panels + [ + FieldPanel('body', classname="full"), + InlinePanel('gallery_images', label="Obrázky"), + ] + + + +class StrankaPageGalleryImage(Orderable): + page = ParentalKey(StrankaPage, on_delete=models.CASCADE, related_name='gallery_images') + image = models.ForeignKey( + 'wagtailimages.Image', on_delete=models.CASCADE, related_name='+' + ) + caption = models.CharField(blank=True, max_length=250) + + panels = [ + ImageChooserPanel('image'), + FieldPanel('caption'), + ] \ No newline at end of file diff --git a/stranky/tests.py b/stranky/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/stranky/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/stranky/views.py b/stranky/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/stranky/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/zapisnik/templates/zapisnik/blog_index_page.html b/zapisnik/templates/zapisnik/blog_index_page.html index ce9aedd..03dd296 100644 --- a/zapisnik/templates/zapisnik/blog_index_page.html +++ b/zapisnik/templates/zapisnik/blog_index_page.html @@ -1,6 +1,6 @@ {% extends "base.html" %} -{% load wagtailcore_tags wagtailimages_tags %} +{% load wagtailcore_tags wagtailimages_tags static %} {% block body_class %}template-blogindexpage{% endblock %} @@ -11,14 +11,26 @@ {% for post in page.get_children %} {% with post=post.specific %} -

{{ post.title }}

- - {% with post.main_image as main_image %} - {% if main_image %}{% image main_image fill-160x100 %}{% endif %} - {% endwith %} - -

{{ post.intro }}

- {# {{ post.body|richtext }} #} +
+
+
+ {% with post.main_image as main_image %} + {% if main_image %} + {% image main_image class="card-img" fill-400x150 %} + {% else %} + blank image + {% endif %} + {% endwith %} +
+
+
+
{{ post.title }}
+

{{ post.intro }}

+

{{ post.date }}

+
+
+
+
{% endwith %} {% endfor %}