diff --git a/knihovna/.dockerignore b/knihovna/.dockerignore new file mode 100644 index 0000000..63ce98d --- /dev/null +++ b/knihovna/.dockerignore @@ -0,0 +1,39 @@ +# Django project +/media/ +/static/ +*.sqlite3 + +# Python and others +__pycache__ +*.pyc +.DS_Store +*.swp +/venv/ +/tmp/ +/.vagrant/ +/Vagrantfile.local +node_modules/ +/npm-debug.log +/.idea/ +.vscode +coverage +.python-version + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg diff --git a/knihovna/Dockerfile b/knihovna/Dockerfile new file mode 100644 index 0000000..786f49a --- /dev/null +++ b/knihovna/Dockerfile @@ -0,0 +1,60 @@ +# Use an official Python runtime based on Debian 10 "buster" as a parent image. +FROM python:3.8.1-slim-buster + +# Add user that will be used in the container. +RUN useradd wagtail + +# Port used by this container to serve HTTP. +EXPOSE 8000 + +# Set environment variables. +# 1. Force Python stdout and stderr streams to be unbuffered. +# 2. Set PORT variable that is used by Gunicorn. This should match "EXPOSE" +# command. +ENV PYTHONUNBUFFERED=1 \ + PORT=8000 + +# Install system packages required by Wagtail and Django. +RUN apt-get update --yes --quiet && apt-get install --yes --quiet --no-install-recommends \ + build-essential \ + libpq-dev \ + libmariadbclient-dev \ + libjpeg62-turbo-dev \ + zlib1g-dev \ + libwebp-dev \ + && rm -rf /var/lib/apt/lists/* + +# Install the application server. +RUN pip install "gunicorn==20.0.4" + +# Install the project requirements. +COPY requirements.txt / +RUN pip install -r /requirements.txt + +# Use /app folder as a directory where the source code is stored. +WORKDIR /app + +# Set this directory to be owned by the "wagtail" user. This Wagtail project +# uses SQLite, the folder needs to be owned by the user that +# will be writing to the database file. +RUN chown wagtail:wagtail /app + +# Copy the source code of the project into the container. +COPY --chown=wagtail:wagtail . . + +# Use user "wagtail" to run the build commands below and the server itself. +USER wagtail + +# Collect static files. +RUN python manage.py collectstatic --noinput --clear + +# Runtime command that executes when "docker run" is called, it does the +# following: +# 1. Migrate the database. +# 2. Start the application server. +# WARNING: +# Migrating database at the same time as starting the server IS NOT THE BEST +# PRACTICE. The database should be migrated manually or using the release +# phase facilities of your hosting platform. This is used only so the +# Wagtail instance can be started with a simple "docker run" command. +CMD set -xe; python manage.py migrate --noinput; gunicorn knihovna.wsgi:application diff --git a/knihovna/dashboard/__init__.py b/knihovna/dashboard/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/knihovna/dashboard/__pycache__/__init__.cpython-37.pyc b/knihovna/dashboard/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000..ca9ea54 Binary files /dev/null and b/knihovna/dashboard/__pycache__/__init__.cpython-37.pyc differ diff --git a/knihovna/dashboard/__pycache__/admin.cpython-37.pyc b/knihovna/dashboard/__pycache__/admin.cpython-37.pyc new file mode 100644 index 0000000..fa1f73d Binary files /dev/null and b/knihovna/dashboard/__pycache__/admin.cpython-37.pyc differ diff --git a/knihovna/dashboard/__pycache__/apps.cpython-37.pyc b/knihovna/dashboard/__pycache__/apps.cpython-37.pyc new file mode 100644 index 0000000..675802a Binary files /dev/null and b/knihovna/dashboard/__pycache__/apps.cpython-37.pyc differ diff --git a/knihovna/dashboard/__pycache__/models.cpython-37.pyc b/knihovna/dashboard/__pycache__/models.cpython-37.pyc new file mode 100644 index 0000000..9127060 Binary files /dev/null and b/knihovna/dashboard/__pycache__/models.cpython-37.pyc differ diff --git a/knihovna/dashboard/admin.py b/knihovna/dashboard/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/knihovna/dashboard/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/knihovna/dashboard/apps.py b/knihovna/dashboard/apps.py new file mode 100644 index 0000000..7b1cc05 --- /dev/null +++ b/knihovna/dashboard/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class DashboardConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'dashboard' diff --git a/knihovna/dashboard/img/hardcore-historie.png b/knihovna/dashboard/img/hardcore-historie.png new file mode 100644 index 0000000..98d09b4 Binary files /dev/null and b/knihovna/dashboard/img/hardcore-historie.png differ diff --git a/knihovna/dashboard/img/nakladatelstvi.svg b/knihovna/dashboard/img/nakladatelstvi.svg new file mode 100644 index 0000000..7437ae7 --- /dev/null +++ b/knihovna/dashboard/img/nakladatelstvi.svg @@ -0,0 +1,3 @@ + + +
NA
KLA
DATE
LSTVÍ
NA...
Viewer does not support full SVG 1.1
\ No newline at end of file diff --git a/knihovna/dashboard/img/telo-scita-rany.png b/knihovna/dashboard/img/telo-scita-rany.png new file mode 100644 index 0000000..1f2a5c0 Binary files /dev/null and b/knihovna/dashboard/img/telo-scita-rany.png differ diff --git a/knihovna/dashboard/migrations/__init__.py b/knihovna/dashboard/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/knihovna/dashboard/migrations/__pycache__/__init__.cpython-37.pyc b/knihovna/dashboard/migrations/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000..6f759ef Binary files /dev/null and b/knihovna/dashboard/migrations/__pycache__/__init__.cpython-37.pyc differ diff --git a/knihovna/dashboard/models.py b/knihovna/dashboard/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/knihovna/dashboard/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/knihovna/dashboard/templates/wagtailadmin/base.html b/knihovna/dashboard/templates/wagtailadmin/base.html new file mode 100644 index 0000000..b1466e2 --- /dev/null +++ b/knihovna/dashboard/templates/wagtailadmin/base.html @@ -0,0 +1,6 @@ +{% extends "wagtailadmin/base.html" %} +{% load staticfiles %} + +{% block branding_logo %} + Custom Project +{% endblock %} \ No newline at end of file diff --git a/knihovna/dashboard/tests.py b/knihovna/dashboard/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/knihovna/dashboard/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/knihovna/dashboard/views.py b/knihovna/dashboard/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/knihovna/dashboard/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/knihovna/db.sqlite3 b/knihovna/db.sqlite3 new file mode 100644 index 0000000..c70ef72 Binary files /dev/null and b/knihovna/db.sqlite3 differ diff --git a/knihovna/home/__init__.py b/knihovna/home/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/knihovna/home/__pycache__/__init__.cpython-37.pyc b/knihovna/home/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000..ad68181 Binary files /dev/null and b/knihovna/home/__pycache__/__init__.cpython-37.pyc differ diff --git a/knihovna/home/__pycache__/models.cpython-37.pyc b/knihovna/home/__pycache__/models.cpython-37.pyc new file mode 100644 index 0000000..8f2842e Binary files /dev/null and b/knihovna/home/__pycache__/models.cpython-37.pyc differ diff --git a/knihovna/home/migrations/0001_initial.py b/knihovna/home/migrations/0001_initial.py new file mode 100644 index 0000000..ef46d12 --- /dev/null +++ b/knihovna/home/migrations/0001_initial.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('wagtailcore', '0040_page_draft_title'), + ] + + operations = [ + migrations.CreateModel( + name='HomePage', + fields=[ + ('page_ptr', models.OneToOneField(on_delete=models.CASCADE, parent_link=True, auto_created=True, primary_key=True, serialize=False, to='wagtailcore.Page')), + ], + options={ + 'abstract': False, + }, + bases=('wagtailcore.page',), + ), + ] diff --git a/knihovna/home/migrations/0002_create_homepage.py b/knihovna/home/migrations/0002_create_homepage.py new file mode 100644 index 0000000..5d611f8 --- /dev/null +++ b/knihovna/home/migrations/0002_create_homepage.py @@ -0,0 +1,62 @@ +# -*- coding: utf-8 -*- +from django.db import migrations + + +def create_homepage(apps, schema_editor): + # Get models + ContentType = apps.get_model('contenttypes.ContentType') + Page = apps.get_model('wagtailcore.Page') + Site = apps.get_model('wagtailcore.Site') + HomePage = apps.get_model('home.HomePage') + + # Delete the default homepage + # If migration is run multiple times, it may have already been deleted + Page.objects.filter(id=2).delete() + + # Create content type for homepage model + homepage_content_type, __ = ContentType.objects.get_or_create( + model='homepage', app_label='home') + + # Create a new homepage + homepage = HomePage.objects.create( + title="Home", + draft_title="Home", + slug='home', + content_type=homepage_content_type, + path='00010001', + depth=2, + numchild=0, + url_path='/home/', + ) + + # Create a site with the new homepage set as the root + Site.objects.create( + hostname='localhost', root_page=homepage, is_default_site=True) + + +def remove_homepage(apps, schema_editor): + # Get models + ContentType = apps.get_model('contenttypes.ContentType') + HomePage = apps.get_model('home.HomePage') + + # Delete the default homepage + # Page and Site objects CASCADE + HomePage.objects.filter(slug='home', depth=2).delete() + + # Delete content type for homepage model + ContentType.objects.filter(model='homepage', app_label='home').delete() + + +class Migration(migrations.Migration): + + run_before = [ + ('wagtailcore', '0053_locale_model'), + ] + + dependencies = [ + ('home', '0001_initial'), + ] + + operations = [ + migrations.RunPython(create_homepage, remove_homepage), + ] diff --git a/knihovna/home/migrations/0003_auto_20210604_0937.py b/knihovna/home/migrations/0003_auto_20210604_0937.py new file mode 100644 index 0000000..32d2ab3 --- /dev/null +++ b/knihovna/home/migrations/0003_auto_20210604_0937.py @@ -0,0 +1,36 @@ +# Generated by Django 3.2.4 on 2021-06-04 07:37 + +from django.db import migrations, models +import django.db.models.deletion +import modelcluster.fields +import wagtail.core.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('wagtailimages', '0023_add_choose_permissions'), + ('home', '0002_create_homepage'), + ] + + operations = [ + migrations.AddField( + model_name='homepage', + name='obsah', + field=wagtail.core.fields.RichTextField(blank=True), + ), + migrations.CreateModel( + name='Kolotoc', + 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)), + ('popisek', models.CharField(blank=True, max_length=250, verbose_name='Popisek')), + ('obrazek', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='+', to='wagtailimages.image', verbose_name='Obrázek')), + ('page', modelcluster.fields.ParentalKey(on_delete=django.db.models.deletion.CASCADE, related_name='kolotoc_obrazky', to='home.homepage')), + ], + options={ + 'ordering': ['sort_order'], + 'abstract': False, + }, + ), + ] diff --git a/knihovna/home/migrations/__init__.py b/knihovna/home/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/knihovna/home/migrations/__pycache__/0001_initial.cpython-37.pyc b/knihovna/home/migrations/__pycache__/0001_initial.cpython-37.pyc new file mode 100644 index 0000000..daaf0ae Binary files /dev/null and b/knihovna/home/migrations/__pycache__/0001_initial.cpython-37.pyc differ diff --git a/knihovna/home/migrations/__pycache__/0002_create_homepage.cpython-37.pyc b/knihovna/home/migrations/__pycache__/0002_create_homepage.cpython-37.pyc new file mode 100644 index 0000000..b41872b Binary files /dev/null and b/knihovna/home/migrations/__pycache__/0002_create_homepage.cpython-37.pyc differ diff --git a/knihovna/home/migrations/__pycache__/0003_auto_20210604_0937.cpython-37.pyc b/knihovna/home/migrations/__pycache__/0003_auto_20210604_0937.cpython-37.pyc new file mode 100644 index 0000000..98410a1 Binary files /dev/null and b/knihovna/home/migrations/__pycache__/0003_auto_20210604_0937.cpython-37.pyc differ diff --git a/knihovna/home/migrations/__pycache__/__init__.cpython-37.pyc b/knihovna/home/migrations/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000..b17a4f5 Binary files /dev/null and b/knihovna/home/migrations/__pycache__/__init__.cpython-37.pyc differ diff --git a/knihovna/home/models.py b/knihovna/home/models.py new file mode 100644 index 0000000..ff2d5af --- /dev/null +++ b/knihovna/home/models.py @@ -0,0 +1,33 @@ +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 HomePage(Page): + obsah = RichTextField(blank=True) + + content_panels = Page.content_panels + [ + FieldPanel('obsah', classname="full"), + InlinePanel('kolotoc_obrazky', label="Obrázky pro kolotoč"), + ] + + search_fields = Page.search_fields + [ + index.SearchField('obsah'), + ] + + +class Kolotoc(Orderable): + page = ParentalKey(HomePage, on_delete=models.CASCADE, related_name='kolotoc_obrazky') + obrazek = models.ForeignKey('wagtailimages.Image', on_delete=models.CASCADE, related_name='+', verbose_name='Obrázek') + popisek = models.CharField(blank=True, max_length=250, verbose_name='Popisek') + + panels = [ + ImageChooserPanel('obrazek'), + FieldPanel('popisek'), + ] \ No newline at end of file diff --git a/knihovna/home/static/css/css.css b/knihovna/home/static/css/css.css new file mode 100644 index 0000000..82c8b11 --- /dev/null +++ b/knihovna/home/static/css/css.css @@ -0,0 +1,3 @@ +nav{ + background-color: lightblue; +} diff --git a/knihovna/home/templates/home/home_page.html b/knihovna/home/templates/home/home_page.html new file mode 100644 index 0000000..99d3687 --- /dev/null +++ b/knihovna/home/templates/home/home_page.html @@ -0,0 +1,44 @@ +{% extends "base.html" %} +{% load static %} + +{% block body_class %}template-homepage{% endblock %} + +{% block extra_css %} + + +{% endblock extra_css %} + +{% load wagtailcore_tags %} + +{% block content %} + + + + +
+
+

{{ page.obsah|richtext }}

+
+ + +
+ + + +{% endblock content %} diff --git a/knihovna/home/templates/home/welcome_page.html b/knihovna/home/templates/home/welcome_page.html new file mode 100644 index 0000000..6368471 --- /dev/null +++ b/knihovna/home/templates/home/welcome_page.html @@ -0,0 +1,52 @@ +{% load i18n wagtailcore_tags %} + +
+ + +
+
+
+ +
+
+

{% trans "Welcome to your new Wagtail site!" %}

+

{% trans 'Please feel free to join our community on Slack, or get started with one of the links below.' %}

+
+
+ diff --git a/knihovna/knihovna/__init__.py b/knihovna/knihovna/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/knihovna/knihovna/__pycache__/__init__.cpython-37.pyc b/knihovna/knihovna/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000..4536533 Binary files /dev/null and b/knihovna/knihovna/__pycache__/__init__.cpython-37.pyc differ diff --git a/knihovna/knihovna/__pycache__/urls.cpython-37.pyc b/knihovna/knihovna/__pycache__/urls.cpython-37.pyc new file mode 100644 index 0000000..4a6fff4 Binary files /dev/null and b/knihovna/knihovna/__pycache__/urls.cpython-37.pyc differ diff --git a/knihovna/knihovna/__pycache__/wsgi.cpython-37.pyc b/knihovna/knihovna/__pycache__/wsgi.cpython-37.pyc new file mode 100644 index 0000000..397952e Binary files /dev/null and b/knihovna/knihovna/__pycache__/wsgi.cpython-37.pyc differ diff --git a/knihovna/knihovna/settings/__init__.py b/knihovna/knihovna/settings/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/knihovna/knihovna/settings/__pycache__/__init__.cpython-37.pyc b/knihovna/knihovna/settings/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000..3bd5566 Binary files /dev/null and b/knihovna/knihovna/settings/__pycache__/__init__.cpython-37.pyc differ diff --git a/knihovna/knihovna/settings/__pycache__/base.cpython-37.pyc b/knihovna/knihovna/settings/__pycache__/base.cpython-37.pyc new file mode 100644 index 0000000..b15a7c5 Binary files /dev/null and b/knihovna/knihovna/settings/__pycache__/base.cpython-37.pyc differ diff --git a/knihovna/knihovna/settings/__pycache__/dev.cpython-37.pyc b/knihovna/knihovna/settings/__pycache__/dev.cpython-37.pyc new file mode 100644 index 0000000..8e7fa85 Binary files /dev/null and b/knihovna/knihovna/settings/__pycache__/dev.cpython-37.pyc differ diff --git a/knihovna/knihovna/settings/base.py b/knihovna/knihovna/settings/base.py new file mode 100644 index 0000000..4909314 --- /dev/null +++ b/knihovna/knihovna/settings/base.py @@ -0,0 +1,162 @@ +""" +Django settings for knihovna project. + +Generated by 'django-admin startproject' using Django 3.2.4. + +For more information on this file, see +https://docs.djangoproject.com/en/3.2/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/3.2/ref/settings/ +""" + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +import os + +PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +BASE_DIR = os.path.dirname(PROJECT_DIR) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/ + + +# Application definition + +INSTALLED_APPS = [ + 'home', + 'search', + 'knihy', + 'stranky', + 'wagtail.contrib.forms', + 'wagtail.contrib.redirects', + 'wagtail.embeds', + 'wagtail.sites', + 'wagtail.users', + 'wagtail.snippets', + 'wagtail.documents', + 'wagtail.images', + 'wagtail.search', + 'wagtail.admin', + 'wagtail.core', + 'modelcluster', + 'taggit', + 'dashboard', + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', +] + +MIDDLEWARE = [ + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', + 'django.middleware.security.SecurityMiddleware', + + 'wagtail.contrib.redirects.middleware.RedirectMiddleware', +] + +ROOT_URLCONF = 'knihovna.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [ + os.path.join(PROJECT_DIR, 'templates'), + ], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'knihovna.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/3.2/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } +} + + +# Password validation +# https://docs.djangoproject.com/en/3.2/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.2/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/3.2/howto/static-files/ + +STATICFILES_FINDERS = [ + 'django.contrib.staticfiles.finders.FileSystemFinder', + 'django.contrib.staticfiles.finders.AppDirectoriesFinder', +] + +STATICFILES_DIRS = [ + os.path.join(PROJECT_DIR, 'static'), +] + +# 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.2/ref/contrib/staticfiles/#manifeststaticfilesstorage +STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage' + +STATIC_ROOT = os.path.join(BASE_DIR, 'static') +STATIC_URL = '/static/' + +MEDIA_ROOT = os.path.join(BASE_DIR, 'media') +MEDIA_URL = '/media/' + + +# Wagtail settings + +WAGTAIL_SITE_NAME = "knihovna" + +# Base URL to use when referring to full URLs within the Wagtail admin backend - +# e.g. in notification emails. Don't include '/admin' or a trailing slash +BASE_URL = 'http://example.com' diff --git a/knihovna/knihovna/settings/dev.py b/knihovna/knihovna/settings/dev.py new file mode 100644 index 0000000..8845508 --- /dev/null +++ b/knihovna/knihovna/settings/dev.py @@ -0,0 +1,18 @@ +from .base import * + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'django-insecure-z+yer#*w2+b-r4)%zb%1t!#m10x#lw=)=!%jw&lwu$1a@o7ea4' + +# SECURITY WARNING: define the correct hosts in production! +ALLOWED_HOSTS = ['*'] + +EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' + + +try: + from .local import * +except ImportError: + pass diff --git a/knihovna/knihovna/settings/production.py b/knihovna/knihovna/settings/production.py new file mode 100644 index 0000000..9ca4ed7 --- /dev/null +++ b/knihovna/knihovna/settings/production.py @@ -0,0 +1,8 @@ +from .base import * + +DEBUG = False + +try: + from .local import * +except ImportError: + pass diff --git a/knihovna/knihovna/static/css/knihovna.css b/knihovna/knihovna/static/css/knihovna.css new file mode 100644 index 0000000..e69de29 diff --git a/knihovna/knihovna/static/js/knihovna.js b/knihovna/knihovna/static/js/knihovna.js new file mode 100644 index 0000000..e69de29 diff --git a/knihovna/knihovna/templates/404.html b/knihovna/knihovna/templates/404.html new file mode 100644 index 0000000..3a5500e --- /dev/null +++ b/knihovna/knihovna/templates/404.html @@ -0,0 +1,9 @@ +{% extends "base.html" %} + +{% block body_class %}template-404{% endblock %} + +{% block content %} +

Page not found

+ +

Sorry, this page could not be found.

+{% endblock %} diff --git a/knihovna/knihovna/templates/500.html b/knihovna/knihovna/templates/500.html new file mode 100644 index 0000000..72b6406 --- /dev/null +++ b/knihovna/knihovna/templates/500.html @@ -0,0 +1,13 @@ + + + + + Internal server error + + + +

Internal server error

+ +

Sorry, there seems to be an error. Please try again soon.

+ + diff --git a/knihovna/knihovna/templates/base.html b/knihovna/knihovna/templates/base.html new file mode 100644 index 0000000..d70ffe4 --- /dev/null +++ b/knihovna/knihovna/templates/base.html @@ -0,0 +1,50 @@ +{% load static wagtailuserbar %} + + + + + + + {% block title %} + {% if self.seo_title %}{{ self.seo_title }}{% else %}{{ self.title }}{% endif %} + {% endblock %} + {% block title_suffix %} + {% with self.get_site.site_name as site_name %} + {% if site_name %}- {{ site_name }}{% endif %} + {% endwith %} + {% endblock %} + + + + + {# Global stylesheets #} + + + {% block extra_css %} + {# Override this in templates to add extra stylesheets #} + {% endblock %} + + + + + {% extends "wagtailadmin/base.html" %} + {% load staticfiles %} + + {% block branding_logo %} + Custom Project + {% endblock %} + + {% wagtailuserbar %} + + {% block content %}{% endblock %} + + {# Global javascript #} + + + + + {% block extra_js %} + {# Override this in templates to add extra javascript #} + {% endblock %} + + diff --git a/knihovna/knihovna/urls.py b/knihovna/knihovna/urls.py new file mode 100644 index 0000000..d1b8710 --- /dev/null +++ b/knihovna/knihovna/urls.py @@ -0,0 +1,39 @@ +from django.conf import settings +from django.urls import include, path +from django.contrib import admin + +from wagtail.admin import urls as wagtailadmin_urls +from wagtail.core import urls as wagtail_urls +from wagtail.documents import urls as wagtaildocs_urls + +from search import views as search_views + +urlpatterns = [ + path('django-admin/', admin.site.urls), + + path('admin/', include(wagtailadmin_urls)), + path('documents/', include(wagtaildocs_urls)), + + path('search/', search_views.search, name='search'), + +] + + +if settings.DEBUG: + from django.conf.urls.static import static + from django.contrib.staticfiles.urls import staticfiles_urlpatterns + + # Serve static and media files from development server + urlpatterns += staticfiles_urlpatterns() + urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + +urlpatterns = urlpatterns + [ + # For anything not caught by a more specific rule above, hand over to + # Wagtail's page serving mechanism. This should be the last pattern in + # the list: + path("", include(wagtail_urls)), + + # Alternatively, if you want Wagtail pages to be served from a subpath + # of your site, rather than the site root: + # path("pages/", include(wagtail_urls)), +] diff --git a/knihovna/knihovna/wsgi.py b/knihovna/knihovna/wsgi.py new file mode 100644 index 0000000..218f0e2 --- /dev/null +++ b/knihovna/knihovna/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for knihovna 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.2/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "knihovna.settings.dev") + +application = get_wsgi_application() diff --git a/knihovna/knihy/__init__.py b/knihovna/knihy/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/knihovna/knihy/__pycache__/__init__.cpython-37.pyc b/knihovna/knihy/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000..2d05064 Binary files /dev/null and b/knihovna/knihy/__pycache__/__init__.cpython-37.pyc differ diff --git a/knihovna/knihy/__pycache__/admin.cpython-37.pyc b/knihovna/knihy/__pycache__/admin.cpython-37.pyc new file mode 100644 index 0000000..fa5da99 Binary files /dev/null and b/knihovna/knihy/__pycache__/admin.cpython-37.pyc differ diff --git a/knihovna/knihy/__pycache__/apps.cpython-37.pyc b/knihovna/knihy/__pycache__/apps.cpython-37.pyc new file mode 100644 index 0000000..7771e50 Binary files /dev/null and b/knihovna/knihy/__pycache__/apps.cpython-37.pyc differ diff --git a/knihovna/knihy/__pycache__/models.cpython-37.pyc b/knihovna/knihy/__pycache__/models.cpython-37.pyc new file mode 100644 index 0000000..7ea6895 Binary files /dev/null and b/knihovna/knihy/__pycache__/models.cpython-37.pyc differ diff --git a/knihovna/knihy/admin.py b/knihovna/knihy/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/knihovna/knihy/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/knihovna/knihy/apps.py b/knihovna/knihy/apps.py new file mode 100644 index 0000000..ed6d716 --- /dev/null +++ b/knihovna/knihy/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class KnihyConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'knihy' diff --git a/knihovna/knihy/kniha.html b/knihovna/knihy/kniha.html new file mode 100644 index 0000000..e69de29 diff --git a/knihovna/knihy/migrations/0001_initial.py b/knihovna/knihy/migrations/0001_initial.py new file mode 100644 index 0000000..cb8a944 --- /dev/null +++ b/knihovna/knihy/migrations/0001_initial.py @@ -0,0 +1,43 @@ +# Generated by Django 3.2.4 on 2021-06-04 07:37 + +from django.db import migrations, models +import django.db.models.deletion +import wagtail.core.fields + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('wagtailcore', '0062_comment_models_and_pagesubscription'), + ('wagtailimages', '0023_add_choose_permissions'), + ] + + operations = [ + migrations.CreateModel( + name='Katalog', + 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')), + ], + options={ + 'abstract': False, + }, + bases=('wagtailcore.page',), + ), + migrations.CreateModel( + name='Kniha', + 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')), + ('podnadpis', models.CharField(blank=True, max_length=128, null=True, verbose_name='Podnadpis')), + ('datum_vydani', models.DateField(verbose_name='Datum vydání')), + ('autor', models.CharField(max_length=128, verbose_name='Autor')), + ('anotace', wagtail.core.fields.RichTextField(blank=True)), + ('obrazek', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='+', to='wagtailimages.image')), + ], + options={ + 'abstract': False, + }, + bases=('wagtailcore.page',), + ), + ] diff --git a/knihovna/knihy/migrations/__init__.py b/knihovna/knihy/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/knihovna/knihy/migrations/__pycache__/0001_initial.cpython-37.pyc b/knihovna/knihy/migrations/__pycache__/0001_initial.cpython-37.pyc new file mode 100644 index 0000000..19cf23e Binary files /dev/null and b/knihovna/knihy/migrations/__pycache__/0001_initial.cpython-37.pyc differ diff --git a/knihovna/knihy/migrations/__pycache__/__init__.cpython-37.pyc b/knihovna/knihy/migrations/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000..107f157 Binary files /dev/null and b/knihovna/knihy/migrations/__pycache__/__init__.cpython-37.pyc differ diff --git a/knihovna/knihy/models.py b/knihovna/knihy/models.py new file mode 100644 index 0000000..bd173fd --- /dev/null +++ b/knihovna/knihy/models.py @@ -0,0 +1,37 @@ +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 Katalog(Page): + parent_page_types = ['home.HomePage', ] + subpage_types = ['Kniha', ] + + +class Kniha(Page): + podnadpis = models.CharField(max_length=128, verbose_name='Podnadpis', null=True, blank=True) + datum_vydani = models.DateField("Datum vydání") + autor = models.CharField(max_length=128, verbose_name='Autor') + anotace = RichTextField(blank=True) + obrazek = models.ForeignKey('wagtailimages.Image', on_delete=models.PROTECT, related_name='+') + + parent_page_types = ['Katalog', ] + + search_fields = Page.search_fields + [ + index.SearchField('anotace'), + ] + + content_panels = Page.content_panels + [ + FieldPanel('podnadpis'), + FieldPanel('autor'), + FieldPanel('datum_vydani'), + FieldPanel('anotace', classname="full"), + ImageChooserPanel('obrazek'), + ] + diff --git a/knihovna/knihy/tests.py b/knihovna/knihy/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/knihovna/knihy/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/knihovna/knihy/views.py b/knihovna/knihy/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/knihovna/knihy/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/knihovna/manage.py b/knihovna/manage.py new file mode 100644 index 0000000..f27c858 --- /dev/null +++ b/knihovna/manage.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python +import os +import sys + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "knihovna.settings.dev") + + from django.core.management import execute_from_command_line + + execute_from_command_line(sys.argv) diff --git a/knihovna/media/images/hardcore-historie.max-165x165.png b/knihovna/media/images/hardcore-historie.max-165x165.png new file mode 100644 index 0000000..17eb2a2 Binary files /dev/null and b/knihovna/media/images/hardcore-historie.max-165x165.png differ diff --git a/knihovna/media/images/nakladatelstvi.svg b/knihovna/media/images/nakladatelstvi.svg new file mode 100644 index 0000000..7437ae7 --- /dev/null +++ b/knihovna/media/images/nakladatelstvi.svg @@ -0,0 +1,3 @@ + + +
NA
KLA
DATE
LSTVÍ
NA...
Viewer does not support full SVG 1.1
\ No newline at end of file diff --git a/knihovna/media/images/telo-scita-rany.max-165x165.png b/knihovna/media/images/telo-scita-rany.max-165x165.png new file mode 100644 index 0000000..9157882 Binary files /dev/null and b/knihovna/media/images/telo-scita-rany.max-165x165.png differ diff --git a/knihovna/media/original_images/hardcore-historie.png b/knihovna/media/original_images/hardcore-historie.png new file mode 100644 index 0000000..98d09b4 Binary files /dev/null and b/knihovna/media/original_images/hardcore-historie.png differ diff --git a/knihovna/media/original_images/telo-scita-rany.png b/knihovna/media/original_images/telo-scita-rany.png new file mode 100644 index 0000000..1f2a5c0 Binary files /dev/null and b/knihovna/media/original_images/telo-scita-rany.png differ diff --git a/knihovna/requirements.txt b/knihovna/requirements.txt new file mode 100644 index 0000000..3e22111 --- /dev/null +++ b/knihovna/requirements.txt @@ -0,0 +1,2 @@ +Django>=3.2,<3.3 +wagtail>=2.13,<2.14 diff --git a/knihovna/search/__init__.py b/knihovna/search/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/knihovna/search/__pycache__/__init__.cpython-37.pyc b/knihovna/search/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000..7443ac8 Binary files /dev/null and b/knihovna/search/__pycache__/__init__.cpython-37.pyc differ diff --git a/knihovna/search/__pycache__/views.cpython-37.pyc b/knihovna/search/__pycache__/views.cpython-37.pyc new file mode 100644 index 0000000..2f07a0a Binary files /dev/null and b/knihovna/search/__pycache__/views.cpython-37.pyc differ diff --git a/knihovna/search/templates/search/home_page.html b/knihovna/search/templates/search/home_page.html new file mode 100644 index 0000000..e69de29 diff --git a/knihovna/search/templates/search/katalog.html b/knihovna/search/templates/search/katalog.html new file mode 100644 index 0000000..e69de29 diff --git a/knihovna/search/templates/search/knihy.html b/knihovna/search/templates/search/knihy.html new file mode 100644 index 0000000..e69de29 diff --git a/knihovna/search/templates/search/search.html b/knihovna/search/templates/search/search.html new file mode 100644 index 0000000..5f222e5 --- /dev/null +++ b/knihovna/search/templates/search/search.html @@ -0,0 +1,38 @@ +{% extends "base.html" %} +{% load static wagtailcore_tags %} + +{% block body_class %}template-searchresults{% endblock %} + +{% block title %}Search{% endblock %} + +{% block content %} +

Search

+ +
+ + +
+ + {% if search_results %} + + + {% if search_results.has_previous %} + Previous + {% endif %} + + {% if search_results.has_next %} + Next + {% endif %} + {% elif search_query %} + No results found + {% endif %} +{% endblock %} diff --git a/knihovna/search/views.py b/knihovna/search/views.py new file mode 100644 index 0000000..d9ad9d0 --- /dev/null +++ b/knihovna/search/views.py @@ -0,0 +1,34 @@ +from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator +from django.template.response import TemplateResponse + +from wagtail.core.models import Page +from wagtail.search.models import Query + + +def search(request): + search_query = request.GET.get('query', None) + page = request.GET.get('page', 1) + + # Search + if search_query: + search_results = Page.objects.live().search(search_query) + query = Query.get(search_query) + + # Record hit + query.add_hit() + else: + search_results = Page.objects.none() + + # Pagination + paginator = Paginator(search_results, 10) + try: + search_results = paginator.page(page) + except PageNotAnInteger: + search_results = paginator.page(1) + except EmptyPage: + search_results = paginator.page(paginator.num_pages) + + return TemplateResponse(request, 'search/search.html', { + 'search_query': search_query, + 'search_results': search_results, + }) diff --git a/knihovna/stranky/__init__.py b/knihovna/stranky/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/knihovna/stranky/__pycache__/__init__.cpython-37.pyc b/knihovna/stranky/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000..f455aee Binary files /dev/null and b/knihovna/stranky/__pycache__/__init__.cpython-37.pyc differ diff --git a/knihovna/stranky/__pycache__/admin.cpython-37.pyc b/knihovna/stranky/__pycache__/admin.cpython-37.pyc new file mode 100644 index 0000000..1e587aa Binary files /dev/null and b/knihovna/stranky/__pycache__/admin.cpython-37.pyc differ diff --git a/knihovna/stranky/__pycache__/apps.cpython-37.pyc b/knihovna/stranky/__pycache__/apps.cpython-37.pyc new file mode 100644 index 0000000..66f8923 Binary files /dev/null and b/knihovna/stranky/__pycache__/apps.cpython-37.pyc differ diff --git a/knihovna/stranky/__pycache__/models.cpython-37.pyc b/knihovna/stranky/__pycache__/models.cpython-37.pyc new file mode 100644 index 0000000..a0c7181 Binary files /dev/null and b/knihovna/stranky/__pycache__/models.cpython-37.pyc differ diff --git a/knihovna/stranky/admin.py b/knihovna/stranky/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/knihovna/stranky/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/knihovna/stranky/apps.py b/knihovna/stranky/apps.py new file mode 100644 index 0000000..46af8b4 --- /dev/null +++ b/knihovna/stranky/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class StrankyConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'stranky' diff --git a/knihovna/stranky/migrations/0001_initial.py b/knihovna/stranky/migrations/0001_initial.py new file mode 100644 index 0000000..574ad0f --- /dev/null +++ b/knihovna/stranky/migrations/0001_initial.py @@ -0,0 +1,44 @@ +# Generated by Django 3.2.4 on 2021-06-04 07:37 + +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', '0062_comment_models_and_pagesubscription'), + ('wagtailimages', '0023_add_choose_permissions'), + ] + + operations = [ + migrations.CreateModel( + name='Stranka', + 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')), + ('obsah', wagtail.core.fields.RichTextField(blank=True, verbose_name='Obsah stránky')), + ], + options={ + 'abstract': False, + }, + bases=('wagtailcore.page',), + ), + migrations.CreateModel( + name='StrankaObrazek', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('sort_order', models.IntegerField(blank=True, editable=False, null=True)), + ('popisek', models.CharField(blank=True, max_length=250, verbose_name='Popisek')), + ('page', modelcluster.fields.ParentalKey(on_delete=django.db.models.deletion.CASCADE, related_name='obrazky', to='stranky.stranka')), + ('soubor', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='+', to='wagtailimages.image', verbose_name='Obrázek')), + ], + options={ + 'ordering': ['sort_order'], + 'abstract': False, + }, + ), + ] diff --git a/knihovna/stranky/migrations/__init__.py b/knihovna/stranky/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/knihovna/stranky/migrations/__pycache__/0001_initial.cpython-37.pyc b/knihovna/stranky/migrations/__pycache__/0001_initial.cpython-37.pyc new file mode 100644 index 0000000..a4119f1 Binary files /dev/null and b/knihovna/stranky/migrations/__pycache__/0001_initial.cpython-37.pyc differ diff --git a/knihovna/stranky/migrations/__pycache__/__init__.cpython-37.pyc b/knihovna/stranky/migrations/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000..3a4abb9 Binary files /dev/null and b/knihovna/stranky/migrations/__pycache__/__init__.cpython-37.pyc differ diff --git a/knihovna/stranky/models.py b/knihovna/stranky/models.py new file mode 100644 index 0000000..b0a2940 --- /dev/null +++ b/knihovna/stranky/models.py @@ -0,0 +1,33 @@ +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 Stranka(Page): + obsah = RichTextField(blank=True, verbose_name="Obsah stránky") + + search_fields = Page.search_fields + [ + index.SearchField('obsah'), + ] + + content_panels = Page.content_panels + [ + FieldPanel('obsah', classname="full"), + InlinePanel('obrazky', label="Obrázky"), + ] + + +class StrankaObrazek(Orderable): + page = ParentalKey(Stranka, on_delete=models.CASCADE, related_name='obrazky') + soubor = models.ForeignKey('wagtailimages.Image', on_delete=models.CASCADE, related_name='+', verbose_name='Obrázek') + popisek = models.CharField(blank=True, max_length=250, verbose_name='Popisek') + + panels = [ + ImageChooserPanel('soubor'), + FieldPanel('popisek'), + ] \ No newline at end of file diff --git a/knihovna/stranky/tests.py b/knihovna/stranky/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/knihovna/stranky/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/knihovna/stranky/views.py b/knihovna/stranky/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/knihovna/stranky/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here.