commit
7c8f70e4d3
25 changed files with 613 additions and 92 deletions
77
Makefile
Normal file
77
Makefile
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
export COMPOSE_FILE=./docker-compose.yml
|
||||||
|
export COMPOSE_PROJECT_NAME=publichealth
|
||||||
|
|
||||||
|
default: build
|
||||||
|
|
||||||
|
build-cached:
|
||||||
|
docker-compose build
|
||||||
|
|
||||||
|
build:
|
||||||
|
docker-compose build --no-cache
|
||||||
|
|
||||||
|
run:
|
||||||
|
docker-compose stop web # for restart cases, when already running
|
||||||
|
docker-compose up
|
||||||
|
|
||||||
|
run-detached:
|
||||||
|
docker-compose up -d
|
||||||
|
|
||||||
|
django-restart-detached:
|
||||||
|
docker-compose stop web
|
||||||
|
docker-compose up -d web
|
||||||
|
|
||||||
|
stop:
|
||||||
|
docker-compose stop
|
||||||
|
|
||||||
|
migrate:
|
||||||
|
docker-compose exec web ./manage.py migrate
|
||||||
|
|
||||||
|
migrations:
|
||||||
|
docker-compose exec web ./manage.py makemigrations
|
||||||
|
|
||||||
|
apply-migrations: migrations migrate
|
||||||
|
|
||||||
|
setup:
|
||||||
|
docker-compose exec web ./manage.py migrate
|
||||||
|
docker-compose exec web ./manage.py createsuperuser
|
||||||
|
docker-compose exec web ./manage.py compress
|
||||||
|
docker-compose exec web ./manage.py collectstatic
|
||||||
|
|
||||||
|
release:
|
||||||
|
docker-compose stop web
|
||||||
|
docker-compose kill web
|
||||||
|
docker-compose build web
|
||||||
|
docker-compose up -d web
|
||||||
|
|
||||||
|
django-exec-bash:
|
||||||
|
# execute bash in the currently running container
|
||||||
|
docker-compose exec web bash
|
||||||
|
|
||||||
|
django-run-bash:
|
||||||
|
# run new django container, with bash, and remove it after usage
|
||||||
|
docker-compose run --rm --no-deps web bash
|
||||||
|
|
||||||
|
django-shell:
|
||||||
|
docker-compose exec web ./manage.py shell
|
||||||
|
|
||||||
|
logs:
|
||||||
|
docker-compose logs -f --tail=500
|
||||||
|
|
||||||
|
pg-run-detached:
|
||||||
|
# start pg service
|
||||||
|
docker-compose up -d pg_database
|
||||||
|
|
||||||
|
pg-exec:
|
||||||
|
docker-compose exec pg_database bash
|
||||||
|
|
||||||
|
pg-dump:
|
||||||
|
docker-compose exec pg_database bash -c 'pg_dump -U "$$POSTGRES_USER" -d "$$POSTGRES_DB" -f ./dumps/latest.sql'
|
||||||
|
|
||||||
|
pg-restore:
|
||||||
|
docker-compose exec pg_database bash -c 'psql -U "$$POSTGRES_USER" -d "$$POSTGRES_DB" -f ./dumps/latest.sql'
|
||||||
|
|
||||||
|
pg-surefire-drop-restore-db:
|
||||||
|
# drop existing database, recreate it, and then restore its content from backup.
|
||||||
|
-docker-compose exec pg_database bash -c 'dropdb -h localhost -U "$$POSTGRES_USER" "$$POSTGRES_DB"'
|
||||||
|
docker-compose exec pg_database bash -c 'createdb -h localhost -U "$$POSTGRES_USER" "$$POSTGRES_DB"'
|
||||||
|
make pg-restore
|
14
README.md
14
README.md
|
@ -60,14 +60,8 @@ Now access the admin panel with the user account you created earlier: http://loc
|
||||||
|
|
||||||
## Production notes
|
## Production notes
|
||||||
|
|
||||||
We suggest using Docker or [Dokku](http://dokku.viewdocs.io/) for automated deployment.
|
We suggest using Docker or [Dokku](http://dokku.viewdocs.io/) for automated deployment. There is a Makefile to help set up and manage the instance.
|
||||||
|
|
||||||
```
|
- Initial setup: `make setup`
|
||||||
docker-compose run web python manage.py migrate
|
- Startup: `make run-detached`
|
||||||
... createsuperuser
|
- Release: `make release`
|
||||||
... compress
|
|
||||||
... collectstatic
|
|
||||||
|
|
||||||
docker-compose build web
|
|
||||||
docker-compose up -d
|
|
||||||
```
|
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.10.6 on 2017-04-08 14:03
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
import modelcluster.fields
|
||||||
|
import wagtail.wagtailcore.fields
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('home', '0008_auto_20170313_1755'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Contact',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('title', models.CharField(default='', max_length=255)),
|
||||||
|
('title_fr', models.CharField(default='', max_length=255)),
|
||||||
|
('address', models.TextField(blank=True, default='')),
|
||||||
|
('phone', models.CharField(default='', max_length=40)),
|
||||||
|
('email', models.CharField(default='', max_length=40)),
|
||||||
|
('www', models.URLField(blank=True, null=True)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='ContactForm',
|
||||||
|
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')),
|
||||||
|
('to_address', models.CharField(blank=True, help_text='Optional - form submissions will be emailed to these addresses. Separate multiple addresses by comma.', max_length=255, verbose_name='to address')),
|
||||||
|
('from_address', models.CharField(blank=True, max_length=255, verbose_name='from address')),
|
||||||
|
('subject', models.CharField(blank=True, max_length=255, verbose_name='subject')),
|
||||||
|
('title_fr', models.CharField(default=b'', max_length=255)),
|
||||||
|
('intro_de', wagtail.wagtailcore.fields.RichTextField(blank=True, default=b'')),
|
||||||
|
('intro_fr', wagtail.wagtailcore.fields.RichTextField(blank=True, default=b'')),
|
||||||
|
('thanks_de', wagtail.wagtailcore.fields.RichTextField(blank=True, default=b'')),
|
||||||
|
('thanks_fr', wagtail.wagtailcore.fields.RichTextField(blank=True, default=b'')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Formular',
|
||||||
|
},
|
||||||
|
bases=('wagtailcore.page',),
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='ContactFormField',
|
||||||
|
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)),
|
||||||
|
('label', models.CharField(help_text='The label of the form field', max_length=255, verbose_name='label')),
|
||||||
|
('field_type', models.CharField(choices=[('singleline', 'Single line text'), ('multiline', 'Multi-line text'), ('email', 'Email'), ('number', 'Number'), ('url', 'URL'), ('checkbox', 'Checkbox'), ('checkboxes', 'Checkboxes'), ('dropdown', 'Drop down'), ('radio', 'Radio buttons'), ('date', 'Date'), ('datetime', 'Date/time')], max_length=16, verbose_name='field type')),
|
||||||
|
('required', models.BooleanField(default=True, verbose_name='required')),
|
||||||
|
('choices', models.TextField(blank=True, help_text='Comma separated list of choices. Only applicable in checkboxes, radio and dropdown.', verbose_name='choices')),
|
||||||
|
('default_value', models.CharField(blank=True, help_text='Default value. Comma separated values supported for checkboxes.', max_length=255, verbose_name='default value')),
|
||||||
|
('help_text', models.CharField(blank=True, max_length=255, verbose_name='help text')),
|
||||||
|
('page', modelcluster.fields.ParentalKey(on_delete=django.db.models.deletion.CASCADE, related_name='form_fields', to='home.ContactForm')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'ordering': ['sort_order'],
|
||||||
|
'abstract': False,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
|
@ -1,8 +1,8 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Generated by Django 1.10.6 on 2017-04-06 12:49
|
# Generated by Django 1.10.6 on 2017-04-10 21:07
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.db import migrations
|
from django.db import migrations, models
|
||||||
import wagtail.wagtailcore.blocks
|
import wagtail.wagtailcore.blocks
|
||||||
import wagtail.wagtailcore.fields
|
import wagtail.wagtailcore.fields
|
||||||
import wagtail.wagtailimages.blocks
|
import wagtail.wagtailimages.blocks
|
||||||
|
@ -11,10 +11,40 @@ import wagtail.wagtailimages.blocks
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('home', '0008_auto_20170313_1755'),
|
('home', '0009_contact_contactform_contactformfield'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='articlepage',
|
||||||
|
name='on_homepage',
|
||||||
|
field=models.BooleanField(default=False, verbose_name='Auf der Frontpage anzeigen'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='contactform',
|
||||||
|
name='intro_de',
|
||||||
|
field=wagtail.wagtailcore.fields.RichTextField(blank=True, default=''),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='contactform',
|
||||||
|
name='intro_fr',
|
||||||
|
field=wagtail.wagtailcore.fields.RichTextField(blank=True, default=''),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='contactform',
|
||||||
|
name='thanks_de',
|
||||||
|
field=wagtail.wagtailcore.fields.RichTextField(blank=True, default=''),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='contactform',
|
||||||
|
name='thanks_fr',
|
||||||
|
field=wagtail.wagtailcore.fields.RichTextField(blank=True, default=''),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='contactform',
|
||||||
|
name='title_fr',
|
||||||
|
field=models.CharField(default='', max_length=255),
|
||||||
|
),
|
||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name='homepage',
|
model_name='homepage',
|
||||||
name='infos_de',
|
name='infos_de',
|
3
publichealth/home/models/__init__.py
Normal file
3
publichealth/home/models/__init__.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from .forms import *
|
||||||
|
from .models import *
|
||||||
|
from .snippets import *
|
59
publichealth/home/models/forms.py
Normal file
59
publichealth/home/models/forms.py
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from modelcluster.fields import ParentalKey
|
||||||
|
|
||||||
|
from wagtail.wagtailadmin.edit_handlers import (
|
||||||
|
FieldPanel, FieldRowPanel,
|
||||||
|
InlinePanel, MultiFieldPanel
|
||||||
|
)
|
||||||
|
|
||||||
|
from django.db.models import CharField
|
||||||
|
from wagtail.wagtailcore.fields import RichTextField
|
||||||
|
from wagtail.wagtailforms.models import (
|
||||||
|
AbstractEmailForm, AbstractFormField
|
||||||
|
)
|
||||||
|
|
||||||
|
from ..util import TranslatedField
|
||||||
|
|
||||||
|
class ContactFormField(AbstractFormField):
|
||||||
|
page = ParentalKey('ContactForm', related_name='form_fields')
|
||||||
|
|
||||||
|
class ContactForm(AbstractEmailForm):
|
||||||
|
title_fr = CharField(max_length=255, default="")
|
||||||
|
trans_title = TranslatedField(
|
||||||
|
'title',
|
||||||
|
'title_fr',
|
||||||
|
)
|
||||||
|
|
||||||
|
intro_de = RichTextField(default='', blank=True)
|
||||||
|
intro_fr = RichTextField(default='', blank=True)
|
||||||
|
trans_intro = TranslatedField(
|
||||||
|
'intro_de',
|
||||||
|
'intro_fr',
|
||||||
|
)
|
||||||
|
|
||||||
|
thanks_de = RichTextField(default='', blank=True)
|
||||||
|
thanks_fr = RichTextField(default='', blank=True)
|
||||||
|
trans_thanks = TranslatedField(
|
||||||
|
'thanks_de',
|
||||||
|
'thanks_fr',
|
||||||
|
)
|
||||||
|
|
||||||
|
content_panels = AbstractEmailForm.content_panels + [
|
||||||
|
FieldPanel('intro_de', classname="full"),
|
||||||
|
FieldPanel('thanks_de', classname="full"),
|
||||||
|
FieldPanel('title_fr', classname="full"),
|
||||||
|
FieldPanel('intro_fr', classname="full"),
|
||||||
|
FieldPanel('thanks_fr', classname="full"),
|
||||||
|
InlinePanel('form_fields', label="Form fields"),
|
||||||
|
MultiFieldPanel([
|
||||||
|
FieldRowPanel([
|
||||||
|
FieldPanel('from_address', classname="col6"),
|
||||||
|
FieldPanel('to_address', classname="col6"),
|
||||||
|
]),
|
||||||
|
FieldPanel('subject'),
|
||||||
|
], "Email"),
|
||||||
|
]
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
verbose_name = "Formular"
|
|
@ -15,7 +15,7 @@ from wagtail.wagtailsearch import index
|
||||||
|
|
||||||
from puput.models import EntryPage
|
from puput.models import EntryPage
|
||||||
|
|
||||||
from .util import TranslatedField
|
from ..util import TranslatedField
|
||||||
|
|
||||||
class ArticleIndexPage(Page):
|
class ArticleIndexPage(Page):
|
||||||
title_fr = models.CharField(max_length=255, default="")
|
title_fr = models.CharField(max_length=255, default="")
|
||||||
|
@ -77,6 +77,10 @@ class ArticlePage(Page):
|
||||||
)
|
)
|
||||||
|
|
||||||
date = models.DateField("Date", null=True, blank=True)
|
date = models.DateField("Date", null=True, blank=True)
|
||||||
|
|
||||||
|
on_homepage = models.BooleanField(default=False, verbose_name="Featured",
|
||||||
|
help_text="Auf der Frontpage anzeigen")
|
||||||
|
|
||||||
feed_image = models.ForeignKey(
|
feed_image = models.ForeignKey(
|
||||||
'wagtailimages.Image',
|
'wagtailimages.Image',
|
||||||
null=True,
|
null=True,
|
||||||
|
@ -107,9 +111,12 @@ class ArticlePage(Page):
|
||||||
ImageChooserPanel('feed_image'),
|
ImageChooserPanel('feed_image'),
|
||||||
]
|
]
|
||||||
promote_panels = [
|
promote_panels = [
|
||||||
FieldPanel('date'),
|
|
||||||
InlinePanel('related_links', label="Links"),
|
InlinePanel('related_links', label="Links"),
|
||||||
MultiFieldPanel(Page.promote_panels, "Common page configuration"),
|
MultiFieldPanel([
|
||||||
|
FieldPanel('date'),
|
||||||
|
FieldPanel('on_homepage'),
|
||||||
|
], heading="Veröffentlichung"),
|
||||||
|
MultiFieldPanel(Page.promote_panels, "Einstellungen"),
|
||||||
]
|
]
|
||||||
parent_page_types = ['home.ArticleIndexPage']
|
parent_page_types = ['home.ArticleIndexPage']
|
||||||
subpage_types = []
|
subpage_types = []
|
||||||
|
@ -175,6 +182,7 @@ class HomePage(Page):
|
||||||
def featured(self):
|
def featured(self):
|
||||||
# Get list of live pages that are descendants of this page
|
# Get list of live pages that are descendants of this page
|
||||||
articles = ArticlePage.objects.live() #.descendant_of(self)
|
articles = ArticlePage.objects.live() #.descendant_of(self)
|
||||||
|
articles = articles.filter(on_homepage=True)
|
||||||
# Order by most recent date first
|
# Order by most recent date first
|
||||||
#articles = articles.order_by('-date')
|
#articles = articles.order_by('-date')
|
||||||
return articles[:4]
|
return articles[:4]
|
46
publichealth/home/models/snippets.py
Normal file
46
publichealth/home/models/snippets.py
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
|
from wagtail.wagtailsnippets.models import register_snippet
|
||||||
|
|
||||||
|
from wagtail.wagtailcore.models import Page
|
||||||
|
from wagtail.wagtailadmin.edit_handlers import FieldPanel
|
||||||
|
|
||||||
|
from ..util import TranslatedField
|
||||||
|
|
||||||
|
@register_snippet
|
||||||
|
class Contact(models.Model):
|
||||||
|
title = models.CharField(max_length=255, default="")
|
||||||
|
title_fr = models.CharField(max_length=255, default="")
|
||||||
|
trans_title = TranslatedField(
|
||||||
|
'title',
|
||||||
|
'title_fr',
|
||||||
|
)
|
||||||
|
address = models.TextField(default="", blank=True)
|
||||||
|
phone = models.CharField(max_length=40, default="")
|
||||||
|
email = models.CharField(max_length=40, default="")
|
||||||
|
www = models.URLField(null=True, blank=True)
|
||||||
|
|
||||||
|
panels = Page.content_panels + [
|
||||||
|
FieldPanel('title_fr'),
|
||||||
|
FieldPanel('address'),
|
||||||
|
FieldPanel('phone'),
|
||||||
|
FieldPanel('email'),
|
||||||
|
FieldPanel('www'),
|
||||||
|
]
|
||||||
|
|
||||||
|
def phone_link(self):
|
||||||
|
return 'tel:%s' % self.phone.replace(' ', '')
|
||||||
|
def email_link(self):
|
||||||
|
return 'mailto:%s' % self.email
|
||||||
|
def www_domain(self):
|
||||||
|
return self.www.replace('http://', '').replace('https://', '')
|
||||||
|
def trans_title_styled(self):
|
||||||
|
v = self.trans_title.split(' ')
|
||||||
|
if len(v) != 3: return v
|
||||||
|
return "<strong>%s %s</strong> %s" % tuple(v)
|
||||||
|
def __str__(self):
|
||||||
|
return self.trans_title
|
24
publichealth/home/templates/home/contact_form.html
Normal file
24
publichealth/home/templates/home/contact_form.html
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
{% load wagtailcore_tags %}
|
||||||
|
|
||||||
|
{% block body_class %}template-{{ self.get_verbose_name|slugify }}{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<section id="contact-page">
|
||||||
|
<div class="container">
|
||||||
|
|
||||||
|
<h2>{{ page.trans_title }}</h2>
|
||||||
|
|
||||||
|
<p class="lead">{{ page.trans_intro|richtext }}</p>
|
||||||
|
|
||||||
|
<!-- Main content -->
|
||||||
|
<div class="article-body" role="main">
|
||||||
|
<form action="{% pageurl page %}" method="POST">
|
||||||
|
{% csrf_token %}
|
||||||
|
{{ form.as_p }}
|
||||||
|
<button class="btn btn-primary" type="submit">Senden / Envoi</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
{% endblock %}
|
17
publichealth/home/templates/home/contact_form_landing.html
Normal file
17
publichealth/home/templates/home/contact_form_landing.html
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
{% load wagtailcore_tags %}
|
||||||
|
|
||||||
|
{% block body_class %}template-{{ self.get_verbose_name|slugify }}{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<section id="contact-page">
|
||||||
|
<div class="container">
|
||||||
|
|
||||||
|
<h2>{{ page.trans_title }}</h2>
|
||||||
|
|
||||||
|
<center>
|
||||||
|
<p class="lead">{{ page.trans_thanks|richtext }}</p>
|
||||||
|
</center>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
{% endblock %}
|
59
publichealth/home/templates/puput/blog_page.html
Normal file
59
publichealth/home/templates/puput/blog_page.html
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
{% load static i18n wagtailcore_tags wagtailimages_tags puput_tags %}
|
||||||
|
|
||||||
|
{% block body_class %}template-{{ self.get_verbose_name|slugify }}{% endblock %}
|
||||||
|
|
||||||
|
{% block title %}{% if search_term %}{{ search_term }} | {{ blog_page.title }}{% else %}{{ block.super }}{% endif %}{% endblock title %}
|
||||||
|
{% block meta_title %}{% if search_term %}{% trans 'Entries for' %} {{ search_type }} {{ search_term }}{% else %}{{ block.super }}{% endif %}{% endblock meta_title %}
|
||||||
|
{% block meta_description %}{% if search_term %}{% trans 'Entries for' %} {{ search_type }} {{ search_term }}{% else %}{{ block.super }}{% endif %}{% endblock meta_description %}
|
||||||
|
{% block social_share %}
|
||||||
|
{% image blog_page.header_image fill-800x450 as share_image %}
|
||||||
|
<meta property="og:title" content="{{ blog_page.title }}" />
|
||||||
|
<meta property="og:description" content="{{ blog_page.description }}" />
|
||||||
|
<meta property="og:url" content="{% canonical_url %}" />
|
||||||
|
{% if blog_page.header_image %}
|
||||||
|
<meta property="og:image" content="{% image_url share_image.url %}" />
|
||||||
|
<meta property="og:image:width" content="800" />
|
||||||
|
<meta property="og:image:height" content="450" />
|
||||||
|
<meta name="twitter:image" content="{% image_url share_image.url %}" />
|
||||||
|
{% endif %}
|
||||||
|
<meta name="twitter:card" content="summary_large_image" />
|
||||||
|
<meta name="twitter:title" content="{{ blog_page.title }}" />
|
||||||
|
<meta name="twitter:description" content="{{ blog_page.description }}" />
|
||||||
|
{% endblock social_share %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<section id="news-page">
|
||||||
|
{% with per_page=blog_page.num_entries_page %}
|
||||||
|
{# 'paginate' tag cannot render dotted variables, so we need to create a context var #}
|
||||||
|
{% paginate per_page entries %}
|
||||||
|
{% if search_term %}
|
||||||
|
<div class="searchTerm">{% trans 'Entries for' %} {{ search_type }} "{{ search_term }}"</div>
|
||||||
|
{% endif %}
|
||||||
|
{% for entry in entries %}
|
||||||
|
<article class="container page-content">
|
||||||
|
{% include 'puput/entry_page_header.html' %}
|
||||||
|
{% if entry.header_image %}
|
||||||
|
<span class="img-responsive">
|
||||||
|
{% image entry.header_image fill-800x240 as header_image %}
|
||||||
|
<img alt="{{ entry.header_image.title }}" src="{{ header_image.url }}">
|
||||||
|
</span>
|
||||||
|
{% endif %}
|
||||||
|
<div class="article">
|
||||||
|
{% if entry.excerpt %}
|
||||||
|
{{ entry.excerpt|richtext }}
|
||||||
|
{% else %}
|
||||||
|
{{ entry.body|richtext|truncatewords_html:70 }}
|
||||||
|
{% endif %}
|
||||||
|
<a class="blog_btn continue" href="{% pageurl entry %}">{% trans 'Continue reading' %} »</a>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
{% empty %}
|
||||||
|
<span>{% trans 'No results found.' %}</span>
|
||||||
|
{% endfor %}
|
||||||
|
<div class="pagination">
|
||||||
|
{% show_paginator %}
|
||||||
|
</div>
|
||||||
|
{% endwith %}
|
||||||
|
</section>
|
||||||
|
{% endblock content %}
|
36
publichealth/home/templates/puput/entry_page_header.html
Normal file
36
publichealth/home/templates/puput/entry_page_header.html
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
{% load wagtailcore_tags wagtailroutablepage_tags puput_tags %}
|
||||||
|
<header>
|
||||||
|
<h2 class="post_title">
|
||||||
|
<a href="{% pageurl entry %}">{{ entry.title }}</a>
|
||||||
|
</h2>
|
||||||
|
<ul class="links">
|
||||||
|
<li>
|
||||||
|
<i class="fa fa-user"></i>
|
||||||
|
<a href="{% routablepageurl blog_page "entries_by_author" entry.owner.username %}">
|
||||||
|
{{ entry.owner.username }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<i class="fa fa-calendar"></i>
|
||||||
|
{{ entry.date|date:"DATE_FORMAT" }}
|
||||||
|
</li>
|
||||||
|
{% if entry.categories.count > 0 %}
|
||||||
|
<li>
|
||||||
|
<i class="fa fa-folder-open"></i>
|
||||||
|
{% categories_list entry.categories %}
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
{% if entry.tags.count > 0 %}
|
||||||
|
<li>
|
||||||
|
<i class="fa fa-tag"></i>
|
||||||
|
{% tags_list blog_page.num_tags_entry_header entry.tags %}
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
{% if blog_page.disqus_api_secret %}
|
||||||
|
<li>
|
||||||
|
<i class="fa fa-comments"></i>
|
||||||
|
{{ entry.num_comments }}
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
</ul>
|
||||||
|
</header>
|
12
publichealth/home/templates/tags/contact_form.html
Normal file
12
publichealth/home/templates/tags/contact_form.html
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<form action="https://formspree.io/{{ contact.email }}" method="POST">
|
||||||
|
<div class="form-group">
|
||||||
|
<input name="name" id="name" type="text" placeholder="Name / Nom" class="form-control">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<input name="_replyto" id="email" type="email" placeholder="E-Mail" class="form-control">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<textarea name="message" id="message" rows="3" placeholder="" class="form-control"></textarea>
|
||||||
|
</div>
|
||||||
|
<button class="btn btn-primary" type="submit">Senden / Envoi</button>
|
||||||
|
</form>
|
8
publichealth/home/templates/tags/contact_info.html
Normal file
8
publichealth/home/templates/tags/contact_info.html
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<address>
|
||||||
|
<p>{{ contact.trans_title }}<br>
|
||||||
|
{{ contact.address }}
|
||||||
|
</p>
|
||||||
|
<p>Tel. <a href="{{ contact.phone_link }}">{{ contact.phone }}</a><br>
|
||||||
|
<a href="{{ contact.email_link }}">{{ contact.email }}</a><br>
|
||||||
|
<a href="{{ contact.www }}">{{ contact.www_domain }}</a></p>
|
||||||
|
</address>
|
7
publichealth/home/templates/tags/contact_links.html
Normal file
7
publichealth/home/templates/tags/contact_links.html
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<a href="{{ contact.phone_link }}">
|
||||||
|
<span class="glyphicon glyphicon-earphone" aria-hidden="true"></span>
|
||||||
|
<span class="hidden-xs">{{ contact.phone }}</span></a>
|
||||||
|
|
||||||
|
<a href="{{ contact.email_link }}">
|
||||||
|
<span class="glyphicon glyphicon-envelope" aria-hidden="true"></span>
|
||||||
|
<span class="hidden-xs">{{ contact.email }}</span></a>
|
1
publichealth/home/templates/tags/contact_name.html
Normal file
1
publichealth/home/templates/tags/contact_name.html
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{{ contact.trans_title_styled|safe }}
|
35
publichealth/home/templatetags/information.py
Normal file
35
publichealth/home/templatetags/information.py
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from django import template
|
||||||
|
from django.utils import translation
|
||||||
|
|
||||||
|
from ..models.snippets import Contact
|
||||||
|
|
||||||
|
register = template.Library()
|
||||||
|
|
||||||
|
# Contact information (footer)
|
||||||
|
@register.inclusion_tag('tags/contact_info.html')
|
||||||
|
def contact_info():
|
||||||
|
return {
|
||||||
|
'contact': Contact.objects.last(),
|
||||||
|
}
|
||||||
|
|
||||||
|
# Contact form (footer)
|
||||||
|
@register.inclusion_tag('tags/contact_form.html')
|
||||||
|
def contact_form():
|
||||||
|
return {
|
||||||
|
'contact': Contact.objects.last(),
|
||||||
|
}
|
||||||
|
|
||||||
|
# Contact links (header)
|
||||||
|
@register.inclusion_tag('tags/contact_links.html')
|
||||||
|
def contact_links():
|
||||||
|
return {
|
||||||
|
'contact': Contact.objects.last(),
|
||||||
|
}
|
||||||
|
|
||||||
|
# Styled contact name (header)
|
||||||
|
@register.inclusion_tag('tags/contact_name.html')
|
||||||
|
def contact_name():
|
||||||
|
return {
|
||||||
|
'contact': Contact.objects.last(),
|
||||||
|
}
|
|
@ -6,12 +6,16 @@
|
||||||
{% block title %}Search{% endblock %}
|
{% block title %}Search{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>Search</h1>
|
<section id="search-page">
|
||||||
|
<div class="container">
|
||||||
|
<center>
|
||||||
<form action="{% url 'search' %}" method="get">
|
<form action="{% url 'search' %}" method="get">
|
||||||
<input type="text" name="query"{% if search_query %} value="{{ search_query }}{% endif %}">
|
<input type="text" name="query"{% if search_query %} value="{{ search_query }}{% endif %}">
|
||||||
<input type="submit" value="Search">
|
<button type="submit" title="Search">
|
||||||
|
<span class="glyphicon glyphicon-search" aria-hidden="false"></span>
|
||||||
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
</center>
|
||||||
|
|
||||||
{% get_search_promotions search_query as search_picks %}
|
{% get_search_promotions search_query as search_picks %}
|
||||||
{% if search_picks %}
|
{% if search_picks %}
|
||||||
|
@ -38,13 +42,20 @@
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
{% if search_results.has_previous %}
|
{% if search_results.has_previous %}
|
||||||
<a href="{% url 'search' %}?query={{ search_query|urlencode }}&page={{ search_results.previous_page_number }}">Previous</a>
|
<a href="{% url 'search' %}?query={{ search_query|urlencode }}&page={{ search_results.previous_page_number }}">
|
||||||
|
{{ search_results.previous_page_number }}
|
||||||
|
<<</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if search_results.has_next %}
|
{% if search_results.has_next %}
|
||||||
<a href="{% url 'search' %}?query={{ search_query|urlencode }}&page={{ search_results.next_page_number }}">Next</a>
|
<a href="{% url 'search' %}?query={{ search_query|urlencode }}&page={{ search_results.next_page_number }}">
|
||||||
|
>>
|
||||||
|
{{ search_results.next_page_number }}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% elif search_query %}
|
{% elif search_query %}
|
||||||
No results found
|
<b>Leider keine Ergebnisse / Désolé, aucun résultat n'a été trouvé</b>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -163,31 +163,6 @@ COMPRESS_PRECOMPILERS = [
|
||||||
('text/x-scss', 'django_libsass.SassCompiler'),
|
('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': 'publichealth',
|
|
||||||
'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.db',
|
|
||||||
#'BACKEND': 'wagtail.wagtailsearch.backends.elasticsearch.ElasticSearch',
|
|
||||||
'INDEX': 'publichealth',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
# Wagtail settings
|
# Wagtail settings
|
||||||
|
|
||||||
WAGTAIL_SITE_NAME = "Public Health Schweiz"
|
WAGTAIL_SITE_NAME = "Public Health Schweiz"
|
||||||
|
|
|
@ -97,7 +97,19 @@ if 'MAILGUN_KEY' in os.environ:
|
||||||
}
|
}
|
||||||
DEFAULT_FROM_EMAIL = env['MAILGUN_FROM']
|
DEFAULT_FROM_EMAIL = env['MAILGUN_FROM']
|
||||||
|
|
||||||
# Redis
|
# Use Redis as the cache backend for extra performance
|
||||||
|
|
||||||
|
CACHES = {
|
||||||
|
'default': {
|
||||||
|
'BACKEND': 'django_redis.cache.RedisCache',
|
||||||
|
'LOCATION': '127.0.0.1:6379',
|
||||||
|
'KEY_PREFIX': 'publichealth',
|
||||||
|
'OPTIONS': {
|
||||||
|
'CLIENT_CLASS': 'django_redis.client.DefaultClient',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Redis location can either be passed through with REDIS_HOST or REDIS_SOCKET
|
# Redis location can either be passed through with REDIS_HOST or REDIS_SOCKET
|
||||||
|
|
||||||
if 'REDIS_URL' in env:
|
if 'REDIS_URL' in env:
|
||||||
|
@ -128,8 +140,7 @@ if REDIS_LOCATION is not None:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Use Elasticsearch as the search backend for extra performance and better search results
|
||||||
# Elasticsearch
|
|
||||||
|
|
||||||
if 'ELASTICSEARCH_URL' in env:
|
if 'ELASTICSEARCH_URL' in env:
|
||||||
WAGTAILSEARCH_BACKENDS = {
|
WAGTAILSEARCH_BACKENDS = {
|
||||||
|
|
27
publichealth/static/css/modules/_forms.scss
Normal file
27
publichealth/static/css/modules/_forms.scss
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
// Contact page
|
||||||
|
#contact-page {
|
||||||
|
|
||||||
|
form {
|
||||||
|
label {
|
||||||
|
width: 15em;
|
||||||
|
border-bottom: 1px dashed #ccc;
|
||||||
|
line-height: 155%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Footer search form
|
||||||
|
#search-form {
|
||||||
|
|
||||||
|
input {
|
||||||
|
float: left;
|
||||||
|
width: auto;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
button {
|
||||||
|
background: none; border: none;
|
||||||
|
padding-top: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -3,3 +3,4 @@
|
||||||
@import "banner";
|
@import "banner";
|
||||||
@import "footer";
|
@import "footer";
|
||||||
@import "news";
|
@import "news";
|
||||||
|
@import "forms";
|
||||||
|
|
|
@ -8478,6 +8478,7 @@ footer#footer a {
|
||||||
|
|
||||||
#news-details {
|
#news-details {
|
||||||
background: white;
|
background: white;
|
||||||
|
padding-top: 0;
|
||||||
}
|
}
|
||||||
#news-details .category {
|
#news-details .category {
|
||||||
margin-top: 2em;
|
margin-top: 2em;
|
||||||
|
@ -8508,6 +8509,36 @@ footer#footer a {
|
||||||
#news-details .backlink {
|
#news-details .backlink {
|
||||||
margin-top: 3em;
|
margin-top: 3em;
|
||||||
}
|
}
|
||||||
|
#news-details .img-responsive {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
#news-details .links {
|
||||||
|
display: inline-block;
|
||||||
|
border-bottom: 1px solid #999;
|
||||||
|
padding: 1em;
|
||||||
|
margin: 0em;
|
||||||
|
list-style-type: none;
|
||||||
|
}
|
||||||
|
#news-details .links li:first-child {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#contact-page form label {
|
||||||
|
width: 15em;
|
||||||
|
border-bottom: 1px dashed #ccc;
|
||||||
|
line-height: 155%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#search-form input {
|
||||||
|
float: left;
|
||||||
|
width: auto;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
#search-form button {
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
padding-top: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
margin-top: 104px;
|
margin-top: 104px;
|
||||||
|
|
|
@ -1,41 +1,28 @@
|
||||||
{% load wagtailcore_tags navigation %}
|
{% load wagtailcore_tags navigation information %}
|
||||||
{% get_site_root as site_root %}
|
{% get_site_root as site_root %}
|
||||||
|
|
||||||
<!-- Footer -->
|
<!-- Footer -->
|
||||||
<footer id="footer">
|
<footer id="footer">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<!-- Bottom Menu -->
|
<!-- Bottom Menu -->
|
||||||
{% footer_menu parent=site_root calling_page=self %}
|
{% footer_menu parent=site_root calling_page=self %}
|
||||||
</div>
|
|
||||||
<div class="col-md-4" id="contact">
|
<!-- Search form -->
|
||||||
<address>
|
<form action="/search/" method="get" id="search-form">
|
||||||
<p>Public Health Schweiz<br>
|
<input type="text" name="query" value="" class="form-control">
|
||||||
Effingerstrasse 54<br>
|
<button type="submit" title="Search">
|
||||||
Postfach 3420<br>
|
<span class="glyphicon glyphicon-search" aria-hidden="false"></span>
|
||||||
3001 Bern</p>
|
</button>
|
||||||
<p>Tel. +41 31 389 92 86<br>
|
|
||||||
<a href="#">info@public-health.ch</a><br>
|
|
||||||
<a href="#">www.public-health.ch</a></p>
|
|
||||||
</address>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-4">
|
|
||||||
<form action="https://formspree.io/info@datalets.ch" method="POST">
|
|
||||||
<div class="form-group">
|
|
||||||
<input name="name" id="name" type="text" placeholder="Name" class="form-control">
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<input name="_replyto" id="email" type="email" placeholder="E-Mail" class="form-control">
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<textarea name="message" id="message" rows="3" placeholder="Anfrage" class="form-control"></textarea>
|
|
||||||
</div>
|
|
||||||
<button class="btn btn-priamry" type="submit">Senden</button>
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-md-4" id="contact-info">
|
||||||
|
{% contact_info %}
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4" id="contact-form">
|
||||||
|
{% contact_form %}
|
||||||
|
</div>
|
||||||
</div><!-- /row -->
|
</div><!-- /row -->
|
||||||
</div><!-- /container -->
|
</div><!-- /container -->
|
||||||
</footer>
|
</footer>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% load wagtailcore_tags navigation %}
|
{% load wagtailcore_tags navigation information %}
|
||||||
{% get_site_root as site_root %}
|
{% get_site_root as site_root %}
|
||||||
|
|
||||||
<nav class="navbar-pre navbar-fixed-top">
|
<nav class="navbar-pre navbar-fixed-top">
|
||||||
|
@ -6,12 +6,7 @@
|
||||||
<div class="nav">
|
<div class="nav">
|
||||||
<span class="contact-nav">
|
<span class="contact-nav">
|
||||||
<a class="link" href="#contact">Kontakt</a>
|
<a class="link" href="#contact">Kontakt</a>
|
||||||
<a href="tel:+41313899286">
|
{% contact_links %}
|
||||||
<span class="glyphicon glyphicon-earphone" aria-hidden="true"></span>
|
|
||||||
<span class="hidden-xs">+41 31 389 92 86</span></a>
|
|
||||||
<a href="mailto:info@public-health.ch">
|
|
||||||
<span class="glyphicon glyphicon-envelope" aria-hidden="true"></span>
|
|
||||||
<span class="hidden-xs">info@public-health.ch</span></a>
|
|
||||||
</span>
|
</span>
|
||||||
<span class="language-nav">
|
<span class="language-nav">
|
||||||
{% language_switcher %}
|
{% language_switcher %}
|
||||||
|
@ -29,8 +24,9 @@
|
||||||
<span class="icon-bar"></span>
|
<span class="icon-bar"></span>
|
||||||
<span class="icon-bar"></span>
|
<span class="icon-bar"></span>
|
||||||
</button>
|
</button>
|
||||||
<a class="navbar-brand" href="{% pageurl site_root %}"><img src="/static/images/public-health-logo-sign.png" alt="[logo]">
|
<a class="navbar-brand" href="{% pageurl site_root %}">
|
||||||
<span class="hidden-xs"><strong>Public Health</strong> Schweiz</span></a>
|
<img src="/static/images/public-health-logo-sign.png" alt="[logo]">
|
||||||
|
<span class="hidden-xs">{% contact_name %}</span></a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% block menu %}
|
{% block menu %}
|
||||||
|
|
Loading…
Reference in a new issue