Merged in theme-alpha (pull request #2)

Theme alpha
This commit is contained in:
Oleg Lavrovsky 2017-03-14 23:37:06 +00:00
commit 7c09af2147
42 changed files with 742 additions and 337 deletions

View file

@ -1,33 +0,0 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.4 on 2016-12-09 05:55
from __future__ import unicode_literals
from django.db import migrations, models
import wagtail.wagtailcore.blocks
import wagtail.wagtailcore.fields
import wagtail.wagtailimages.blocks
class Migration(migrations.Migration):
dependencies = [
('home', '0002_create_homepage'),
]
operations = [
migrations.AddField(
model_name='homepage',
name='body_de',
field=wagtail.wagtailcore.fields.StreamField((('heading', wagtail.wagtailcore.blocks.CharBlock(classname='full title')), ('paragraph', wagtail.wagtailcore.blocks.RichTextBlock()), ('image', wagtail.wagtailimages.blocks.ImageChooserBlock())), blank=True, null=True),
),
migrations.AddField(
model_name='homepage',
name='body_fr',
field=wagtail.wagtailcore.fields.StreamField((('heading', wagtail.wagtailcore.blocks.CharBlock(classname='full title')), ('paragraph', wagtail.wagtailcore.blocks.RichTextBlock()), ('image', wagtail.wagtailimages.blocks.ImageChooserBlock())), blank=True, null=True),
),
migrations.AddField(
model_name='homepage',
name='title_fr',
field=models.CharField(default='', max_length=255),
),
]

View file

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-02-21 16:28
# Generated by Django 1.10.5 on 2017-02-23 08:59
from __future__ import unicode_literals
from django.db import migrations, models
@ -13,9 +13,9 @@ import wagtail.wagtailimages.blocks
class Migration(migrations.Migration):
dependencies = [
('wagtailimages', '0016_deprecate_rendition_filter_relation'),
('wagtailcore', '0032_add_bulk_delete_page_permission'),
('home', '0003_auto_20161209_0655'),
('wagtailimages', '0018_remove_rendition_filter'),
('home', '0002_create_homepage'),
]
operations = [
@ -26,7 +26,7 @@ class Migration(migrations.Migration):
('title_fr', models.CharField(default='', max_length=255)),
],
options={
'abstract': False,
'verbose_name': 'Rubrik',
},
bases=('wagtailcore.page',),
),
@ -36,12 +36,14 @@ class Migration(migrations.Migration):
('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')),
('title_fr', models.CharField(default='', max_length=255)),
('date', models.DateField(verbose_name='Date')),
('body_de', wagtail.wagtailcore.fields.StreamField((('heading', wagtail.wagtailcore.blocks.CharBlock(classname='full title')), ('paragraph', wagtail.wagtailcore.blocks.RichTextBlock()), ('image', wagtail.wagtailimages.blocks.ImageChooserBlock())), blank=True, null=True)),
('body_fr', wagtail.wagtailcore.fields.StreamField((('heading', wagtail.wagtailcore.blocks.CharBlock(classname='full title')), ('paragraph', wagtail.wagtailcore.blocks.RichTextBlock()), ('image', wagtail.wagtailimages.blocks.ImageChooserBlock())), blank=True, null=True)),
('intro_de', wagtail.wagtailcore.fields.RichTextField(default='')),
('intro_fr', wagtail.wagtailcore.fields.RichTextField(default='')),
('body_de', wagtail.wagtailcore.fields.StreamField([('paragraph', wagtail.wagtailcore.blocks.RichTextBlock()), ('image', wagtail.wagtailimages.blocks.ImageChooserBlock()), ('section', wagtail.wagtailcore.blocks.CharBlock(classname='full title'))], blank=True, null=True)),
('body_fr', wagtail.wagtailcore.fields.StreamField([('paragraph', wagtail.wagtailcore.blocks.RichTextBlock()), ('image', wagtail.wagtailimages.blocks.ImageChooserBlock()), ('section', wagtail.wagtailcore.blocks.CharBlock(classname='full title'))], blank=True, null=True)),
('feed_image', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.Image')),
],
options={
'abstract': False,
'verbose_name': 'Artikel',
},
bases=('wagtailcore.page',),
),
@ -55,21 +57,29 @@ class Migration(migrations.Migration):
('page', modelcluster.fields.ParentalKey(on_delete=django.db.models.deletion.CASCADE, related_name='related_links', to='home.ArticlePage')),
],
options={
'abstract': False,
'ordering': ['sort_order'],
'abstract': False,
},
),
migrations.RemoveField(
migrations.AddField(
model_name='homepage',
name='body_de',
field=wagtail.wagtailcore.fields.RichTextField(default=''),
),
migrations.RemoveField(
migrations.AddField(
model_name='homepage',
name='body_fr',
field=wagtail.wagtailcore.fields.RichTextField(default=''),
),
migrations.RemoveField(
migrations.AddField(
model_name='homepage',
name='title_fr',
name='infos_de',
field=wagtail.wagtailcore.fields.StreamField([('info', wagtail.wagtailcore.blocks.StructBlock([(b'title', wagtail.wagtailcore.blocks.CharBlock(required=True)), (b'photo', wagtail.wagtailimages.blocks.ImageChooserBlock()), (b'summary', wagtail.wagtailcore.blocks.RichTextBlock(required=True)), (b'action', wagtail.wagtailcore.blocks.CharBlock()), (b'url', wagtail.wagtailcore.blocks.URLBlock())]))], blank=True, null=True),
),
migrations.AddField(
model_name='homepage',
name='infos_fr',
field=wagtail.wagtailcore.fields.StreamField([('info', wagtail.wagtailcore.blocks.StructBlock([(b'title', wagtail.wagtailcore.blocks.CharBlock(required=True)), (b'photo', wagtail.wagtailimages.blocks.ImageChooserBlock()), (b'summary', wagtail.wagtailcore.blocks.RichTextBlock(required=True)), (b'action', wagtail.wagtailcore.blocks.CharBlock()), (b'url', wagtail.wagtailcore.blocks.URLBlock())]))], blank=True, null=True),
),
migrations.AddField(
model_name='homepage',

View file

@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-03-08 19:20
from __future__ import unicode_literals
from django.db import migrations
import wagtail.wagtailcore.fields
class Migration(migrations.Migration):
dependencies = [
('home', '0003_auto_20170223_0959'),
]
operations = [
migrations.RemoveField(
model_name='articlepage',
name='date',
),
migrations.AddField(
model_name='articleindexpage',
name='intro_de',
field=wagtail.wagtailcore.fields.RichTextField(default=''),
),
migrations.AddField(
model_name='articleindexpage',
name='intro_fr',
field=wagtail.wagtailcore.fields.RichTextField(default=''),
),
]

View file

@ -1,38 +0,0 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-02-21 16:48
from __future__ import unicode_literals
from django.db import migrations
import wagtail.wagtailcore.blocks
import wagtail.wagtailcore.fields
import wagtail.wagtailimages.blocks
class Migration(migrations.Migration):
dependencies = [
('home', '0004_auto_20170221_1728'),
]
operations = [
migrations.AddField(
model_name='homepage',
name='body_de',
field=wagtail.wagtailcore.fields.RichTextField(default=''),
),
migrations.AddField(
model_name='homepage',
name='body_fr',
field=wagtail.wagtailcore.fields.RichTextField(default=''),
),
migrations.AddField(
model_name='homepage',
name='infos_de',
field=wagtail.wagtailcore.fields.StreamField((('info', wagtail.wagtailcore.blocks.StructBlock((('title', wagtail.wagtailcore.blocks.CharBlock(required=True)), ('photo', wagtail.wagtailimages.blocks.ImageChooserBlock()), ('summary', wagtail.wagtailcore.blocks.RichTextBlock())))),), blank=True, null=True),
),
migrations.AddField(
model_name='homepage',
name='infos_fr',
field=wagtail.wagtailcore.fields.StreamField((('info', wagtail.wagtailcore.blocks.StructBlock((('title', wagtail.wagtailcore.blocks.CharBlock(required=True)), ('photo', wagtail.wagtailimages.blocks.ImageChooserBlock()), ('summary', wagtail.wagtailcore.blocks.RichTextBlock())))),), blank=True, null=True),
),
]

View file

@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-03-08 19:23
from __future__ import unicode_literals
from django.db import migrations
import wagtail.wagtailcore.fields
class Migration(migrations.Migration):
dependencies = [
('home', '0004_auto_20170308_2020'),
]
operations = [
migrations.AlterField(
model_name='articleindexpage',
name='intro_de',
field=wagtail.wagtailcore.fields.RichTextField(blank=True, default=''),
),
migrations.AlterField(
model_name='articleindexpage',
name='intro_fr',
field=wagtail.wagtailcore.fields.RichTextField(blank=True, default=''),
),
migrations.AlterField(
model_name='articlepage',
name='intro_de',
field=wagtail.wagtailcore.fields.RichTextField(blank=True, default=''),
),
migrations.AlterField(
model_name='articlepage',
name='intro_fr',
field=wagtail.wagtailcore.fields.RichTextField(blank=True, default=''),
),
]

View file

@ -1,28 +0,0 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-02-21 17:11
from __future__ import unicode_literals
from django.db import migrations
import wagtail.wagtailcore.blocks
import wagtail.wagtailcore.fields
import wagtail.wagtailimages.blocks
class Migration(migrations.Migration):
dependencies = [
('home', '0005_auto_20170221_1748'),
]
operations = [
migrations.AlterField(
model_name='homepage',
name='infos_de',
field=wagtail.wagtailcore.fields.StreamField((('info', wagtail.wagtailcore.blocks.StructBlock((('title', wagtail.wagtailcore.blocks.CharBlock(required=True)), ('photo', wagtail.wagtailimages.blocks.ImageChooserBlock()), ('summary', wagtail.wagtailcore.blocks.RichTextBlock()), ('action', wagtail.wagtailcore.blocks.CharBlock(required=True))))),), blank=True, null=True),
),
migrations.AlterField(
model_name='homepage',
name='infos_fr',
field=wagtail.wagtailcore.fields.StreamField((('info', wagtail.wagtailcore.blocks.StructBlock((('title', wagtail.wagtailcore.blocks.CharBlock(required=True)), ('photo', wagtail.wagtailimages.blocks.ImageChooserBlock()), ('summary', wagtail.wagtailcore.blocks.RichTextBlock()), ('action', wagtail.wagtailcore.blocks.CharBlock(required=True))))),), blank=True, null=True),
),
]

View file

@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-03-08 19:25
from __future__ import unicode_literals
from django.db import migrations
import wagtail.wagtailcore.fields
class Migration(migrations.Migration):
dependencies = [
('home', '0005_auto_20170308_2023'),
]
operations = [
migrations.AlterField(
model_name='homepage',
name='body_de',
field=wagtail.wagtailcore.fields.RichTextField(blank=True, default=''),
),
migrations.AlterField(
model_name='homepage',
name='body_fr',
field=wagtail.wagtailcore.fields.RichTextField(blank=True, default=''),
),
]

View file

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-03-08 21:49
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('home', '0006_auto_20170308_2025'),
]
operations = [
migrations.AddField(
model_name='articlepage',
name='date',
field=models.DateField(blank=True, null=True, verbose_name='Date'),
),
]

View file

@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.6 on 2017-03-13 16:55
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('home', '0007_articlepage_date'),
]
operations = [
migrations.AlterModelOptions(
name='homepage',
options={'verbose_name': 'Frontpage'},
),
]

View file

@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models
@ -11,47 +13,70 @@ from wagtail.wagtailimages.blocks import ImageChooserBlock
from wagtail.wagtailimages.edit_handlers import ImageChooserPanel
from wagtail.wagtailsearch import index
from puput.models import EntryPage
from .util import TranslatedField
class ArticleIndexPage(Page):
title_fr = models.CharField(max_length=255, default="")
translated_title = TranslatedField(
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',
)
content_panels = Page.content_panels + [
FieldPanel('intro_de'),
FieldPanel('title_fr'),
FieldPanel('intro_fr'),
]
def get_context(self, request):
context = super(ArticleIndexPage, self).get_context(request)
# Add extra variables and return the updated context
context['article_entries'] = ArticlePage.objects.child_of(self).live()
articles = ArticlePage.objects.child_of(self).live()
context['articles'] = articles
return context
subpage_types = ['home.ArticlePage']
class Meta:
verbose_name = "Rubrik"
class ArticlePage(Page):
title_fr = models.CharField(max_length=255, default="")
translated_title = TranslatedField(
trans_title = TranslatedField(
'title',
'title_fr',
)
date = models.DateField("Date")
intro_de = RichTextField(default='', blank=True)
intro_fr = RichTextField(default='', blank=True)
trans_intro = TranslatedField(
'intro_de',
'intro_fr',
)
body_de = StreamField([
('heading', blocks.CharBlock(classname="full title")),
('paragraph', blocks.RichTextBlock()),
('image', ImageChooserBlock()),
('section', blocks.CharBlock(classname="full title")),
], null=True, blank=True)
body_fr = StreamField([
('heading', blocks.CharBlock(classname="full title")),
('paragraph', blocks.RichTextBlock()),
('image', ImageChooserBlock()),
('section', blocks.CharBlock(classname="full title")),
], null=True, blank=True)
body = TranslatedField(
trans_body = TranslatedField(
'body_de',
'body_fr',
)
date = models.DateField("Date", null=True, blank=True)
feed_image = models.ForeignKey(
'wagtailimages.Image',
null=True,
@ -65,21 +90,31 @@ class ArticlePage(Page):
index.SearchField('body_fr'),
index.SearchField('title'),
index.SearchField('title_fr'),
index.FilterField('date'),
index.SearchField('intro_de'),
index.SearchField('intro_fr'),
]
content_panels = Page.content_panels + [
FieldPanel('title_fr'),
FieldPanel('date'),
content_panels = [
MultiFieldPanel([
FieldPanel('title'),
FieldPanel('intro_de'),
StreamFieldPanel('body_de'),
], heading="Deutsch"),
MultiFieldPanel([
FieldPanel('title_fr'),
FieldPanel('intro_fr'),
StreamFieldPanel('body_fr'),
InlinePanel('related_links', label="Related links"),
], heading="Français"),
ImageChooserPanel('feed_image'),
]
promote_panels = [
FieldPanel('date'),
InlinePanel('related_links', label="Links"),
MultiFieldPanel(Page.promote_panels, "Common page configuration"),
ImageChooserPanel('feed_image'),
]
parent_page_types = ['home.ArticleIndexPage']
subpage_types = []
class Meta:
verbose_name = "Artikel"
class ArticleRelatedLink(Orderable):
page = ParentalKey(ArticlePage, related_name='related_links')
@ -93,21 +128,21 @@ class ArticleRelatedLink(Orderable):
class InfoBlock(blocks.StructBlock):
title = blocks.CharBlock(required=True)
photo = ImageChooserBlock()
summary = blocks.RichTextBlock()
action = blocks.CharBlock(required=True)
url = models.URLField()
summary = blocks.RichTextBlock(required=True)
action = blocks.CharBlock()
url = blocks.URLBlock()
class HomePage(Page):
intro_de = RichTextField(default='')
intro_fr = RichTextField(default='')
intro = TranslatedField(
trans_intro = TranslatedField(
'intro_de',
'intro_fr',
)
body_de = RichTextField(default='')
body_fr = RichTextField(default='')
body = TranslatedField(
body_de = RichTextField(default='', blank=True)
body_fr = RichTextField(default='', blank=True)
trans_body = TranslatedField(
'body_de',
'body_fr',
)
@ -118,16 +153,48 @@ class HomePage(Page):
infos_fr = StreamField([
('info', InfoBlock())
], null=True, blank=True)
infos = TranslatedField(
trans_infos = TranslatedField(
'infos_de',
'infos_fr',
)
content_panels = Page.content_panels + [
MultiFieldPanel([
FieldPanel('intro_de', classname="full"),
FieldPanel('intro_fr', classname="full"),
FieldPanel('body_de', classname="full"),
FieldPanel('body_fr', classname="full"),
StreamFieldPanel('infos_de'),
], heading="Deutsch"),
MultiFieldPanel([
FieldPanel('intro_fr', classname="full"),
FieldPanel('body_fr', classname="full"),
StreamFieldPanel('infos_fr'),
], heading="Français"),
]
@property
def featured(self):
# Get list of live pages that are descendants of this page
articles = ArticlePage.objects.live() #.descendant_of(self)
# Order by most recent date first
#articles = articles.order_by('-date')
return articles[:4]
@property
def newsfeed(self):
# Get list of latest news
# TODO: fetch children of 'News (DE)'
entries = EntryPage.objects.live().descendant_of(self)
# Order by most recent date first
entries = entries.order_by('-date')
return entries[:4]
def get_context(self, request):
# Update template context
context = super(HomePage, self).get_context(request)
context['featured'] = self.featured
context['newsfeed'] = self.newsfeed
return context
parent_page_types = []
class Meta:
verbose_name = "Frontpage"

View file

@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
from datetime import date
from django.utils.dateformat import DateFormat
from django.utils.formats import date_format
from django.utils.translation import ugettext_lazy as _
from django.conf import settings
from wagtail.wagtailcore.models import Page
from wagtail.wagtailsearch.models import Query
from wagtail.contrib.wagtailroutablepage.models import RoutablePageMixin, route
class HomePage(RoutablePageMixin, Page):
@route(r'^$')
def home_page(self, request, *args, **kwargs):
self.articles = self.get_articles()
return Page.serve(self, request, *args, **kwargs)

View file

@ -1,28 +0,0 @@
{% extends "base.html" %}
{% load wagtailcore_tags %}
{% block body_class %}template-{{ self.get_verbose_name|slugify }}{% endblock %}
{% block content %}
<h1>{{ page.translated_title }}</h1>
<small>{{ page.date }}</small>
{% include_block feed_image %}
<!-- Main content -->
<div class="container" role="main">
{% for block in page.body %}
{% if block.block_type == 'heading' %}
<h2>{{ block.value }}</h2>
{% else %}
<section class="block-{{ block.block_type }}">
{% include_block block %}
</section>
{% endif %}
{% endfor %}
</div>
{% endblock %}

View file

@ -1,53 +1,29 @@
{% load wagtailcore_tags %}
{% load wagtailcore_tags wagtailimages_tags %}
<!-- Banner -->
<div id="carousel-banner" class="slide">
<!-- Wrapper for slides -->
<div class="carousel-inner slick" role="listbox">
{% for entry in featured %}
<div class="item">
<image style="background-image:url(/static/images/banner_4.jpg)" />
{% image entry.feed_image original as entry_photo %}
<image style="background-image:url({{ entry_photo.url }})">
<a href="{% pageurl entry %}">
<div class="carousel-caption">
<h3>Mitgliedschaft</h3>
<p>Werden Sie jetzt Mitglied von Public Health Schweiz und profitieren Sie von vielen Vorteilen und Vergünstigungen. Als Mitglied tragen Sie zudem dazu bei, dass sich Public Health Schweiz weiterhin für die Anliegen der Public-Health-Fachleute einsetzen kann.</p>
<p><a class="btn btn-primary" href="#" role="button"><span class="glyphicon glyphicon-heart" aria-hidden="true"></span> Mitglied werden</a></p>
<h3>{{ entry.trans_title }}</h3>
<p>{{ entry.trans_intro|richtext }}</p>
</div>
</a>
</div>
<div class="item">
<image style="background-image:url(/static/images/banner_1.jpg)" />
<div class="carousel-caption">
<h3>Swiss Public Health Conference 15. November 2016 in Bern</h3>
<p>Die Swiss Public Health Conference 2016 ist erfolgreich zu Ende gegangen. Wir bedanken uns bei Ihnen an dieser Stelle für Ihre engagierte Teilnahme und die vielen angeregten Gespräche während der Konferenz.</p>
<p><a class="btn btn-primary" href="#" role="button">Learn more</a></p>
{% empty %}
No articles found
{% endfor %}
</div>
</div>
<div class="item">
<image style="background-image:url(/static/images/banner_0.jpg)" />
<div class="carousel-caption">
<h3>Parlamentarische Gruppe nichtübertragbare Krankheiten NCD gegründet</h3>
<p>Die Ständeräte Hans Stöckli und Joachim Eder sowie die Nationalrätin Ruth Humbel haben die Parlamentarische Gruppe nichtübertragbare Krankheiten NCD gegründet. Ziel ist es, das Thema NCD in der Schweizer Politik nachhaltig zu verankern. </p>
<p><a class="btn btn-primary" href="#" role="button">Learn more</a></p>
</div>
</div>
<div class="item">
<image style="background-image:url(/static/images/banner_2.jpg)" />
<div class="carousel-caption ">
<h3>Wirksamer Schutz der Kinder und Jugendlichen vor Tabakkonsum rückt in weite Ferne </h3>
<p>National- und Ständerat finden, dass die wenigen heute geltenden Einschränkungen für Tabakwerbung genügen. Dabei verkennen sie jedoch, dass die omnipräsente Tabakwerbung insbesondere auf Kinder und Jugendliche einen grossen Einfluss hat und oft
auch auf diese ausgerichtet ist.</p>
<p><a class="btn btn-primary" href="#" role="button">Learn more</a></p>
</div>
</div>
</div>
</div><!-- /carousel-banner -->
<section id="banner">
<div class="container">
<footer class="container">
<p class="lead">
{{ page.intro|richtext }}
{{ page.trans_intro|richtext }}
</p>
</footer>
</div>

View file

@ -0,0 +1,29 @@
{% extends "base.html" %}
{% load wagtailcore_tags %}
{% block body_class %}template-{{ self.get_verbose_name|slugify }}{% endblock %}
{% block content %}
<section id="article-index">
<div class="container">
<h2>{{ page.trans_title }}</h2>
<p class="lead">{{ page.trans_intro|richtext }}</p>
<div class="article-body" role="main">
{% for entry in articles %}
<div class="item">
<div class="article-caption">
<h3><a href="{% pageurl entry %}">{{ entry.trans_title }}</a></h3>
<p>{{ entry.trans_intro|richtext }}</p>
</div>
</div>
{% empty %}
No articles found
{% endfor %}
</div>
</div>
</section>
{% endblock %}

View file

@ -0,0 +1,38 @@
{% extends "base.html" %}
{% load wagtailcore_tags wagtailimages_tags %}
{% block body_class %}template-{{ self.get_verbose_name|slugify }}{% endblock %}
{% block content %}
<section id="news-details">
<div class="container">
{% if page.feed_image %}
<div class="image">
{% image page.feed_image fill-940x400 class="img-responsive" %}
</div>
{% endif %}
<h2>{{ page.trans_title }}</h2>
<p class="lead">{{ page.trans_intro|richtext }}</p>
{% if page.date %}
<p class="date">{{ page.date }}</p>
{% endif %}
<!-- Main content -->
<div class="article-body" role="main">
{% for block in page.trans_body %}
{% if block.block_type == 'heading' %}
<h3>{{ block.value }}</h3>
{% else %}
<p class="block-{{ block.block_type }}">
{% include_block block %}
</p>
{% endif %}
{% endfor %}
</div>
</div>
</section>
{% endblock %}

View file

@ -5,48 +5,22 @@
{% block content %}
{% include 'banner.html' %}
<!-- Banner (articles) -->
{% include 'banner.html' %}
{% include 'news.html' %}
<!-- News -->
{% include 'news.html' %}
<section>
<!-- Page body -->
<section>
<div class="container">
<div class="homepage-body">
{{ page.body|richtext }}
{{ page.trans_body|richtext }}
</div>
</div>
</section>
</section>
<!-- Three -->
<section id="three" class="wrapper align-center">
<div class="container">
<div class="row">
{% for block in page.infos %}
<article class="col-md-4">
<div class="image round">
<img src="{{ block.photo }}" />
</div>
<header>
<h3>{{ block.title }}</h3>
</header>
{{ block.summary|richtext }}
<footer>
<a href="{{ block.url }}" class="btn btn-default">{{ block.action }}</a>
</footer>
</article>
{% endif %}
</div>
</div>
</section>
{% if block.block_type == 'heading' %}
<h2>{{ block.value }}</h2>
{% else %}
<section class="block-{{ block.block_type }}">
{% include_block block %}
</section>
{% endfor %}
</div>
<!-- Infoblocks -->
{% include 'infos.html' %}
{% endblock %}

View file

@ -0,0 +1,22 @@
{% load wagtailcore_tags wagtailimages_tags %}
<section id="three" class="wrapper align-center">
<div class="container">
<div class="row">
{% for block in page.trans_infos %}
<article class="col-md-4">
<div class="image">
{% image block.value.photo fill-300x300 %}
</div>
<header>
<h3>{{ block.value.title }}</h3>
</header>
{{ block.value.summary|richtext }}
<footer>
<a href="{{ block.value.url }}" class="btn btn-default">{{ block.value.action }}</a>
</footer>
</article>
{% endfor %}
</div>
</div>
</section>

View file

@ -1,39 +1,31 @@
{% load wagtailcore_tags wagtailimages_tags puput_tags %}
<section id="news">
<div class="container">
<div class="row">
{% for entry in newsfeed %}
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="panel panel-default">
<img src="/static/images/thumb_news_1.jpg" alt="">
{% if entry.header_image %}
{% image entry.header_image fill-360x270 %}
{% endif %}
<div class="panel-body">
<h3><span>Ehrenmitgliedschaften</span></h3>
<p>Nicole Probst-Hensch, Professorin für Pharmakologie und Epidemiologie am Schweizerischen Tropen- und Public Health Institut der Universität Basel, wurde die Ehrenmitgliedschaft von Public Health Schweiz verliehen.</p>
<a href="/news-details.html" class="btn btn-default btn-xs">Mehr erfahren</a>
<h3><span>{{ entry.title }}</span></h3>
<p>
{% if entry.excerpt %}
{{ entry.excerpt|richtext }}
{% else %}
{{ entry.body|richtext|truncatewords_html:70 }}
{% endif %}
</p>
<a href="{% pageurl entry %}" class="btn btn-default btn-xs">Mehr erfahren</a>
</div>
<a href="/news-details.html" class="fill"></a>
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="panel panel-default">
<img src="/static/images/thumb_news_2.jpg" alt="">
<div class="panel-body">
<h3><span>Parlamentarische Gruppe nichtübertragbare Krankheiten NCD gegründet</span></h3>
<a href="/news-details.html" class="btn btn-default btn-xs">Mehr erfahren</a>
</div>
<a href="/news-details.html" class="fill"></a>
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="panel panel-default">
<div class="img-crop"></div>
<div class="panel-body">
<h3><span>Wirksamer Schutz der Kinder und Jugendlichen vor Tabakkonsum rückt in weite Ferne<span></h3>
<a href="/news-details.html" class="btn btn-default btn-xs">Mehr erfahren</a>
</div>
<a href="/news-details.html" class="fill"></a>
<a href="{% pageurl entry %}" class="fill"></a>
</div>
</div>
{% empty %}
No news today
{% endfor %}
</div>
</div>
</section>

View file

@ -0,0 +1,53 @@
{% extends "base.html" %}
{% load wagtailcore_tags wagtailimages_tags puput_tags %}
{% block body_class %}template-{{ self.get_verbose_name|slugify }}{% endblock %}
{% block title %}{{ self.title }} | {{ blog_page.title }}{% endblock title %}
{% block meta_title %}{% if self.seo_title %}{{ self.seo_title }}{% else %}{{ self.title }}{% endif %}{% endblock meta_title %}
{% block meta_description %}{% if self.search_description %}{{ self.search_description }}{% else %}{{ self.body|striptags|truncatewords:20 }}{% endif %}{% endblock meta_description %}
{% block canonical %}{% canonical_url entry=self %}{% endblock canonical %}
{% block social_share %}
{% image self.header_image fill-800x450 as share_image %}
<meta property="og:title" content="{{ self.title }}" />
<meta property="og:description" content="{% if self.excerpt %}{{ self.excerpt|striptags }}{% else %}{{ self.body|striptags|truncatewords:20 }}{% endif %}" />
<meta property="og:url" content="{% canonical_url entry=self %}" />
{% if self.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="{{ self.title }}" />
<meta name="twitter:description" content="{% if self.excerpt %}{{ self.excerpt|striptags }}{% else %}{{ self.body|striptags|truncatewords:20 }}{% endif %}" />
{% endblock social_share %}
{% block content %}
<section id="news-details">
<article class="container"
{%if self.id %}data-entry-page-update-comments-url="{% url 'entry_page_update_comments' self.id %}{% endif %}">
{% if self.header_image %}
<div class="image">
{% image self.header_image fill-940x300 as header_image %}
<img alt="{{ self.header_image.title }}" src="{{ header_image.url }}" class="img-responsive">
</div>
{% endif %}
{% include 'puput/entry_page_header.html' with entry=self %}
<div class="article-body" role="main">
{{ self.body|richtext}}
</div>
{% show_comments %}
</article>
</section>
{% endblock content %}
{% block extra_content %}
{% if self.has_related %}
{% include 'puput/related_entries.html' with entry=self %}
{% endif %}
{% endblock extra_content %}

View file

@ -0,0 +1,7 @@
{% load navigation wagtailcore_tags %}
<ul class="list-unstyled">
{% for menuitem in menuitems %}
<li><a href="{% pageurl menuitem %}">{{ menuitem.title }}</a></li>
{% endfor %}
</ul>

View file

@ -0,0 +1,3 @@
{% for lang in languages %}
<a{% if lang.code == currentlangcode %} class="active"{% endif %} href="/{{ lang.code }}">{{ lang.title }}</a>
{% endfor %}

View file

@ -0,0 +1,17 @@
{% load navigation wagtailcore_tags %}
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
{% for menuitem in menuitems %}
<li class="{% if menuitem.show_dropdown %}dropdown{% endif %}{% if menuitem.active %} active{% endif %}">
{% if menuitem.show_dropdown %}
<a data-toggle="dropdown" class="dropdown-toggle" href="#">{{ menuitem.title }} <b class="caret"></b></a>
{% top_menu_children parent=menuitem %}
{% else %}
<a href="{% pageurl menuitem %}">{{ menuitem.title }}</a>
{% endif %}
</li>
{% endfor %}
</ul>
</div>
<!-- /.navbar-collapse -->

View file

@ -0,0 +1,8 @@
{% load navigation wagtailcore_tags %}
<ul class="dropdown-menu">
<!--<li><a href="{% pageurl parent %}">{{ parent.title }}</a></li>-->
{% for child in menuitems_children %}
<li><a href="{% pageurl child %}">{{ child.title }}</a></li>
{% endfor %}
</ul>

View file

@ -0,0 +1,62 @@
# -*- coding: utf-8 -*-
from django import template
from django.utils import translation
register = template.Library()
# Language switcher
@register.inclusion_tag('tags/language.html', takes_context=True)
def language_switcher(context):
return {
'languages': [ { 'code': 'de', 'title': 'De' }, { 'code': 'fr', 'title': 'Fr' } ],
'currentlangcode': translation.get_language(),
'request': context['request'],
}
@register.assignment_tag(takes_context=True)
def get_site_root(context):
# NB this returns a core.Page, not the implementation-specific model used
# so object-comparison to self will return false as objects would differ
return context['request'].site.root_page
def has_menu_children(page):
return page.get_children().live().in_menu().exists()
# Retrieves the top menu items
@register.inclusion_tag('tags/top_menu.html', takes_context=True)
def top_menu(context, parent, calling_page=None):
menuitems = parent.get_children().live().in_menu().specific()
for menuitem in menuitems:
menuitem.show_dropdown = has_menu_children(menuitem)
menuitem.active = (calling_page.url.startswith(menuitem.url)
if calling_page else False)
menuitem.title = menuitem.trans_title
return {
'calling_page': calling_page,
'menuitems': menuitems,
'request': context['request'],
}
def menuitems_children(parent):
menuitems_children = parent.get_children().live().in_menu().specific()
for menuitem in menuitems_children:
menuitem.title = menuitem.trans_title
return menuitems_children
# Retrieves the children of the top menu items for the drop downs
@register.inclusion_tag('tags/top_menu_children.html', takes_context=True)
def top_menu_children(context, parent):
return {
'parent': parent,
'menuitems_children': menuitems_children(parent),
'request': context['request'],
}
# Retrieves the footer menu items
@register.inclusion_tag('tags/footer_menu.html', takes_context=True)
def footer_menu(context, parent, calling_page=None):
return {
'calling_page': calling_page,
'menuitems': menuitems_children(parent),
'request': context['request'],
}

View file

@ -10,24 +10,24 @@ For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
"""
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/
# 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 = [
'publichealth.home',
'publichealth.home.templatetags',
'publichealth.search',
'wagtail.contrib.wagtailsearchpromotions',
'wagtail.contrib.wagtailroutablepage',
'wagtail.contrib.wagtailsitemaps',
'wagtail.wagtailforms',
'wagtail.wagtailredirects',
'wagtail.wagtailembeds',
@ -43,6 +43,7 @@ INSTALLED_APPS = [
'modelcluster',
'compressor',
'taggit',
'puput',
'django.contrib.admin',
'django.contrib.auth',
@ -190,3 +191,7 @@ WAGTAILSEARCH_BACKENDS = {
# Wagtail settings
WAGTAIL_SITE_NAME = "Public Health Schweiz"
# Puput settings
PUPUT_AS_PLUGIN = True

View file

@ -8,7 +8,6 @@
// Modules
@import "modules/modules";
body {
margin-top: 104px;
}

View file

@ -77,6 +77,8 @@
// News detail article
#news-details {
background: white;
padding-top: 0;
.category {
margin-top: 2em;
display: inline-block;
@ -106,4 +108,18 @@
.backlink {
margin-top: 3em;
}
.img-responsive {
width: 100%;
}
.links {
display: inline-block;
border-bottom: 1px solid #999;
padding: 1em;
margin: 0em;
list-style-type: none;
li:first-child { display: none; }
}
}

View file

@ -1,21 +1,16 @@
{% load wagtailcore_tags navigation %}
{% get_site_root as site_root %}
<!-- Footer -->
<footer id="footer">
<div class="container">
<div class="row">
<div class="col-md-4">
<ul class="list-unstyled">
<li><a href="#">Über uns</a></li>
<li><a href="#">Mitglied werden</a></li>
<li><a href="#">Veranstaltungen</a></li>
<li><a href="#">Projekte und Aktivitäten</a></li>
<li><a href="#">Information zu Public Health</a></li>
<li><a href="#">Agenda</a></li>
<li><a href="#">...</a></li>
</ul>
<!-- Bottom Menu -->
{% footer_menu parent=site_root calling_page=self %}
</div>
<div class="col-md-4">
<div class="col-md-4" id="contact">
<address>
<p>Public Health Schweiz<br>
Effingerstrasse 54<br>
@ -27,20 +22,18 @@
</address>
</div>
<div class="col-md-4">
<form action="#" method="post">
<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="email" id="email" type="email" placeholder="E-Mail" class="form-control">
<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>
</div>
</div><!-- /row -->
@ -48,5 +41,5 @@
</footer>
<div class="copyright">
&copy; 2016 Public Health Schweiz
&copy; 2017 Public Health Schweiz
</div>

View file

@ -1,14 +1,20 @@
{% load wagtailcore_tags navigation %}
{% get_site_root as site_root %}
<nav class="navbar-pre navbar-fixed-top">
<div class="container">
<div class="nav">
<span class="contact-nav">
<a class="link" href="#">Kontakt</a>
<a href="#"><span class="glyphicon glyphicon-earphone" aria-hidden="true"></span> <span class="hidden-xs">+41 31 389 92 86</span></a>
<a href="#"><span class="glyphicon glyphicon-envelope" aria-hidden="true"></span> <span class="hidden-xs">info@public-health.ch</span></a>
<a class="link" href="#contact">Kontakt</a>
<a href="tel:+41313899286">
<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 class="language-nav">
<a class="active "href="#">De</a>
<a href="#">Fr</a>
{% language_switcher %}
</span>
</div>
</div>
@ -23,37 +29,14 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"><img src="/static/images/public-health-logo-sign.png" alt=""> <span class="hidden-xs"><strong>Public Health</strong> Schweiz</span></a>
<a class="navbar-brand" href="{% pageurl site_root %}"><img src="/static/images/public-health-logo-sign.png" alt="[logo]">
<span class="hidden-xs"><strong>Public Health</strong> Schweiz</span></a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Über uns <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Mitglied werden</a></li>
<li><a href="#">Informationen zu Public Health</a></li>
<li><a href="#">Stellenangebote</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">Migliederversammlung</a></li>
<li><a href="#">Fachrat</a></li>
<li><a href="#">Vorstand</a></li>
<li><a href="#">Fachgruppen</a></li>
<li><a href="#">Geschäftsstelle</a></li>
<li><a href="#">Grundlagedokumente</a></li>
<li><a href="#">Jahresberichte</a></li>
<li><a href="#">Archiv</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">Kontakt</a></li>
</ul>
</li>
<li><a href="#">News</a></li>
<li><a href="#">Agenda</a></li>
<li><a href="#">Projekte</a></li>
</ul>
</div>
<!-- /.navbar-collapse -->
{% block menu %}
<!-- Top Menu -->
{% top_menu parent=site_root calling_page=self %}
{% endblock %}
</div>
<!-- /.container -->
</nav>

View file

@ -6,18 +6,19 @@ from django.conf.urls.i18n import i18n_patterns
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 puput import urls as puput_urls
from publichealth.search import views as search_views
urlpatterns = [
url(r'', include(puput_urls)),
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'),
]

View file

@ -53,3 +53,7 @@ grunt browser-sync
A default browser should open pointing to the default home page.
Now access the admin panel with the user account you created earlier: http://localhost:3000/admin/
## Troubleshooting
- Issues with migrating database tables in SQLite during development? Try `./manage.py migrate --fake`

3
requirements-test.txt Normal file
View file

@ -0,0 +1,3 @@
pytest==3.0.3
pytest-splinter==1.7.6
tox==2.3.1

View file

@ -1,8 +1,9 @@
Django==1.10.5
psycopg2==2.6.2
elasticsearch==5.0.1
wagtail==1.9
puput==0.8
Django==1.10.6
psycopg2==2.7.1
elasticsearch==5.2.0
django-redis==4.7.0
wagtail==1.8
django-libsass==0.7
libsass==0.12.3
Pillow==4.0.0
@ -12,6 +13,6 @@ stellar==0.4.3
# Production dependencies
dj-database-url==0.4.2
whitenoise==3.2.3
whitenoise==3.3.0
uwsgi==2.0.14
ConcurrentLogHandler==0.9.1

0
tests/__init__.py Normal file
View file

10
tests/conftest.py Normal file
View file

@ -0,0 +1,10 @@
import pytest
@pytest.fixture
def site_url(request):
return request.config.getoption("--site-url")
def pytest_addoption(parser):
parser.addoption("--site-url", action="store", default="type1", help="url to test")

View file

View file

@ -0,0 +1,11 @@
hub:
image: selenium/hub
ports:
- "4444:4444"
firefox:
image: selenium/node-firefox
links:
- hub
expose:
- "5555"

BIN
tests/testapp/puput.db Normal file

Binary file not shown.

71
tests/testapp/settings.py Normal file
View file

@ -0,0 +1,71 @@
import os
from puput import PUPUT_APPS
WAGTAIL_SITE_NAME = 'Public Health'
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SECRET_KEY = 'changemepliz'
DEBUG = True
ALLOWED_HOSTS = "*"
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
)
INSTALLED_APPS += PUPUT_APPS
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
'wagtail.wagtailcore.middleware.SiteMiddleware',
'wagtail.wagtailredirects.middleware.RedirectMiddleware',
)
ROOT_URLCONF = 'tests.testapp.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'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 = 'tests.testapp.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'tests/testapp/publichealth.db',
'USER': '',
'PASSWORD': '',
}
}
LANGUAGE_CODE = 'de-ch'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
STATIC_ROOT = '/tmp/static'
STATIC_URL = '/static/'
MEDIA_ROOT = '/tmp/media'
MEDIA_URL = '/media/'

11
tests/testapp/urls.py Normal file
View file

@ -0,0 +1,11 @@
from django.conf import settings
from django.conf.urls import include, url
from django.contrib import admin
from django.conf.urls.static import static
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'', include('publichealth.urls')),
]
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

16
tests/testapp/wsgi.py Normal file
View file

@ -0,0 +1,16 @@
"""
WSGI config for blog project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tests.testapp.settings")
application = get_wsgi_application()