Initial from torchbox/cookiecutter-wagtail
This commit is contained in:
commit
2200695306
40 changed files with 1647 additions and 0 deletions
11
.gitignore
vendored
Normal file
11
.gitignore
vendored
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
*.pyc
|
||||||
|
.DS_Store
|
||||||
|
*.swp
|
||||||
|
/env/
|
||||||
|
/venv/
|
||||||
|
/static/
|
||||||
|
/media/
|
||||||
|
/tmp/
|
||||||
|
/.vagrant/
|
||||||
|
/Vagrantfile.local
|
||||||
|
/docs/_build/
|
1
Procfile
Normal file
1
Procfile
Normal file
|
@ -0,0 +1 @@
|
||||||
|
web: uwsgi --http :$PORT --module publichealthschweiz.wsgi --master --offload-threads 1
|
76
Vagrantfile
vendored
Normal file
76
Vagrantfile
vendored
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
# -*- mode: ruby -*-
|
||||||
|
# vi: set ft=ruby :
|
||||||
|
|
||||||
|
# All Vagrant configuration is done below. The "2" in Vagrant.configure
|
||||||
|
# configures the configuration version (we support older styles for
|
||||||
|
# backwards compatibility). Please don't change it unless you know what
|
||||||
|
# you're doing.
|
||||||
|
Vagrant.configure(2) do |config|
|
||||||
|
# The most common configuration options are documented and commented below.
|
||||||
|
# For a complete reference, please see the online documentation at
|
||||||
|
# https://docs.vagrantup.com.
|
||||||
|
|
||||||
|
# Every Vagrant development environment requires a box. You can search for
|
||||||
|
# boxes at https://atlas.hashicorp.com/search.
|
||||||
|
config.vm.box = "torchbox/wagtail-jessie64"
|
||||||
|
config.vm.box_version = "~> 1.0"
|
||||||
|
|
||||||
|
# Disable automatic box update checking. If you disable this, then
|
||||||
|
# boxes will only be checked for updates when the user runs
|
||||||
|
# `vagrant box outdated`. This is not recommended.
|
||||||
|
# config.vm.box_check_update = false
|
||||||
|
|
||||||
|
# Create a forwarded port mapping which allows access to a specific port
|
||||||
|
# within the machine from a port on the host machine. In the example below,
|
||||||
|
# accessing "localhost:8000" will access port 8000 on the guest machine.
|
||||||
|
config.vm.network "forwarded_port", guest: 8000, host: 8000
|
||||||
|
|
||||||
|
# Create a private network, which allows host-only access to the machine
|
||||||
|
# using a specific IP.
|
||||||
|
# config.vm.network "private_network", ip: "192.168.33.10"
|
||||||
|
|
||||||
|
# Create a public network, which generally matched to bridged network.
|
||||||
|
# Bridged networks make the machine appear as another physical device on
|
||||||
|
# your network.
|
||||||
|
# config.vm.network "public_network"
|
||||||
|
|
||||||
|
# Share an additional folder to the guest VM. The first argument is
|
||||||
|
# the path on the host to the actual folder. The second argument is
|
||||||
|
# the path on the guest to mount the folder. And the optional third
|
||||||
|
# argument is a set of non-required options.
|
||||||
|
# config.vm.synced_folder "../data", "/vagrant_data"
|
||||||
|
|
||||||
|
# Provider-specific configuration so you can fine-tune various
|
||||||
|
# backing providers for Vagrant. These expose provider-specific options.
|
||||||
|
# Example for VirtualBox:
|
||||||
|
#
|
||||||
|
# config.vm.provider "virtualbox" do |vb|
|
||||||
|
# # Display the VirtualBox GUI when booting the machine
|
||||||
|
# vb.gui = true
|
||||||
|
#
|
||||||
|
# # Customize the amount of memory on the VM:
|
||||||
|
# vb.memory = "1024"
|
||||||
|
# end
|
||||||
|
#
|
||||||
|
# View the documentation for the provider you are using for more
|
||||||
|
# information on available options.
|
||||||
|
|
||||||
|
# Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
|
||||||
|
# such as FTP and Heroku are also available. See the documentation at
|
||||||
|
# https://docs.vagrantup.com/v2/push/atlas.html for more information.
|
||||||
|
# config.push.define "atlas" do |push|
|
||||||
|
# push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
|
||||||
|
# end
|
||||||
|
|
||||||
|
# Enable provisioning with a shell script. Additional provisioners such as
|
||||||
|
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
|
||||||
|
# documentation for more information about their specific syntax and use.
|
||||||
|
# config.vm.provision "shell", inline: <<-SHELL
|
||||||
|
# sudo apt-get update
|
||||||
|
# sudo apt-get install -y apache2
|
||||||
|
# SHELL
|
||||||
|
config.vm.provision :shell, :path => "vagrant/provision.sh", :args => "publichealthschweiz"
|
||||||
|
|
||||||
|
# Enable agent forwarding over SSH connections.
|
||||||
|
config.ssh.forward_agent = true
|
||||||
|
end
|
1
bin/post_compile
Normal file
1
bin/post_compile
Normal file
|
@ -0,0 +1 @@
|
||||||
|
python manage.py compress --settings publichealthschweiz.settings.production
|
153
docs/Makefile
Normal file
153
docs/Makefile
Normal file
|
@ -0,0 +1,153 @@
|
||||||
|
# Makefile for Sphinx documentation
|
||||||
|
#
|
||||||
|
|
||||||
|
# You can set these variables from the command line.
|
||||||
|
SPHINXOPTS =
|
||||||
|
SPHINXBUILD = sphinx-build
|
||||||
|
PAPER =
|
||||||
|
BUILDDIR = _build
|
||||||
|
|
||||||
|
# Internal variables.
|
||||||
|
PAPEROPT_a4 = -D latex_paper_size=a4
|
||||||
|
PAPEROPT_letter = -D latex_paper_size=letter
|
||||||
|
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
|
||||||
|
# the i18n builder cannot share the environment and doctrees with the others
|
||||||
|
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
|
||||||
|
|
||||||
|
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
|
||||||
|
|
||||||
|
help:
|
||||||
|
@echo "Please use \`make <target>' where <target> is one of"
|
||||||
|
@echo " html to make standalone HTML files"
|
||||||
|
@echo " dirhtml to make HTML files named index.html in directories"
|
||||||
|
@echo " singlehtml to make a single large HTML file"
|
||||||
|
@echo " pickle to make pickle files"
|
||||||
|
@echo " json to make JSON files"
|
||||||
|
@echo " htmlhelp to make HTML files and a HTML help project"
|
||||||
|
@echo " qthelp to make HTML files and a qthelp project"
|
||||||
|
@echo " devhelp to make HTML files and a Devhelp project"
|
||||||
|
@echo " epub to make an epub"
|
||||||
|
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
|
||||||
|
@echo " latexpdf to make LaTeX files and run them through pdflatex"
|
||||||
|
@echo " text to make text files"
|
||||||
|
@echo " man to make manual pages"
|
||||||
|
@echo " texinfo to make Texinfo files"
|
||||||
|
@echo " info to make Texinfo files and run them through makeinfo"
|
||||||
|
@echo " gettext to make PO message catalogs"
|
||||||
|
@echo " changes to make an overview of all changed/added/deprecated items"
|
||||||
|
@echo " linkcheck to check all external links for integrity"
|
||||||
|
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
|
||||||
|
|
||||||
|
clean:
|
||||||
|
-rm -rf $(BUILDDIR)/*
|
||||||
|
|
||||||
|
html:
|
||||||
|
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
|
||||||
|
@echo
|
||||||
|
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
|
||||||
|
|
||||||
|
dirhtml:
|
||||||
|
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
|
||||||
|
@echo
|
||||||
|
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
|
||||||
|
|
||||||
|
singlehtml:
|
||||||
|
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
|
||||||
|
@echo
|
||||||
|
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
|
||||||
|
|
||||||
|
pickle:
|
||||||
|
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
|
||||||
|
@echo
|
||||||
|
@echo "Build finished; now you can process the pickle files."
|
||||||
|
|
||||||
|
json:
|
||||||
|
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
|
||||||
|
@echo
|
||||||
|
@echo "Build finished; now you can process the JSON files."
|
||||||
|
|
||||||
|
htmlhelp:
|
||||||
|
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
|
||||||
|
@echo
|
||||||
|
@echo "Build finished; now you can run HTML Help Workshop with the" \
|
||||||
|
".hhp project file in $(BUILDDIR)/htmlhelp."
|
||||||
|
|
||||||
|
qthelp:
|
||||||
|
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
|
||||||
|
@echo
|
||||||
|
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
|
||||||
|
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
|
||||||
|
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Public Health Schweiz.qhcp"
|
||||||
|
@echo "To view the help file:"
|
||||||
|
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Public Health Schweiz.qhc"
|
||||||
|
|
||||||
|
devhelp:
|
||||||
|
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
|
||||||
|
@echo
|
||||||
|
@echo "Build finished."
|
||||||
|
@echo "To view the help file:"
|
||||||
|
@echo "# mkdir -p $$HOME/.local/share/devhelp/Public Health Schweiz"
|
||||||
|
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/Public Health Schweiz"
|
||||||
|
@echo "# devhelp"
|
||||||
|
|
||||||
|
epub:
|
||||||
|
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
|
||||||
|
@echo
|
||||||
|
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
|
||||||
|
|
||||||
|
latex:
|
||||||
|
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
||||||
|
@echo
|
||||||
|
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
|
||||||
|
@echo "Run \`make' in that directory to run these through (pdf)latex" \
|
||||||
|
"(use \`make latexpdf' here to do that automatically)."
|
||||||
|
|
||||||
|
latexpdf:
|
||||||
|
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
||||||
|
@echo "Running LaTeX files through pdflatex..."
|
||||||
|
$(MAKE) -C $(BUILDDIR)/latex all-pdf
|
||||||
|
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
|
||||||
|
|
||||||
|
text:
|
||||||
|
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
|
||||||
|
@echo
|
||||||
|
@echo "Build finished. The text files are in $(BUILDDIR)/text."
|
||||||
|
|
||||||
|
man:
|
||||||
|
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
|
||||||
|
@echo
|
||||||
|
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
|
||||||
|
|
||||||
|
texinfo:
|
||||||
|
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
|
||||||
|
@echo
|
||||||
|
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
|
||||||
|
@echo "Run \`make' in that directory to run these through makeinfo" \
|
||||||
|
"(use \`make info' here to do that automatically)."
|
||||||
|
|
||||||
|
info:
|
||||||
|
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
|
||||||
|
@echo "Running Texinfo files through makeinfo..."
|
||||||
|
make -C $(BUILDDIR)/texinfo info
|
||||||
|
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
|
||||||
|
|
||||||
|
gettext:
|
||||||
|
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
|
||||||
|
@echo
|
||||||
|
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
|
||||||
|
|
||||||
|
changes:
|
||||||
|
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
|
||||||
|
@echo
|
||||||
|
@echo "The overview file is in $(BUILDDIR)/changes."
|
||||||
|
|
||||||
|
linkcheck:
|
||||||
|
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
|
||||||
|
@echo
|
||||||
|
@echo "Link check complete; look for any errors in the above output " \
|
||||||
|
"or in $(BUILDDIR)/linkcheck/output.txt."
|
||||||
|
|
||||||
|
doctest:
|
||||||
|
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
|
||||||
|
@echo "Testing of doctests in the sources finished, look at the " \
|
||||||
|
"results in $(BUILDDIR)/doctest/output.txt."
|
1
docs/__init__.py
Normal file
1
docs/__init__.py
Normal file
|
@ -0,0 +1 @@
|
||||||
|
# Included so that Django's startproject comment runs against the docs directory
|
242
docs/conf.py
Normal file
242
docs/conf.py
Normal file
|
@ -0,0 +1,242 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
#
|
||||||
|
# Public Health Schweiz documentation build configuration file, created by
|
||||||
|
# sphinx-quickstart on Sun Feb 17 11:46:20 2013.
|
||||||
|
#
|
||||||
|
# This file is execfile()d with the current directory set to its containing dir.
|
||||||
|
#
|
||||||
|
# Note that not all possible configuration values are present in this
|
||||||
|
# autogenerated file.
|
||||||
|
#
|
||||||
|
# All configuration values have a default; values that are commented out
|
||||||
|
# serve to show the default.
|
||||||
|
|
||||||
|
import sys, os
|
||||||
|
|
||||||
|
# If extensions (or modules to document with autodoc) are in another directory,
|
||||||
|
# add these directories to sys.path here. If the directory is relative to the
|
||||||
|
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||||
|
#sys.path.insert(0, os.path.abspath('.'))
|
||||||
|
|
||||||
|
# -- General configuration -----------------------------------------------------
|
||||||
|
|
||||||
|
# If your documentation needs a minimal Sphinx version, state it here.
|
||||||
|
#needs_sphinx = '1.0'
|
||||||
|
|
||||||
|
# Add any Sphinx extension module names here, as strings. They can be extensions
|
||||||
|
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
||||||
|
extensions = []
|
||||||
|
|
||||||
|
# Add any paths that contain templates here, relative to this directory.
|
||||||
|
templates_path = ['_templates']
|
||||||
|
|
||||||
|
# The suffix of source filenames.
|
||||||
|
source_suffix = '.rst'
|
||||||
|
|
||||||
|
# The encoding of source files.
|
||||||
|
#source_encoding = 'utf-8-sig'
|
||||||
|
|
||||||
|
# The master toctree document.
|
||||||
|
master_doc = 'index'
|
||||||
|
|
||||||
|
# General information about the project.
|
||||||
|
project = u'Public Health Schweiz'
|
||||||
|
copyright = u'2014, ChangeMyName'
|
||||||
|
|
||||||
|
# The version info for the project you're documenting, acts as replacement for
|
||||||
|
# |version| and |release|, also used in various other places throughout the
|
||||||
|
# built documents.
|
||||||
|
#
|
||||||
|
# The short X.Y version.
|
||||||
|
version = '0.1'
|
||||||
|
# The full version, including alpha/beta/rc tags.
|
||||||
|
release = '0.1'
|
||||||
|
|
||||||
|
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||||
|
# for a list of supported languages.
|
||||||
|
#language = None
|
||||||
|
|
||||||
|
# There are two options for replacing |today|: either, you set today to some
|
||||||
|
# non-false value, then it is used:
|
||||||
|
#today = ''
|
||||||
|
# Else, today_fmt is used as the format for a strftime call.
|
||||||
|
#today_fmt = '%B %d, %Y'
|
||||||
|
|
||||||
|
# List of patterns, relative to source directory, that match files and
|
||||||
|
# directories to ignore when looking for source files.
|
||||||
|
exclude_patterns = ['_build']
|
||||||
|
|
||||||
|
# The reST default role (used for this markup: `text`) to use for all documents.
|
||||||
|
#default_role = None
|
||||||
|
|
||||||
|
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||||
|
#add_function_parentheses = True
|
||||||
|
|
||||||
|
# If true, the current module name will be prepended to all description
|
||||||
|
# unit titles (such as .. function::).
|
||||||
|
#add_module_names = True
|
||||||
|
|
||||||
|
# If true, sectionauthor and moduleauthor directives will be shown in the
|
||||||
|
# output. They are ignored by default.
|
||||||
|
#show_authors = False
|
||||||
|
|
||||||
|
# The name of the Pygments (syntax highlighting) style to use.
|
||||||
|
pygments_style = 'sphinx'
|
||||||
|
|
||||||
|
# A list of ignored prefixes for module index sorting.
|
||||||
|
#modindex_common_prefix = []
|
||||||
|
|
||||||
|
|
||||||
|
# -- Options for HTML output ---------------------------------------------------
|
||||||
|
|
||||||
|
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||||
|
# a list of builtin themes.
|
||||||
|
html_theme = 'default'
|
||||||
|
|
||||||
|
# Theme options are theme-specific and customize the look and feel of a theme
|
||||||
|
# further. For a list of options available for each theme, see the
|
||||||
|
# documentation.
|
||||||
|
#html_theme_options = {}
|
||||||
|
|
||||||
|
# Add any paths that contain custom themes here, relative to this directory.
|
||||||
|
#html_theme_path = []
|
||||||
|
|
||||||
|
# The name for this set of Sphinx documents. If None, it defaults to
|
||||||
|
# "<project> v<release> documentation".
|
||||||
|
#html_title = None
|
||||||
|
|
||||||
|
# A shorter title for the navigation bar. Default is the same as html_title.
|
||||||
|
#html_short_title = None
|
||||||
|
|
||||||
|
# The name of an image file (relative to this directory) to place at the top
|
||||||
|
# of the sidebar.
|
||||||
|
#html_logo = None
|
||||||
|
|
||||||
|
# The name of an image file (within the static path) to use as favicon of the
|
||||||
|
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
||||||
|
# pixels large.
|
||||||
|
#html_favicon = None
|
||||||
|
|
||||||
|
# Add any paths that contain custom static files (such as style sheets) here,
|
||||||
|
# relative to this directory. They are copied after the builtin static files,
|
||||||
|
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||||
|
html_static_path = ['_static']
|
||||||
|
|
||||||
|
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
||||||
|
# using the given strftime format.
|
||||||
|
#html_last_updated_fmt = '%b %d, %Y'
|
||||||
|
|
||||||
|
# If true, SmartyPants will be used to convert quotes and dashes to
|
||||||
|
# typographically correct entities.
|
||||||
|
#html_use_smartypants = True
|
||||||
|
|
||||||
|
# Custom sidebar templates, maps document names to template names.
|
||||||
|
#html_sidebars = {}
|
||||||
|
|
||||||
|
# Additional templates that should be rendered to pages, maps page names to
|
||||||
|
# template names.
|
||||||
|
#html_additional_pages = {}
|
||||||
|
|
||||||
|
# If false, no module index is generated.
|
||||||
|
#html_domain_indices = True
|
||||||
|
|
||||||
|
# If false, no index is generated.
|
||||||
|
#html_use_index = True
|
||||||
|
|
||||||
|
# If true, the index is split into individual pages for each letter.
|
||||||
|
#html_split_index = False
|
||||||
|
|
||||||
|
# If true, links to the reST sources are added to the pages.
|
||||||
|
#html_show_sourcelink = True
|
||||||
|
|
||||||
|
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
|
||||||
|
#html_show_sphinx = True
|
||||||
|
|
||||||
|
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
|
||||||
|
#html_show_copyright = True
|
||||||
|
|
||||||
|
# If true, an OpenSearch description file will be output, and all pages will
|
||||||
|
# contain a <link> tag referring to it. The value of this option must be the
|
||||||
|
# base URL from which the finished HTML is served.
|
||||||
|
#html_use_opensearch = ''
|
||||||
|
|
||||||
|
# This is the file name suffix for HTML files (e.g. ".xhtml").
|
||||||
|
#html_file_suffix = None
|
||||||
|
|
||||||
|
# Output file base name for HTML help builder.
|
||||||
|
htmlhelp_basename = 'publichealthschweizdoc'
|
||||||
|
|
||||||
|
|
||||||
|
# -- Options for LaTeX output --------------------------------------------------
|
||||||
|
|
||||||
|
latex_elements = {
|
||||||
|
# The paper size ('letterpaper' or 'a4paper').
|
||||||
|
#'papersize': 'letterpaper',
|
||||||
|
|
||||||
|
# The font size ('10pt', '11pt' or '12pt').
|
||||||
|
#'pointsize': '10pt',
|
||||||
|
|
||||||
|
# Additional stuff for the LaTeX preamble.
|
||||||
|
#'preamble': '',
|
||||||
|
}
|
||||||
|
|
||||||
|
# Grouping the document tree into LaTeX files. List of tuples
|
||||||
|
# (source start file, target name, title, author, documentclass [howto/manual]).
|
||||||
|
latex_documents = [
|
||||||
|
('index', 'publichealthschweiz.tex', u'Public Health Schweiz Documentation',
|
||||||
|
u'ChangeToMyName', 'manual'),
|
||||||
|
]
|
||||||
|
|
||||||
|
# The name of an image file (relative to this directory) to place at the top of
|
||||||
|
# the title page.
|
||||||
|
#latex_logo = None
|
||||||
|
|
||||||
|
# For "manual" documents, if this is true, then toplevel headings are parts,
|
||||||
|
# not chapters.
|
||||||
|
#latex_use_parts = False
|
||||||
|
|
||||||
|
# If true, show page references after internal links.
|
||||||
|
#latex_show_pagerefs = False
|
||||||
|
|
||||||
|
# If true, show URL addresses after external links.
|
||||||
|
#latex_show_urls = False
|
||||||
|
|
||||||
|
# Documents to append as an appendix to all manuals.
|
||||||
|
#latex_appendices = []
|
||||||
|
|
||||||
|
# If false, no module index is generated.
|
||||||
|
#latex_domain_indices = True
|
||||||
|
|
||||||
|
|
||||||
|
# -- Options for manual page output --------------------------------------------
|
||||||
|
|
||||||
|
# One entry per manual page. List of tuples
|
||||||
|
# (source start file, name, description, authors, manual section).
|
||||||
|
man_pages = [
|
||||||
|
('index', 'publichealthschweiz', u'Public Health Schweiz Documentation',
|
||||||
|
[u'ChangeToMyName'], 1)
|
||||||
|
]
|
||||||
|
|
||||||
|
# If true, show URL addresses after external links.
|
||||||
|
#man_show_urls = False
|
||||||
|
|
||||||
|
|
||||||
|
# -- Options for Texinfo output ------------------------------------------------
|
||||||
|
|
||||||
|
# Grouping the document tree into Texinfo files. List of tuples
|
||||||
|
# (source start file, target name, title, author,
|
||||||
|
# dir menu entry, description, category)
|
||||||
|
texinfo_documents = [
|
||||||
|
('index', 'publichealthschweiz', u'Public Health Schweiz Documentation',
|
||||||
|
u'ChangeToMyName', 'publichealthschweiz', 'One line description of project.',
|
||||||
|
'Miscellaneous'),
|
||||||
|
]
|
||||||
|
|
||||||
|
# Documents to append as an appendix to all manuals.
|
||||||
|
#texinfo_appendices = []
|
||||||
|
|
||||||
|
# If false, no module index is generated.
|
||||||
|
#texinfo_domain_indices = True
|
||||||
|
|
||||||
|
# How to display URL addresses: 'footnote', 'no', or 'inline'.
|
||||||
|
#texinfo_show_urls = 'footnote'
|
4
docs/deploy.rst
Normal file
4
docs/deploy.rst
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
Deploy
|
||||||
|
========
|
||||||
|
|
||||||
|
This is where you describe how the project is deployed in production.
|
25
docs/index.rst
Normal file
25
docs/index.rst
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
.. Public Health Schweiz documentation master file, created by
|
||||||
|
sphinx-quickstart on Sun Feb 17 11:46:20 2013.
|
||||||
|
You can adapt this file completely to your liking, but it should at least
|
||||||
|
contain the root `toctree` directive.
|
||||||
|
|
||||||
|
Welcome to Public Health Schweiz's documentation!
|
||||||
|
====================================
|
||||||
|
|
||||||
|
Contents:
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:maxdepth: 2
|
||||||
|
|
||||||
|
install
|
||||||
|
deploy
|
||||||
|
tests
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Indices and tables
|
||||||
|
==================
|
||||||
|
|
||||||
|
* :ref:`genindex`
|
||||||
|
* :ref:`modindex`
|
||||||
|
* :ref:`search`
|
4
docs/install.rst
Normal file
4
docs/install.rst
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
Install
|
||||||
|
=========
|
||||||
|
|
||||||
|
This is where you write how to get a new laptop to run this project.
|
190
docs/make.bat
Normal file
190
docs/make.bat
Normal file
|
@ -0,0 +1,190 @@
|
||||||
|
@ECHO OFF
|
||||||
|
|
||||||
|
REM Command file for Sphinx documentation
|
||||||
|
|
||||||
|
if "%SPHINXBUILD%" == "" (
|
||||||
|
set SPHINXBUILD=sphinx-build
|
||||||
|
)
|
||||||
|
set BUILDDIR=_build
|
||||||
|
set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
|
||||||
|
set I18NSPHINXOPTS=%SPHINXOPTS% .
|
||||||
|
if NOT "%PAPER%" == "" (
|
||||||
|
set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
|
||||||
|
set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%
|
||||||
|
)
|
||||||
|
|
||||||
|
if "%1" == "" goto help
|
||||||
|
|
||||||
|
if "%1" == "help" (
|
||||||
|
:help
|
||||||
|
echo.Please use `make ^<target^>` where ^<target^> is one of
|
||||||
|
echo. html to make standalone HTML files
|
||||||
|
echo. dirhtml to make HTML files named index.html in directories
|
||||||
|
echo. singlehtml to make a single large HTML file
|
||||||
|
echo. pickle to make pickle files
|
||||||
|
echo. json to make JSON files
|
||||||
|
echo. htmlhelp to make HTML files and a HTML help project
|
||||||
|
echo. qthelp to make HTML files and a qthelp project
|
||||||
|
echo. devhelp to make HTML files and a Devhelp project
|
||||||
|
echo. epub to make an epub
|
||||||
|
echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
|
||||||
|
echo. text to make text files
|
||||||
|
echo. man to make manual pages
|
||||||
|
echo. texinfo to make Texinfo files
|
||||||
|
echo. gettext to make PO message catalogs
|
||||||
|
echo. changes to make an overview over all changed/added/deprecated items
|
||||||
|
echo. linkcheck to check all external links for integrity
|
||||||
|
echo. doctest to run all doctests embedded in the documentation if enabled
|
||||||
|
goto end
|
||||||
|
)
|
||||||
|
|
||||||
|
if "%1" == "clean" (
|
||||||
|
for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
|
||||||
|
del /q /s %BUILDDIR%\*
|
||||||
|
goto end
|
||||||
|
)
|
||||||
|
|
||||||
|
if "%1" == "html" (
|
||||||
|
%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
|
||||||
|
if errorlevel 1 exit /b 1
|
||||||
|
echo.
|
||||||
|
echo.Build finished. The HTML pages are in %BUILDDIR%/html.
|
||||||
|
goto end
|
||||||
|
)
|
||||||
|
|
||||||
|
if "%1" == "dirhtml" (
|
||||||
|
%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
|
||||||
|
if errorlevel 1 exit /b 1
|
||||||
|
echo.
|
||||||
|
echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
|
||||||
|
goto end
|
||||||
|
)
|
||||||
|
|
||||||
|
if "%1" == "singlehtml" (
|
||||||
|
%SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
|
||||||
|
if errorlevel 1 exit /b 1
|
||||||
|
echo.
|
||||||
|
echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
|
||||||
|
goto end
|
||||||
|
)
|
||||||
|
|
||||||
|
if "%1" == "pickle" (
|
||||||
|
%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
|
||||||
|
if errorlevel 1 exit /b 1
|
||||||
|
echo.
|
||||||
|
echo.Build finished; now you can process the pickle files.
|
||||||
|
goto end
|
||||||
|
)
|
||||||
|
|
||||||
|
if "%1" == "json" (
|
||||||
|
%SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
|
||||||
|
if errorlevel 1 exit /b 1
|
||||||
|
echo.
|
||||||
|
echo.Build finished; now you can process the JSON files.
|
||||||
|
goto end
|
||||||
|
)
|
||||||
|
|
||||||
|
if "%1" == "htmlhelp" (
|
||||||
|
%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
|
||||||
|
if errorlevel 1 exit /b 1
|
||||||
|
echo.
|
||||||
|
echo.Build finished; now you can run HTML Help Workshop with the ^
|
||||||
|
.hhp project file in %BUILDDIR%/htmlhelp.
|
||||||
|
goto end
|
||||||
|
)
|
||||||
|
|
||||||
|
if "%1" == "qthelp" (
|
||||||
|
%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
|
||||||
|
if errorlevel 1 exit /b 1
|
||||||
|
echo.
|
||||||
|
echo.Build finished; now you can run "qcollectiongenerator" with the ^
|
||||||
|
.qhcp project file in %BUILDDIR%/qthelp, like this:
|
||||||
|
echo.^> qcollectiongenerator %BUILDDIR%\qthelp\Public Health Schweiz.qhcp
|
||||||
|
echo.To view the help file:
|
||||||
|
echo.^> assistant -collectionFile %BUILDDIR%\qthelp\Public Health Schweiz.ghc
|
||||||
|
goto end
|
||||||
|
)
|
||||||
|
|
||||||
|
if "%1" == "devhelp" (
|
||||||
|
%SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
|
||||||
|
if errorlevel 1 exit /b 1
|
||||||
|
echo.
|
||||||
|
echo.Build finished.
|
||||||
|
goto end
|
||||||
|
)
|
||||||
|
|
||||||
|
if "%1" == "epub" (
|
||||||
|
%SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
|
||||||
|
if errorlevel 1 exit /b 1
|
||||||
|
echo.
|
||||||
|
echo.Build finished. The epub file is in %BUILDDIR%/epub.
|
||||||
|
goto end
|
||||||
|
)
|
||||||
|
|
||||||
|
if "%1" == "latex" (
|
||||||
|
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
|
||||||
|
if errorlevel 1 exit /b 1
|
||||||
|
echo.
|
||||||
|
echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
|
||||||
|
goto end
|
||||||
|
)
|
||||||
|
|
||||||
|
if "%1" == "text" (
|
||||||
|
%SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
|
||||||
|
if errorlevel 1 exit /b 1
|
||||||
|
echo.
|
||||||
|
echo.Build finished. The text files are in %BUILDDIR%/text.
|
||||||
|
goto end
|
||||||
|
)
|
||||||
|
|
||||||
|
if "%1" == "man" (
|
||||||
|
%SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
|
||||||
|
if errorlevel 1 exit /b 1
|
||||||
|
echo.
|
||||||
|
echo.Build finished. The manual pages are in %BUILDDIR%/man.
|
||||||
|
goto end
|
||||||
|
)
|
||||||
|
|
||||||
|
if "%1" == "texinfo" (
|
||||||
|
%SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo
|
||||||
|
if errorlevel 1 exit /b 1
|
||||||
|
echo.
|
||||||
|
echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.
|
||||||
|
goto end
|
||||||
|
)
|
||||||
|
|
||||||
|
if "%1" == "gettext" (
|
||||||
|
%SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
|
||||||
|
if errorlevel 1 exit /b 1
|
||||||
|
echo.
|
||||||
|
echo.Build finished. The message catalogs are in %BUILDDIR%/locale.
|
||||||
|
goto end
|
||||||
|
)
|
||||||
|
|
||||||
|
if "%1" == "changes" (
|
||||||
|
%SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
|
||||||
|
if errorlevel 1 exit /b 1
|
||||||
|
echo.
|
||||||
|
echo.The overview file is in %BUILDDIR%/changes.
|
||||||
|
goto end
|
||||||
|
)
|
||||||
|
|
||||||
|
if "%1" == "linkcheck" (
|
||||||
|
%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
|
||||||
|
if errorlevel 1 exit /b 1
|
||||||
|
echo.
|
||||||
|
echo.Link check complete; look for any errors in the above output ^
|
||||||
|
or in %BUILDDIR%/linkcheck/output.txt.
|
||||||
|
goto end
|
||||||
|
)
|
||||||
|
|
||||||
|
if "%1" == "doctest" (
|
||||||
|
%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
|
||||||
|
if errorlevel 1 exit /b 1
|
||||||
|
echo.
|
||||||
|
echo.Testing of doctests in the sources finished, look at the ^
|
||||||
|
results in %BUILDDIR%/doctest/output.txt.
|
||||||
|
goto end
|
||||||
|
)
|
||||||
|
|
||||||
|
:end
|
95
fabfile.py
vendored
Normal file
95
fabfile.py
vendored
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
from fabric.api import *
|
||||||
|
|
||||||
|
|
||||||
|
env.roledefs = {
|
||||||
|
'production': [],
|
||||||
|
'staging': [],
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@roles('production')
|
||||||
|
def deploy_production():
|
||||||
|
# Remove this line when you're happy that this task is correct
|
||||||
|
raise RuntimeError("Please check the fabfile before using it")
|
||||||
|
|
||||||
|
run('git pull')
|
||||||
|
run('pip install -r requirements.txt')
|
||||||
|
run('django-admin migrate --noinput')
|
||||||
|
run('django-admin collectstatic --noinput')
|
||||||
|
run('django-admin compress')
|
||||||
|
|
||||||
|
# 'restart' should be an alias to a script that restarts the web server
|
||||||
|
run('restart')
|
||||||
|
|
||||||
|
|
||||||
|
@roles('staging')
|
||||||
|
def deploy_staging():
|
||||||
|
# Remove this line when you're happy that this task is correct
|
||||||
|
raise RuntimeError("Please check the fabfile before using it")
|
||||||
|
|
||||||
|
run('git pull')
|
||||||
|
run('pip install -r requirements.txt')
|
||||||
|
run('django-admin migrate --noinput')
|
||||||
|
run('django-admin collectstatic --noinput')
|
||||||
|
run('django-admin compress')
|
||||||
|
|
||||||
|
# 'restart' should be an alias to a script that restarts the web server
|
||||||
|
run('restart')
|
||||||
|
|
||||||
|
|
||||||
|
def _pull_data(env_name, remote_db_name, local_db_name, remote_dump_path, local_dump_path):
|
||||||
|
timestamp = datetime.now().strftime('%Y%m%d-%I%M%S')
|
||||||
|
|
||||||
|
filename = '.'.join([env_name, remote_db_name, timestamp, 'sql'])
|
||||||
|
remote_filename = remote_dump_path + filename
|
||||||
|
local_filename = local_dump_path + filename
|
||||||
|
|
||||||
|
params = {
|
||||||
|
'remote_db_name': remote_db_name,
|
||||||
|
'remote_filename': remote_filename,
|
||||||
|
'local_db_name': local_db_name,
|
||||||
|
'local_filename': local_filename,
|
||||||
|
}
|
||||||
|
|
||||||
|
# Dump/download database from server
|
||||||
|
run('pg_dump {remote_db_name} -xOf {remote_filename}'.format(**params))
|
||||||
|
run('gzip {remote_filename}'.format(**params))
|
||||||
|
get('{remote_filename}.gz'.format(**params), '{local_filename}.gz'.format(**params))
|
||||||
|
run('rm {remote_filename}.gz'.format(**params))
|
||||||
|
|
||||||
|
# Load database locally
|
||||||
|
local('gunzip {local_filename}.gz'.format(**params))
|
||||||
|
local('dropdb {local_db_name}'.format(**params))
|
||||||
|
local('createdb {local_db_name}'.format(**params))
|
||||||
|
local('psql {local_db_name} -f {local_filename}'.format(**params))
|
||||||
|
local('rm {local_filename}'.format(**params))
|
||||||
|
|
||||||
|
|
||||||
|
@roles('production')
|
||||||
|
def pull_production_data():
|
||||||
|
# Remove this line when you're happy that this task is correct
|
||||||
|
raise RuntimeError("Please check the fabfile before using it")
|
||||||
|
|
||||||
|
_pull_data(
|
||||||
|
env_name='production',
|
||||||
|
remote_db_name='publichealthschweiz',
|
||||||
|
local_db_name='publichealthschweiz',
|
||||||
|
remote_dump_path='/usr/local/django/publichealthschweiz/tmp/',
|
||||||
|
local_dump_path='/tmp/',
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@roles('staging')
|
||||||
|
def pull_staging_data():
|
||||||
|
# Remove this line when you're happy that this task is correct
|
||||||
|
raise RuntimeError("Please check the fabfile before using it")
|
||||||
|
|
||||||
|
_pull_data(
|
||||||
|
env_name='staging',
|
||||||
|
remote_db_name='publichealthschweiz',
|
||||||
|
local_db_name='publichealthschweiz',
|
||||||
|
remote_dump_path='/usr/local/django/publichealthschweiz/tmp/',
|
||||||
|
local_dump_path='/tmp/',
|
||||||
|
)
|
10
manage.py
Executable file
10
manage.py
Executable file
|
@ -0,0 +1,10 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "publichealthschweiz.settings")
|
||||||
|
|
||||||
|
from django.core.management import execute_from_command_line
|
||||||
|
|
||||||
|
execute_from_command_line(sys.argv)
|
0
publichealthschweiz/__init__.py
Normal file
0
publichealthschweiz/__init__.py
Normal file
0
publichealthschweiz/home/__init__.py
Normal file
0
publichealthschweiz/home/__init__.py
Normal file
24
publichealthschweiz/home/migrations/0001_initial.py
Normal file
24
publichealthschweiz/home/migrations/0001_initial.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('wagtailcore', '__latest__'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='HomePage',
|
||||||
|
fields=[
|
||||||
|
('page_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'abstract': False,
|
||||||
|
},
|
||||||
|
bases=('wagtailcore.page',),
|
||||||
|
),
|
||||||
|
]
|
45
publichealthschweiz/home/migrations/0002_create_homepage.py
Normal file
45
publichealthschweiz/home/migrations/0002_create_homepage.py
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
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
|
||||||
|
Page.objects.get(id=2).delete()
|
||||||
|
|
||||||
|
# Create content type for homepage model
|
||||||
|
homepage_content_type, created = ContentType.objects.get_or_create(
|
||||||
|
model='homepage', app_label='home')
|
||||||
|
|
||||||
|
# Create a new homepage
|
||||||
|
homepage = HomePage.objects.create(
|
||||||
|
title="Homepage",
|
||||||
|
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)
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('home', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RunPython(create_homepage),
|
||||||
|
]
|
0
publichealthschweiz/home/migrations/__init__.py
Normal file
0
publichealthschweiz/home/migrations/__init__.py
Normal file
9
publichealthschweiz/home/models.py
Normal file
9
publichealthschweiz/home/models.py
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
|
from wagtail.wagtailcore.models import Page
|
||||||
|
|
||||||
|
|
||||||
|
class HomePage(Page):
|
||||||
|
pass
|
11
publichealthschweiz/home/templates/home/home_page.html
Normal file
11
publichealthschweiz/home/templates/home/home_page.html
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block body_class %}template-{{ self.get_verbose_name|slugify }}{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h1>Welcome to your new Wagtail site!</h1>
|
||||||
|
|
||||||
|
<p>You can access the admin interface <a href="{% url 'wagtailadmin_home' %}">here</a> (make sure you have run "dj createsuperuser" in the console first).
|
||||||
|
|
||||||
|
<p>If you haven't already given the documentation a read, head over to <a href="http://wagtail.readthedocs.org/">http://wagtail.readthedocs.org</a> to start building on Wagtail</p>
|
||||||
|
{% endblock %}
|
0
publichealthschweiz/search/__init__.py
Normal file
0
publichealthschweiz/search/__init__.py
Normal file
50
publichealthschweiz/search/templates/search/search.html
Normal file
50
publichealthschweiz/search/templates/search/search.html
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
{% load static wagtailcore_tags wagtailsearchpromotions_tags %}
|
||||||
|
|
||||||
|
{% block body_class %}template-searchresults{% endblock %}
|
||||||
|
|
||||||
|
{% block title %}Search{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h1>Search</h1>
|
||||||
|
|
||||||
|
<form action="{% url 'search' %}" method="get">
|
||||||
|
<input type="text" name="query"{% if search_query %} value="{{ search_query }}{% endif %}">
|
||||||
|
<input type="submit" value="Search">
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{% get_search_promotions search_query as search_picks %}
|
||||||
|
{% if search_picks %}
|
||||||
|
<ul>
|
||||||
|
{% for pick in search_picks %}
|
||||||
|
<li>
|
||||||
|
<h2><a href="{{ pick.page.url }}">{{ pick.page }}</a></h2>
|
||||||
|
<p>{{ pick.description }}</p>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if search_results %}
|
||||||
|
<ul>
|
||||||
|
{% for result in search_results %}
|
||||||
|
<li>
|
||||||
|
<h4><a href="{% pageurl result %}">{{ result }}</a></h4>
|
||||||
|
{% if result.search_description %}
|
||||||
|
{{ result.search_description|safe }}
|
||||||
|
{% endif %}
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
{% if search_results.has_previous %}
|
||||||
|
<a href="{% url 'search' %}?query={{ search_query|urlencode }}&page={{ search_results.previous_page_number }}">Previous</a>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if search_results.has_next %}
|
||||||
|
<a href="{% url 'search' %}?query={{ search_query|urlencode }}&page={{ search_results.next_page_number }}">Next</a>
|
||||||
|
{% endif %}
|
||||||
|
{% elif search_query %}
|
||||||
|
No results found
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
34
publichealthschweiz/search/views.py
Normal file
34
publichealthschweiz/search/views.py
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
from django.shortcuts import render
|
||||||
|
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
|
||||||
|
|
||||||
|
from wagtail.wagtailcore.models import Page
|
||||||
|
from wagtail.wagtailsearch.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 render(request, 'search/search.html', {
|
||||||
|
'search_query': search_query,
|
||||||
|
'search_results': search_results,
|
||||||
|
})
|
1
publichealthschweiz/settings/.gitignore
vendored
Normal file
1
publichealthschweiz/settings/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/local.py
|
1
publichealthschweiz/settings/__init__.py
Normal file
1
publichealthschweiz/settings/__init__.py
Normal file
|
@ -0,0 +1 @@
|
||||||
|
from .dev import *
|
189
publichealthschweiz/settings/base.py
Normal file
189
publichealthschweiz/settings/base.py
Normal file
|
@ -0,0 +1,189 @@
|
||||||
|
"""
|
||||||
|
Django settings for publichealthschweiz project.
|
||||||
|
|
||||||
|
Generated by 'django-admin startproject' using Django 1.8.2.
|
||||||
|
|
||||||
|
For more information on this file, see
|
||||||
|
https://docs.djangoproject.com/en/1.8/topics/settings/
|
||||||
|
|
||||||
|
For the full list of settings and their values, see
|
||||||
|
https://docs.djangoproject.com/en/1.8/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/1.8/howto/deployment/checklist/
|
||||||
|
|
||||||
|
|
||||||
|
# Application definition
|
||||||
|
|
||||||
|
INSTALLED_APPS = [
|
||||||
|
'publichealthschweiz.home',
|
||||||
|
'publichealthschweiz.search',
|
||||||
|
|
||||||
|
'wagtail.contrib.wagtailsearchpromotions',
|
||||||
|
'wagtail.wagtailforms',
|
||||||
|
'wagtail.wagtailredirects',
|
||||||
|
'wagtail.wagtailembeds',
|
||||||
|
'wagtail.wagtailsites',
|
||||||
|
'wagtail.wagtailusers',
|
||||||
|
'wagtail.wagtailsnippets',
|
||||||
|
'wagtail.wagtaildocs',
|
||||||
|
'wagtail.wagtailimages',
|
||||||
|
'wagtail.wagtailsearch',
|
||||||
|
'wagtail.wagtailadmin',
|
||||||
|
'wagtail.wagtailcore',
|
||||||
|
|
||||||
|
'modelcluster',
|
||||||
|
'compressor',
|
||||||
|
'taggit',
|
||||||
|
|
||||||
|
'django.contrib.admin',
|
||||||
|
'django.contrib.auth',
|
||||||
|
'django.contrib.contenttypes',
|
||||||
|
'django.contrib.sessions',
|
||||||
|
'django.contrib.messages',
|
||||||
|
'django.contrib.staticfiles',
|
||||||
|
]
|
||||||
|
|
||||||
|
MIDDLEWARE_CLASSES = [
|
||||||
|
'django.middleware.security.SecurityMiddleware',
|
||||||
|
'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',
|
||||||
|
|
||||||
|
'wagtail.wagtailcore.middleware.SiteMiddleware',
|
||||||
|
'wagtail.wagtailredirects.middleware.RedirectMiddleware',
|
||||||
|
]
|
||||||
|
|
||||||
|
ROOT_URLCONF = 'publichealthschweiz.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 = 'publichealthschweiz.wsgi.application'
|
||||||
|
|
||||||
|
|
||||||
|
# Database
|
||||||
|
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
|
||||||
|
|
||||||
|
DATABASES = {
|
||||||
|
'default': {
|
||||||
|
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||||
|
'NAME': 'publichealthschweiz',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Password validation
|
||||||
|
# https://docs.djangoproject.com/en/1.9/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/1.8/topics/i18n/
|
||||||
|
|
||||||
|
LANGUAGE_CODE = 'en-gb'
|
||||||
|
|
||||||
|
TIME_ZONE = 'Europe/London'
|
||||||
|
|
||||||
|
USE_I18N = True
|
||||||
|
|
||||||
|
USE_L10N = True
|
||||||
|
|
||||||
|
USE_TZ = True
|
||||||
|
|
||||||
|
|
||||||
|
# Static files (CSS, JavaScript, Images)
|
||||||
|
# https://docs.djangoproject.com/en/1.8/howto/static-files/
|
||||||
|
|
||||||
|
STATICFILES_FINDERS = [
|
||||||
|
'django.contrib.staticfiles.finders.FileSystemFinder',
|
||||||
|
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
||||||
|
'compressor.finders.CompressorFinder',
|
||||||
|
]
|
||||||
|
|
||||||
|
STATICFILES_DIRS = [
|
||||||
|
os.path.join(PROJECT_DIR, 'static'),
|
||||||
|
]
|
||||||
|
|
||||||
|
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
|
||||||
|
STATIC_URL = '/static/'
|
||||||
|
|
||||||
|
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
|
||||||
|
MEDIA_URL = '/media/'
|
||||||
|
|
||||||
|
|
||||||
|
# Django compressor settings
|
||||||
|
# http://django-compressor.readthedocs.org/en/latest/settings/
|
||||||
|
|
||||||
|
COMPRESS_PRECOMPILERS = [
|
||||||
|
('text/x-scss', 'django_libsass.SassCompiler'),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
# Use Redis as the cache backend for extra performance
|
||||||
|
|
||||||
|
CACHES = {
|
||||||
|
'default': {
|
||||||
|
'BACKEND': 'django_redis.cache.RedisCache',
|
||||||
|
'LOCATION': '127.0.0.1:6379',
|
||||||
|
'KEY_PREFIX': 'publichealthschweiz',
|
||||||
|
'OPTIONS': {
|
||||||
|
'CLIENT_CLASS': 'django_redis.client.DefaultClient',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Use Elasticsearch as the search backend for extra performance and better search results
|
||||||
|
|
||||||
|
WAGTAILSEARCH_BACKENDS = {
|
||||||
|
'default': {
|
||||||
|
'BACKEND': 'wagtail.wagtailsearch.backends.elasticsearch.ElasticSearch',
|
||||||
|
'INDEX': 'publichealthschweiz',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Wagtail settings
|
||||||
|
|
||||||
|
WAGTAIL_SITE_NAME = "Public Health Schweiz"
|
21
publichealthschweiz/settings/dev.py
Normal file
21
publichealthschweiz/settings/dev.py
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
from .base import *
|
||||||
|
|
||||||
|
|
||||||
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
|
DEBUG = True
|
||||||
|
TEMPLATES[0]['OPTIONS']['debug'] = True
|
||||||
|
|
||||||
|
# SECURITY WARNING: keep the secret key used in production secret!
|
||||||
|
SECRET_KEY = 'CHANGEME!!!'
|
||||||
|
|
||||||
|
INTERNAL_IPS = ('127.0.0.1', '10.0.2.2')
|
||||||
|
|
||||||
|
BASE_URL = 'http://localhost:8000'
|
||||||
|
|
||||||
|
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
from .local import *
|
||||||
|
except ImportError:
|
||||||
|
pass
|
217
publichealthschweiz/settings/production.py
Normal file
217
publichealthschweiz/settings/production.py
Normal file
|
@ -0,0 +1,217 @@
|
||||||
|
import os
|
||||||
|
import dj_database_url
|
||||||
|
|
||||||
|
from .base import *
|
||||||
|
|
||||||
|
# Do not set SECRET_KEY, Postgres or LDAP password or any other sensitive data here.
|
||||||
|
# Instead, use environment variables or create a local.py file on the server.
|
||||||
|
|
||||||
|
# Disable debug mode
|
||||||
|
DEBUG = False
|
||||||
|
TEMPLATES[0]['OPTIONS']['debug'] = False
|
||||||
|
|
||||||
|
|
||||||
|
# Compress static files offline and minify CSS
|
||||||
|
# http://django-compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_OFFLINE
|
||||||
|
COMPRESS_OFFLINE = True
|
||||||
|
COMPRESS_CSS_FILTERS = [
|
||||||
|
'compressor.filters.css_default.CssAbsoluteFilter',
|
||||||
|
'compressor.filters.cssmin.CSSMinFilter',
|
||||||
|
]
|
||||||
|
COMPRESS_CSS_HASHING_METHOD = 'content'
|
||||||
|
|
||||||
|
|
||||||
|
# Configuration from environment variables
|
||||||
|
# Alternatively, you can set these in a local.py file on the server
|
||||||
|
|
||||||
|
env = os.environ.copy()
|
||||||
|
|
||||||
|
# On Torchbox servers, many environment variables are prefixed with "CFG_"
|
||||||
|
for key, value in os.environ.items():
|
||||||
|
if key.startswith('CFG_'):
|
||||||
|
env[key[4:]] = value
|
||||||
|
|
||||||
|
|
||||||
|
# Basic configuration
|
||||||
|
|
||||||
|
APP_NAME = env.get('APP_NAME', 'publichealthschweiz')
|
||||||
|
|
||||||
|
if 'SECRET_KEY' in env:
|
||||||
|
SECRET_KEY = env['SECRET_KEY']
|
||||||
|
|
||||||
|
if 'ALLOWED_HOSTS' in env:
|
||||||
|
ALLOWED_HOSTS = env['ALLOWED_HOSTS'].split(',')
|
||||||
|
|
||||||
|
if 'PRIMARY_HOST' in env:
|
||||||
|
BASE_URL = 'http://%s/' % env['PRIMARY_HOST']
|
||||||
|
|
||||||
|
if 'SERVER_EMAIL' in env:
|
||||||
|
SERVER_EMAIL = env['SERVER_EMAIL']
|
||||||
|
|
||||||
|
if 'CACHE_PURGE_URL' in env:
|
||||||
|
INSTALLED_APPS += ( 'wagtail.contrib.wagtailfrontendcache', )
|
||||||
|
WAGTAILFRONTENDCACHE = {
|
||||||
|
'default': {
|
||||||
|
'BACKEND': 'wagtail.contrib.wagtailfrontendcache.backends.HTTPBackend',
|
||||||
|
'LOCATION': env['CACHE_PURGE_URL'],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
if 'STATIC_URL' in env:
|
||||||
|
STATIC_URL = env['STATIC_URL']
|
||||||
|
|
||||||
|
if 'STATIC_DIR' in env:
|
||||||
|
STATIC_ROOT = env['STATIC_DIR']
|
||||||
|
|
||||||
|
if 'MEDIA_URL' in env:
|
||||||
|
MEDIA_URL = env['MEDIA_URL']
|
||||||
|
|
||||||
|
if 'MEDIA_DIR' in env:
|
||||||
|
MEDIA_ROOT = env['MEDIA_DIR']
|
||||||
|
|
||||||
|
|
||||||
|
# Database
|
||||||
|
|
||||||
|
if 'DATABASE_URL' in os.environ:
|
||||||
|
DATABASES = {'default': dj_database_url.config()}
|
||||||
|
|
||||||
|
else:
|
||||||
|
DATABASES = {
|
||||||
|
'default': {
|
||||||
|
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||||
|
'NAME': env.get('PGDATABASE', APP_NAME),
|
||||||
|
'CONN_MAX_AGE': 600, # number of seconds database connections should persist for
|
||||||
|
|
||||||
|
# User, host and port can be configured by the PGUSER, PGHOST and
|
||||||
|
# PGPORT environment variables (these get picked up by libpq).
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Redis
|
||||||
|
# Redis location can either be passed through with REDIS_HOST or REDIS_SOCKET
|
||||||
|
|
||||||
|
if 'REDIS_URL' in env:
|
||||||
|
REDIS_LOCATION = env['REDIS_URL']
|
||||||
|
BROKER_URL = env['REDIS_URL']
|
||||||
|
|
||||||
|
elif 'REDIS_HOST' in env:
|
||||||
|
REDIS_LOCATION = env['REDIS_HOST']
|
||||||
|
BROKER_URL = 'redis://%s' % env['REDIS_HOST']
|
||||||
|
|
||||||
|
elif 'REDIS_SOCKET' in env:
|
||||||
|
REDIS_LOCATION = 'unix://%s' % env['REDIS_SOCKET']
|
||||||
|
BROKER_URL = 'redis+socket://%s' % env['REDIS_SOCKET']
|
||||||
|
|
||||||
|
else:
|
||||||
|
REDIS_LOCATION = None
|
||||||
|
|
||||||
|
|
||||||
|
if REDIS_LOCATION is not None:
|
||||||
|
CACHES = {
|
||||||
|
'default': {
|
||||||
|
'BACKEND': 'django_redis.cache.RedisCache',
|
||||||
|
'LOCATION': REDIS_LOCATION,
|
||||||
|
'KEY_PREFIX': APP_NAME,
|
||||||
|
'OPTIONS': {
|
||||||
|
'CLIENT_CLASS': 'django_redis.client.DefaultClient',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Elasticsearch
|
||||||
|
|
||||||
|
if 'ELASTICSEARCH_URL' in env:
|
||||||
|
WAGTAILSEARCH_BACKENDS = {
|
||||||
|
'default': {
|
||||||
|
'BACKEND': 'wagtail.wagtailsearch.backends.elasticsearch.ElasticSearch',
|
||||||
|
'URLS': [env['ELASTICSEARCH_URL']],
|
||||||
|
'INDEX': APP_NAME,
|
||||||
|
'ATOMIC_REBUILD': True,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Logging
|
||||||
|
|
||||||
|
LOGGING = {
|
||||||
|
'version': 1,
|
||||||
|
'disable_existing_loggers': False,
|
||||||
|
'handlers': {
|
||||||
|
'mail_admins': {
|
||||||
|
'level': 'ERROR',
|
||||||
|
'class': 'django.utils.log.AdminEmailHandler',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'formatters': {
|
||||||
|
'default': {
|
||||||
|
'verbose': '[%(asctime)s] (%(process)d/%(thread)d) %(name)s %(levelname)s: %(message)s'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'loggers': {
|
||||||
|
'publichealthschweiz': {
|
||||||
|
'handlers': [],
|
||||||
|
'level': 'INFO',
|
||||||
|
'propagate': False,
|
||||||
|
'formatter': 'verbose',
|
||||||
|
},
|
||||||
|
'wagtail': {
|
||||||
|
'handlers': [],
|
||||||
|
'level': 'INFO',
|
||||||
|
'propagate': False,
|
||||||
|
'formatter': 'verbose',
|
||||||
|
},
|
||||||
|
'django.request': {
|
||||||
|
'handlers': ['mail_admins'],
|
||||||
|
'level': 'ERROR',
|
||||||
|
'propagate': False,
|
||||||
|
'formatter': 'verbose',
|
||||||
|
},
|
||||||
|
'django.security': {
|
||||||
|
'handlers': ['mail_admins'],
|
||||||
|
'level': 'ERROR',
|
||||||
|
'propagate': False,
|
||||||
|
'formatter': 'verbose',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if 'LOG_DIR' in env:
|
||||||
|
# Public Health Schweiz log
|
||||||
|
LOGGING['handlers']['publichealthschweiz_file'] = {
|
||||||
|
'level': 'INFO',
|
||||||
|
'class': 'cloghandler.ConcurrentRotatingFileHandler',
|
||||||
|
'filename': os.path.join(env['LOG_DIR'], 'publichealthschweiz.log'),
|
||||||
|
'maxBytes': 5242880, # 5MB
|
||||||
|
'backupCount': 5
|
||||||
|
}
|
||||||
|
LOGGING['loggers']['wagtail']['handlers'].append('publichealthschweiz_file')
|
||||||
|
|
||||||
|
# Wagtail log
|
||||||
|
LOGGING['handlers']['wagtail_file'] = {
|
||||||
|
'level': 'INFO',
|
||||||
|
'class': 'cloghandler.ConcurrentRotatingFileHandler',
|
||||||
|
'filename': os.path.join(env['LOG_DIR'], 'wagtail.log'),
|
||||||
|
'maxBytes': 5242880, # 5MB
|
||||||
|
'backupCount': 5
|
||||||
|
}
|
||||||
|
LOGGING['loggers']['wagtail']['handlers'].append('wagtail_file')
|
||||||
|
|
||||||
|
# Error log
|
||||||
|
LOGGING['handlers']['errors_file'] = {
|
||||||
|
'level': 'ERROR',
|
||||||
|
'class': 'cloghandler.ConcurrentRotatingFileHandler',
|
||||||
|
'filename': os.path.join(env['LOG_DIR'], 'error.log'),
|
||||||
|
'maxBytes': 5242880, # 5MB
|
||||||
|
'backupCount': 5
|
||||||
|
}
|
||||||
|
LOGGING['loggers']['django.request']['handlers'].append('errors_file')
|
||||||
|
LOGGING['loggers']['django.security']['handlers'].append('errors_file')
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
from .local import *
|
||||||
|
except ImportError:
|
||||||
|
pass
|
23
publichealthschweiz/static/css/main.scss
Normal file
23
publichealthschweiz/static/css/main.scss
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
/* Responsive image/video classes */
|
||||||
|
.rich-text img {
|
||||||
|
max-width: 100%;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
.richtext-image.left{
|
||||||
|
float:left;
|
||||||
|
}
|
||||||
|
.richtext-image.right{
|
||||||
|
float:right;
|
||||||
|
}
|
||||||
|
.responsive-object {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
.responsive-object iframe,
|
||||||
|
.responsive-object object,
|
||||||
|
.responsive-object embed {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
0
publichealthschweiz/static/js/main.js
Normal file
0
publichealthschweiz/static/js/main.js
Normal file
11
publichealthschweiz/templates/404.html
Normal file
11
publichealthschweiz/templates/404.html
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block title %}404 - 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 %}
|
17
publichealthschweiz/templates/500.html
Normal file
17
publichealthschweiz/templates/500.html
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
|
||||||
|
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
|
||||||
|
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
|
||||||
|
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||||
|
<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>
|
38
publichealthschweiz/templates/base.html
Normal file
38
publichealthschweiz/templates/base.html
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
{% load compress static wagtailuserbar %}
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
|
||||||
|
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
|
||||||
|
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
|
||||||
|
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<title>{% block title %}{% if self.seo_title %}{{ self.seo_title }}{% else %}{{ self.title }}{% endif %}{% endblock %}{% block title_suffix %}{% endblock %}</title>
|
||||||
|
<meta name="description" content="">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
||||||
|
{% compress css %}
|
||||||
|
<link rel="stylesheet" type="text/x-scss" href="{% static 'css/main.scss' %}">
|
||||||
|
{% endcompress %}
|
||||||
|
|
||||||
|
{% block extra_css %}
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body class="{% block body_class %}{% endblock %}">
|
||||||
|
{% wagtailuserbar %}
|
||||||
|
|
||||||
|
{% block content %}{% endblock %}
|
||||||
|
|
||||||
|
{% compress js %}
|
||||||
|
<script type="text/javascript" src="{% static 'js/main.js' %}"></script>
|
||||||
|
{% endcompress %}
|
||||||
|
|
||||||
|
{% block extra_js %}
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
41
publichealthschweiz/urls.py
Normal file
41
publichealthschweiz/urls.py
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
from django.conf.urls import include, url
|
||||||
|
from django.conf import settings
|
||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
from wagtail.wagtailadmin import urls as wagtailadmin_urls
|
||||||
|
from wagtail.wagtaildocs import urls as wagtaildocs_urls
|
||||||
|
from wagtail.wagtailcore import urls as wagtail_urls
|
||||||
|
|
||||||
|
from publichealthschweiz.search import views as search_views
|
||||||
|
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
url(r'^django-admin/', include(admin.site.urls)),
|
||||||
|
|
||||||
|
url(r'^admin/', include(wagtailadmin_urls)),
|
||||||
|
url(r'^documents/', include(wagtaildocs_urls)),
|
||||||
|
|
||||||
|
url(r'^search/$', search_views.search, name='search'),
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
if settings.DEBUG:
|
||||||
|
from django.conf.urls.static import static
|
||||||
|
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
||||||
|
from django.views.generic import TemplateView
|
||||||
|
|
||||||
|
# Serve static and media files from development server
|
||||||
|
urlpatterns += staticfiles_urlpatterns()
|
||||||
|
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||||
|
|
||||||
|
# Add views for testing 404 and 500 templates
|
||||||
|
urlpatterns += [
|
||||||
|
url(r'^test404/$', TemplateView.as_view(template_name='404.html')),
|
||||||
|
url(r'^test500/$', TemplateView.as_view(template_name='500.html')),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
urlpatterns += [
|
||||||
|
url(r'', include(wagtail_urls)),
|
||||||
|
]
|
19
publichealthschweiz/wsgi.py
Normal file
19
publichealthschweiz/wsgi.py
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
"""
|
||||||
|
WSGI config for publichealthschweiz 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/1.8/howto/deployment/wsgi/
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
from whitenoise.django import DjangoWhiteNoise
|
||||||
|
|
||||||
|
from django.core.wsgi import get_wsgi_application
|
||||||
|
|
||||||
|
|
||||||
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "publichealthschweiz.settings.production")
|
||||||
|
|
||||||
|
application = DjangoWhiteNoise(get_wsgi_application())
|
8
readme.md
Normal file
8
readme.md
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
Public Health Schweiz
|
||||||
|
=====================
|
||||||
|
|
||||||
|
sudo apt-get install python3-venv python3-dev
|
||||||
|
pyvenv env
|
||||||
|
. env/bin/activate
|
||||||
|
pip install -U pip
|
||||||
|
pip install -r requirements.txt
|
17
requirements.txt
Normal file
17
requirements.txt
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
Django==1.9.9
|
||||||
|
psycopg2==2.6.1
|
||||||
|
elasticsearch==1.2.0
|
||||||
|
django-redis==4.3.0
|
||||||
|
wagtail==1.5.3
|
||||||
|
django-libsass==0.6
|
||||||
|
libsass==0.8.3
|
||||||
|
Pillow==2.9.0
|
||||||
|
|
||||||
|
# Development tools
|
||||||
|
stellar==0.4.3
|
||||||
|
|
||||||
|
# Production dependencies
|
||||||
|
dj-database-url==0.3.0
|
||||||
|
whitenoise==2.0.4
|
||||||
|
uwsgi==2.0.11.2
|
||||||
|
ConcurrentLogHandler==0.9.1
|
1
runtime.txt
Normal file
1
runtime.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
python-3.5.0
|
6
stellar.yaml
Normal file
6
stellar.yaml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
logging: 30
|
||||||
|
migrate_from_0_3_2: false
|
||||||
|
project_name: publichealthschweiz
|
||||||
|
stellar_url: postgresql+psycopg2:///stellar_data
|
||||||
|
tracked_databases: [publichealthschweiz]
|
||||||
|
url: postgresql+psycopg2:///template1
|
51
vagrant/provision.sh
Executable file
51
vagrant/provision.sh
Executable file
|
@ -0,0 +1,51 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
PROJECT_NAME=$1
|
||||||
|
|
||||||
|
PROJECT_DIR=/vagrant
|
||||||
|
VIRTUALENV_DIR=/home/vagrant/.virtualenvs/$PROJECT_NAME
|
||||||
|
|
||||||
|
PYTHON=$VIRTUALENV_DIR/bin/python
|
||||||
|
PIP=$VIRTUALENV_DIR/bin/pip
|
||||||
|
|
||||||
|
|
||||||
|
# Create database
|
||||||
|
su - vagrant -c "createdb $PROJECT_NAME"
|
||||||
|
|
||||||
|
|
||||||
|
# Virtualenv setup for project
|
||||||
|
su - vagrant -c "virtualenv --python=python3 $VIRTUALENV_DIR"
|
||||||
|
# Replace previous line with this if you are using Python 2
|
||||||
|
# su - vagrant -c "virtualenv --python=python2 $VIRTUALENV_DIR"
|
||||||
|
|
||||||
|
su - vagrant -c "echo $PROJECT_DIR > $VIRTUALENV_DIR/.project"
|
||||||
|
|
||||||
|
|
||||||
|
# Upgrade PIP
|
||||||
|
su - vagrant -c "$PIP install --upgrade pip"
|
||||||
|
|
||||||
|
# Install PIP requirements
|
||||||
|
su - vagrant -c "$PIP install -r $PROJECT_DIR/requirements.txt"
|
||||||
|
|
||||||
|
|
||||||
|
# Set execute permissions on manage.py as they get lost if we build from a zip file
|
||||||
|
chmod a+x $PROJECT_DIR/manage.py
|
||||||
|
|
||||||
|
|
||||||
|
# Run syncdb/migrate/update_index
|
||||||
|
su - vagrant -c "$PYTHON $PROJECT_DIR/manage.py migrate --noinput && \
|
||||||
|
$PYTHON $PROJECT_DIR/manage.py update_index"
|
||||||
|
|
||||||
|
|
||||||
|
# Add a couple of aliases to manage.py into .bashrc
|
||||||
|
cat << EOF >> /home/vagrant/.bashrc
|
||||||
|
export PYTHONPATH=$PROJECT_DIR
|
||||||
|
export DJANGO_SETTINGS_MODULE=$PROJECT_NAME.settings.dev
|
||||||
|
|
||||||
|
alias dj="django-admin.py"
|
||||||
|
alias djrun="dj runserver 0.0.0.0:8000"
|
||||||
|
|
||||||
|
source $VIRTUALENV_DIR/bin/activate
|
||||||
|
export PS1="[$PROJECT_NAME \W]\\$ "
|
||||||
|
cd $PROJECT_DIR
|
||||||
|
EOF
|
Loading…
Reference in a new issue