Navigation and routes

This commit is contained in:
Oleg Lavrovsky 2017-03-07 23:37:55 +01:00
parent df7be31ee7
commit 80c0951a5e
10 changed files with 57 additions and 100 deletions

View file

@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models
@ -37,8 +39,6 @@ class ArticlePage(Page):
'title_fr',
)
date = models.DateField("Date")
intro_de = RichTextField(default='')
intro_fr = RichTextField(default='')
trans_intro = TranslatedField(
@ -61,6 +61,7 @@ class ArticlePage(Page):
'body_fr',
)
date = models.DateField("Date")
feed_image = models.ForeignKey(
'wagtailimages.Image',
null=True,
@ -76,20 +77,24 @@ class ArticlePage(Page):
index.SearchField('title_fr'),
index.SearchField('intro_de'),
index.SearchField('intro_fr'),
index.FilterField('date'),
]
content_panels = Page.content_panels + [
FieldPanel('title_fr'),
FieldPanel('date'),
FieldPanel('intro_de'),
FieldPanel('intro_fr'),
StreamFieldPanel('body_de'),
StreamFieldPanel('body_fr'),
InlinePanel('related_links', label="Related links"),
content_panels = [
MultiFieldPanel([
FieldPanel('title'),
FieldPanel('intro_de'),
StreamFieldPanel('body_de'),
], heading="Deutsch"),
MultiFieldPanel([
FieldPanel('title_fr'),
FieldPanel('intro_fr'),
StreamFieldPanel('body_fr'),
], heading="Français"),
]
promote_panels = [
MultiFieldPanel(Page.promote_panels, "Common page configuration"),
FieldPanel('date'),
ImageChooserPanel('feed_image'),
InlinePanel('related_links', label="Links"),
MultiFieldPanel(Page.promote_panels, "Common page configuration"),
]
parent_page_types = ['home.ArticleIndexPage']
subpage_types = []
@ -138,6 +143,9 @@ class HomePage(Page):
'infos_fr',
)
def get_articles(self):
return ArticleIndexPage.objects.descendant_of(self).live().order_by('-date').select_related('owner')
content_panels = Page.content_panels + [
FieldPanel('intro_de', classname="full"),
FieldPanel('intro_fr', classname="full"),

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,46 +1,17 @@
{% load wagtailcore_tags %}
<!-- Banner -->
<div id="carousel-banner" class="slide">
<!-- Wrapper for slides -->
<div class="carousel-inner slick" role="listbox">
{% for entry in articles %}
<div class="item">
<image style="background-image:url(/static/images/banner_4.jpg)" />
<image style="background-image:url({{ entry.feed_image.src }})" />
<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>
</div>
</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>
</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>
<h3>{{ entry.trans_title }}</h3>
<p>{{ entry.trans_intro|richtext }}</p>
</div>
</div>
{% endfor %}
</div>
</div><!-- /carousel-banner -->
<section id="banner">

View file

@ -4,34 +4,5 @@
{% block body_class %}template-{{ self.get_verbose_name|slugify }}{% endblock %}
{% block content %}
<section id="news-details">
<div class="container">
<div class="image">
{% include_block page.feed_image %}
</div>
<h2>{{ page.trans_title }}</h2>
<p class="lead">{{ page.trans_intro|richtext }}</p>
<p class="date">{{ page.date }}</p>
<!-- 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

@ -1,5 +1,6 @@
{% extends "base.html" %}
{% load wagtailcore_tags %}
{% load wagtailimages_tags %}
{% block body_class %}template-{{ self.get_verbose_name|slugify }}{% endblock %}
@ -8,7 +9,7 @@
<div class="container">
<div class="image">
{% include_block feed_image %}
{% image page.feed_image fill-940x400 class="img-responsive" %}
</div>
<h2>{{ page.trans_title }}</h2>

View file

@ -6,10 +6,13 @@
{% block content %}
{% include 'banner.html' %}
<!-- Banner (articles) -->
{% include 'banner.html' %}
{% include 'news.html' %}
<!-- News -->
{% include 'news.html' %}
<!-- Page body -->
<section>
<div class="container">
<div class="homepage-body">
@ -18,7 +21,7 @@
</div>
</section>
<!-- Three -->
<!-- Infoblocks -->
<section id="three" class="wrapper align-center">
<div class="container">
<div class="row">

View file

@ -1,18 +0,0 @@
<section id="news">
<div class="container">
<div class="row">
{% for entry in articles %}
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="panel panel-default">
{% image entry.feed_image fill-345x260 %}
<div class="panel-body">
<h3><span>{{ entry.trans_title }}</span></h3>
<p>{{ entry.trans_intro|richtext }}</p>
<a href="#" class="btn btn-default btn-xs">Mehr erfahren</a>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
</section>

View file

@ -29,6 +29,7 @@ INSTALLED_APPS = [
'publichealth.search',
'wagtail.contrib.wagtailsearchpromotions',
'wagtail.contrib.wagtailroutablepage',
'wagtail.wagtailforms',
'wagtail.wagtailredirects',
'wagtail.wagtailembeds',

View file

@ -8,7 +8,6 @@
// Modules
@import "modules/modules";
body {
margin-top: 104px;
}
@ -18,7 +17,7 @@ section {
&:nth-child(odd) {
background-color: $gray-lighter;
}
h2 {
text-align: center;
margin-bottom: 1.5em;

View file

@ -77,6 +77,8 @@
// News detail article
#news-details {
background: white;
padding-top: 0;
.category {
margin-top: 2em;
display: inline-block;