Skip to content
Snippets Groups Projects
Commit a7c542d3 authored by Tomáš Valenta's avatar Tomáš Valenta
Browse files

wip - index page

parents
Branches
No related tags found
No related merge requests found
Showing
with 584 additions and 0 deletions
# Use an official Python runtime based on Debian 10 "buster" as a parent image.
FROM python:3.11
# 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 institut.wsgi:application
Makefile 0 → 100644
#!/usr/bin/make -f
PYTHON = python3.11
VENV = .venv
PORT = 8009
SETTINGS = institut.settings.dev
.PHONY: help venv install install-hooks hooks build run shell migrations migrate
help:
@echo "Setup:"
@echo " venv Setup virtual environment"
@echo " install Install all dependencies to venv"
@echo " install-python Install Python dependencies to venv"
@echo " install-node Install Node.js dependencies to venv"
@echo " install-hooks Install pre-commit hooks"
@echo " hooks Run pre-commit hooks manually"
@echo " build Build CSS and JS files"
@echo ""
@echo "Application:"
@echo " run Run the application on port ${PORT}"
@echo " shell Access the Django shell"
@echo ""
@echo "Database:"
@echo " migrations Generate migrations"
@echo " migrate Run migrations"
venv: .venv/bin/python
.venv/bin/python:
${PYTHON} -m venv ${VENV}
install: venv
${VENV}/bin/pip install -r requirements/base.txt
${VENV}/bin/pip install -r requirements/production.txt
npm install
install-python: venv
${VENV}/bin/pip install -r requirements/base.txt
${VENV}/bin/pip install -r requirements/production.txt
install-node: venv
npm install
install-hooks:
pre-commit install --install-hooks
hooks:
pre-commit run -a
build: venv
npm run build
${VENV}/bin/python manage.py collectstatic --noinput --settings=${SETTINGS}
run: venv
${VENV}/bin/python manage.py runserver ${PORT} --settings=${SETTINGS}
shell: venv
${VENV}/bin/python manage.py shell --settings=${SETTINGS}
migrations: venv
${VENV}/bin/python manage.py makemigrations --settings=${SETTINGS}
migrate: venv
${VENV}/bin/python manage.py migrate --settings=${SETTINGS}
DATABASE_URL="postgresql://nastenka:nastenka@localhost:5432/postgres"
# -*- 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",),
),
]
# -*- 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),
]
from django.db import models
from wagtail.models import Page
class HomePage(Page):
pass
{% extends "base.html" %}
{% load static %}
{% block content %}
<nav class="bg-grey-800 py-8 flex justify-center">
<div class="flex gap-7 container text-white items-center">
<a
href="/"
>
<img
class="h-9"
src="{% static 'images/logo.png' %}"
alt="Logo"
>
</a>
<div
class="w-px h-6 bg-white"
></div>
<div class="flex gap-4">
<a class="nav__item" href="#uvod">Úvod</a>
<a class="nav__item" href="#aktualne">Aktuálně</a>
<a class="nav__item" href="#akce">Akce</a>
<a class="nav__item" href="#dokumenty">Dokumenty</a>
<a class="nav__item" href="#dary">Dary</a>
<a class="nav__item" href="#kontakty">Kontakty</a>
<a class="nav__item" href="#lide">Lidé</a>
</div>
</div>
</nav>
<main class="flex flex-col items-center gap-5 pt-14">
<div class="container flex gap-10">
<figure class="w-32 flex flex-col gap-2">
<img
src="{% static 'images/logo_big.png' %}"
alt="Logo"
>
<figcaption class="font-sans leading-4">
<small>
Pirátský politický institut
</small>
</figcaption>
</figure>
<div class="prose font-serif leading-6 text-black">
<h2>Co je naším úkolem?</h2>
<p>
Politika se často omezuje na dobu výkonu mandátu a na tvorbu komplexních
a dlouhodobých řešení tak nezbývá vůle ani čas. Institut π ve spolupráci s akademickou
obcí i dobrovolníky z řad expertů i širší veřejnosti se proto přesně tomu bude věnovat.
</p>
<p>
Institut π iniciuje a rozvíjí diskurz o obtížných a pro životaschopnost demokratické
společnosti důležitých otázkách. Podílí se na nacházení možných řešení, analyzuje
výhody a nevýhody různých přístupů a alternativ, otevírá diskuzi o nich a pomáhá je
uskutečňovat.
</p>
<p>
Práce institutu je otevřená a inkluzivní a opírá se především o akademickou radu
a dobrovolnický kruh. Institut vytváří živnou půdu pro práci a iniciativu odborníků
i dobrovolníků napříč obory, včetně spolupráce s občanskými aktivisty a organizacemi,
a to i mezinárodně.
</p>
</div>
</div>
<div class="flex justify-center bg-pii-cyan w-full p-5">
<div class="container flex flex-col gap-2">
<h2 class="font-bebas text-white uppercase">Aktuálně</h2>
<ul class="flex gap-4 h-80 w-72">
<li class="bg-white p-5">
<a class="flex flex-col gap-2">
<small class="text-pii-cyan uppercase font-bold">Společnost</small>
<h3 class="font-serif text-lg font-bold">Současný stranický systém v ČR</h3>
<p class="font-serif leading-5">
Prvního března 2023 proběhla
v Pirátském centru v Praze diskuse,
organizovaná Institutem Π
a věnovaná Pirátům na politické
mapě ČR. A to jak ve smyslu
geograficko-demografickém, tak ve
smyslu čistě politickém
</p>
<small class="font-serif">
Přidáno 23. srpna 2022
</small>
</a>
</li>
</ul>
</div>
</div>
</main>
{% endblock content %}
# 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
"""
Django settings for institut project.
Generated by 'django-admin startproject' using Django 4.2.2.
For more information on this file, see
https://docs.djangoproject.com/en/4.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.2/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
import dj_database_url
import environ
PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
BASE_DIR = os.path.dirname(PROJECT_DIR)
env = environ.Env()
environ.Env.read_env(os.path.join(BASE_DIR, ".env"))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
# Application definition
INSTALLED_APPS = [
"home",
"wagtail.contrib.forms",
"wagtail.contrib.redirects",
"wagtail.embeds",
"wagtail.sites",
"wagtail.users",
"wagtail.snippets",
"wagtail.documents",
"wagtail.images",
"wagtail.search",
"wagtail.admin",
"wagtail",
"modelcluster",
"taggit",
"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 = "institut.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 = "institut.wsgi.application"
# Database
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
DATABASES = {"default": dj_database_url.config(conn_max_age=600, conn_health_checks=True)}
# Password validation
# https://docs.djangoproject.com/en/4.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/4.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/4.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/4.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 = "institut"
# Search
# https://docs.wagtail.org/en/stable/topics/search/backends.html
WAGTAILSEARCH_BACKENDS = {
"default": {
"BACKEND": "wagtail.search.backends.database",
}
}
# 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
WAGTAILADMIN_BASE_URL = "http://example.com"
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-+uu@*c&or8%cp3zu5)tgf^$uc&0cr2)ve=9n%kv4j84g^#iyl2"
# 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
from .base import *
DEBUG = False
try:
from .local import *
except ImportError:
pass
institut/static/images/logo.png

14.5 KiB

institut/static/images/logo_big.png

5.32 KiB

{% extends "base.html" %}
{% block title %}Page not found{% endblock %}
{% block body_class %}template-404{% endblock %}
{% block content %}
<h1>Page not found</h1>
<h2>Sorry, this page could not be found.</h2>
{% endblock %}
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8" />
<title>Internal server error</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
<h1>Internal server error</h1>
<h2>Sorry, there seems to be an error. Please try again soon.</h2>
</body>
</html>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment