{% block content %}{% endblock %} @@ -64,9 +57,10 @@
- Place sticky footer content here. + Place sticky footer content here.
+ {# Global javascript #} diff --git a/blog/templates/menu.html b/blog/templates/menu.html new file mode 100644 index 0000000..c156eac --- /dev/null +++ b/blog/templates/menu.html @@ -0,0 +1,7 @@ + diff --git a/requirements.txt b/requirements.txt index 7b260ab..fa865cb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ Django>=3.1,<3.2 -wagtail>=2.10,<2.11 +wagtail>=2.10,<2.12 +wagtailmenus>=3.0,<3.1 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..417317e --- /dev/null +++ b/stranky/migrations/0001_initial.py @@ -0,0 +1,44 @@ +# Generated by Django 3.1.3 on 2020-11-06 10:18 + +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 = [ + ('wagtailcore', '0059_apply_collection_ordering'), + ('wagtailimages', '0022_uploadedimage'), + ] + + 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..c70364c --- /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'), + ] diff --git a/stranky/templates/stranky/stranka_page.html b/stranky/templates/stranky/stranka_page.html new file mode 100644 index 0000000..76747f8 --- /dev/null +++ b/stranky/templates/stranky/stranka_page.html @@ -0,0 +1,20 @@ +{% extends "base.html" %} + +{% load wagtailcore_tags wagtailimages_tags %} + +{% block body_class %}template-strankapage{% endblock %} + +{% block content %} +

{{ page.title }}

+ + {{ page.body|richtext }} + + {% for item in page.gallery_images.all %} +
+ {% image item.image fill-320x240 %} +

{{ item.caption }}

+
+ {% endfor %} +
+ +{% endblock %} \ 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/migrations/0003_blogpagegalleryimage.py b/zapisnik/migrations/0003_blogpagegalleryimage.py index 7ab47b3..5a6ffdc 100644 --- a/zapisnik/migrations/0003_blogpagegalleryimage.py +++ b/zapisnik/migrations/0003_blogpagegalleryimage.py @@ -1,4 +1,4 @@ -# Generated by Django 3.0.6 on 2020-10-23 09:07 +# Generated by Django 3.1.2 on 2020-10-23 09:03 from django.db import migrations, models import django.db.models.deletion @@ -19,8 +19,8 @@ class Migration(migrations.Migration): ('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='zapisnik.BlogPage')), + ('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='zapisnik.blogpage')), ], options={ 'ordering': ['sort_order'], diff --git a/zapisnik/models.py b/zapisnik/models.py index c859216..2a21b1c 100644 --- a/zapisnik/models.py +++ b/zapisnik/models.py @@ -1,7 +1,5 @@ from django.db import models -# New imports added for ParentalKey, Orderable, InlinePanel, ImageChooserPanel - from modelcluster.fields import ParentalKey from wagtail.core.models import Page, Orderable @@ -40,9 +38,10 @@ class BlogPage(Page): FieldPanel('date'), FieldPanel('intro'), FieldPanel('body', classname="full"), - InlinePanel('gallery_images', label="Gallery images"), + InlinePanel('gallery_images', label="Obrázky"), ] + class BlogPageGalleryImage(Orderable): page = ParentalKey(BlogPage, on_delete=models.CASCADE, related_name='gallery_images') image = models.ForeignKey( @@ -53,4 +52,4 @@ class BlogPageGalleryImage(Orderable): panels = [ ImageChooserPanel('image'), FieldPanel('caption'), - ] \ No newline at end of file + ] diff --git a/zapisnik/templates/zapisnik/blog_index_page.html b/zapisnik/templates/zapisnik/blog_index_page.html index 750ecd6..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 %} +{% 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 %} diff --git a/zapisnik/templates/zapisnik/blog_page.html b/zapisnik/templates/zapisnik/blog_page.html index 3d10bbe..33929c3 100644 --- a/zapisnik/templates/zapisnik/blog_page.html +++ b/zapisnik/templates/zapisnik/blog_page.html @@ -18,7 +18,7 @@

{{ item.caption }}

{% endfor %} - +

Return to blog

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