diff --git a/blog/settings/base.py b/blog/settings/base.py index 9e71f40..95f0f94 100644 --- a/blog/settings/base.py +++ b/blog/settings/base.py @@ -1,13 +1,13 @@ """ Django settings for blog project. -Generated by 'django-admin startproject' using Django 3.0.6. +Generated by 'django-admin startproject' using Django 3.1.2. For more information on this file, see -https://docs.djangoproject.com/en/3.0/topics/settings/ +https://docs.djangoproject.com/en/3.1/topics/settings/ For the full list of settings and their values, see -https://docs.djangoproject.com/en/3.0/ref/settings/ +https://docs.djangoproject.com/en/3.1/ref/settings/ """ # Build paths inside the project like this: os.path.join(BASE_DIR, ...) @@ -18,7 +18,7 @@ BASE_DIR = os.path.dirname(PROJECT_DIR) # Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ +# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ # Application definition @@ -48,6 +48,7 @@ INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'zapisnik', ] MIDDLEWARE = [ @@ -86,7 +87,7 @@ WSGI_APPLICATION = 'blog.wsgi.application' # Database -# https://docs.djangoproject.com/en/3.0/ref/settings/#databases +# https://docs.djangoproject.com/en/3.1/ref/settings/#databases DATABASES = { 'default': { @@ -97,30 +98,30 @@ DATABASES = { # Password validation -# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators - -AUTH_PASSWORD_VALIDATORS = [ - { - 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', - }, - { - 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', - }, - { - 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', - }, - { - 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', - }, -] +# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators + +# AUTH_PASSWORD_VALIDATORS = [ +# { +# 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', +# }, +# { +# 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', +# }, +# { +# 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', +# }, +# { +# 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', +# }, +# ] # Internationalization -# https://docs.djangoproject.com/en/3.0/topics/i18n/ +# https://docs.djangoproject.com/en/3.1/topics/i18n/ -LANGUAGE_CODE = 'en-us' +LANGUAGE_CODE = 'cs' -TIME_ZONE = 'UTC' +TIME_ZONE = 'Europe/Prague' USE_I18N = True @@ -130,7 +131,7 @@ USE_TZ = True # Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/3.0/howto/static-files/ +# https://docs.djangoproject.com/en/3.1/howto/static-files/ STATICFILES_FINDERS = [ 'django.contrib.staticfiles.finders.FileSystemFinder', @@ -143,7 +144,7 @@ STATICFILES_DIRS = [ # ManifestStaticFilesStorage is recommended in production, to prevent outdated # Javascript / CSS assets being served from cache (e.g. after a Wagtail upgrade). -# See https://docs.djangoproject.com/en/3.0/ref/contrib/staticfiles/#manifeststaticfilesstorage +# See https://docs.djangoproject.com/en/3.1/ref/contrib/staticfiles/#manifeststaticfilesstorage STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage' STATIC_ROOT = os.path.join(BASE_DIR, 'static') diff --git a/blog/settings/dev.py b/blog/settings/dev.py index 8baf3ad..6eb6cfd 100644 --- a/blog/settings/dev.py +++ b/blog/settings/dev.py @@ -4,7 +4,7 @@ from .base import * DEBUG = True # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'ur3l)t4xar!mnifbr=*g4ui4m!z=f9upzxg72xowc*#)_ksd$k' +SECRET_KEY = '2p*omsz*++h9ck1)shb9^vzi1u#lay&@j-wl^#f=%_4cf6v7ii' # SECURITY WARNING: define the correct hosts in production! ALLOWED_HOSTS = ['*'] diff --git a/blog/wsgi.py b/blog/wsgi.py index 36e14a9..f21e946 100644 --- a/blog/wsgi.py +++ b/blog/wsgi.py @@ -4,7 +4,7 @@ WSGI config for blog project. It exposes the WSGI callable as a module-level variable named ``application``. For more information on this file, see -https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/ +https://docs.djangoproject.com/en/3.1/howto/deployment/wsgi/ """ import os diff --git a/home/migrations/0003_homepage_body.py b/home/migrations/0003_homepage_body.py index 80feb15..5e10c03 100644 --- a/home/migrations/0003_homepage_body.py +++ b/home/migrations/0003_homepage_body.py @@ -1,4 +1,4 @@ -# Generated by Django 3.0.6 on 2020-10-16 09:17 +# Generated by Django 3.1.2 on 2020-10-16 09:16 from django.db import migrations import wagtail.core.fields diff --git a/home/models.py b/home/models.py index 8cbbb5e..bc7c67f 100644 --- a/home/models.py +++ b/home/models.py @@ -4,6 +4,7 @@ from wagtail.core.models import Page from wagtail.core.fields import RichTextField from wagtail.admin.edit_handlers import FieldPanel + class HomePage(Page): body = RichTextField(blank=True) diff --git a/home/templates/home/home_page.html b/home/templates/home/home_page.html index 363930f..679b29f 100644 --- a/home/templates/home/home_page.html +++ b/home/templates/home/home_page.html @@ -1,5 +1,4 @@ {% extends "base.html" %} -{% load static %} {% load wagtailcore_tags %} {% block body_class %}template-homepage{% endblock %} @@ -9,7 +8,7 @@ {% endblock extra_css %} {% block content %} - tomáš patolán + {{ page.body|richtext }} {% endblock content %} diff --git a/zapisnik/__init__.py b/zapisnik/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/zapisnik/admin.py b/zapisnik/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/zapisnik/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/zapisnik/apps.py b/zapisnik/apps.py new file mode 100644 index 0000000..63f2dbc --- /dev/null +++ b/zapisnik/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class ZapisnikConfig(AppConfig): + name = 'zapisnik' diff --git a/zapisnik/migrations/0001_initial.py b/zapisnik/migrations/0001_initial.py new file mode 100644 index 0000000..4b6c303 --- /dev/null +++ b/zapisnik/migrations/0001_initial.py @@ -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',), + ), + ] diff --git a/zapisnik/migrations/0002_blogpage.py b/zapisnik/migrations/0002_blogpage.py new file mode 100644 index 0000000..8b3559d --- /dev/null +++ b/zapisnik/migrations/0002_blogpage.py @@ -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',), + ), + ] diff --git a/zapisnik/migrations/__init__.py b/zapisnik/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/zapisnik/models.py b/zapisnik/models.py new file mode 100644 index 0000000..6d27806 --- /dev/null +++ b/zapisnik/models.py @@ -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"), + ] diff --git a/zapisnik/templates/zapisnik/blog_index_page.html b/zapisnik/templates/zapisnik/blog_index_page.html new file mode 100644 index 0000000..0f0b870 --- /dev/null +++ b/zapisnik/templates/zapisnik/blog_index_page.html @@ -0,0 +1,18 @@ +{% extends "base.html" %} + +{% load wagtailcore_tags %} + +{% block body_class %}template-blogindexpage{% endblock %} + +{% block content %} +

{{ page.title }}

+ +
{{ page.intro|richtext }}
+ + {% for post in page.get_children %} +

{{ post.title }}

+ {{ post.specific.intro }} + {# {{ post.specific.body|richtext }} #} + {% endfor %} + +{% endblock %} diff --git a/zapisnik/templates/zapisnik/blog_page.html b/zapisnik/templates/zapisnik/blog_page.html new file mode 100644 index 0000000..150118c --- /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 %} diff --git a/zapisnik/tests.py b/zapisnik/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/zapisnik/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/zapisnik/views.py b/zapisnik/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/zapisnik/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here.