commit
c8c20b3fad
8 changed files with 171 additions and 69 deletions
|
@ -0,0 +1,22 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.10.7 on 2017-04-19 16:31
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('wagtailimages', '0018_remove_rendition_filter'),
|
||||
('home', '0012_auto_20170419_1749'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='articleindexpage',
|
||||
name='feed_image',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.Image'),
|
||||
),
|
||||
]
|
|
@ -38,10 +38,18 @@ class ArticleIndexPage(Page):
|
|||
'intro_fr',
|
||||
)
|
||||
|
||||
feed_image = models.ForeignKey(
|
||||
'wagtailimages.Image',
|
||||
null=True, blank=True,
|
||||
on_delete=models.SET_NULL,
|
||||
related_name='+'
|
||||
)
|
||||
|
||||
content_panels = Page.content_panels + [
|
||||
FieldPanel('intro_de'),
|
||||
FieldPanel('title_fr'),
|
||||
FieldPanel('intro_fr'),
|
||||
ImageChooserPanel('feed_image'),
|
||||
]
|
||||
|
||||
def get_context(self, request):
|
||||
|
@ -98,8 +106,7 @@ class ArticlePage(Page):
|
|||
|
||||
feed_image = models.ForeignKey(
|
||||
'wagtailimages.Image',
|
||||
null=True,
|
||||
blank=True,
|
||||
null=True, blank=True,
|
||||
on_delete=models.SET_NULL,
|
||||
related_name='+'
|
||||
)
|
||||
|
|
48
publichealth/home/templates/home/article_content.html
Normal file
48
publichealth/home/templates/home/article_content.html
Normal file
|
@ -0,0 +1,48 @@
|
|||
{% 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>
|
||||
{% elif block.block_type != 'info' %}
|
||||
<p class="block-{{ block.block_type }}">
|
||||
{% include_block block %}
|
||||
</p>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<!-- Infoblocks -->
|
||||
<div class="row">
|
||||
{% for block in page.trans_body %}
|
||||
{% if block.block_type == 'info' %}
|
||||
<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 }}
|
||||
{% if block.value.action %}
|
||||
<footer>
|
||||
<a href="{{ block.value.url }}" class="btn btn-default">{{ block.value.action }}</a>
|
||||
</footer>
|
||||
{% endif %}
|
||||
</article>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
|
@ -1,35 +1,53 @@
|
|||
{% extends "base.html" %}
|
||||
{% load wagtailcore_tags %}
|
||||
{% load wagtailcore_tags wagtailimages_tags %}
|
||||
|
||||
{% block body_class %}template-{{ self.get_verbose_name|slugify }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
{% if articles|length > 1 %}
|
||||
<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>
|
||||
<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>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div><!-- /container -->
|
||||
</div><!-- /container -->
|
||||
</section>
|
||||
|
||||
{% elif articles|length > 0 %}
|
||||
|
||||
<section id="news-details">
|
||||
<div class="container">
|
||||
{% for page in articles %}
|
||||
{% include 'home/page_content.html' %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</section>
|
||||
{% endif %}
|
||||
|
||||
{% if subcategories %}
|
||||
<section id="three" class="article-subcategories" class="wrapper align-center">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
{% for block in subcategories %}
|
||||
<article class="col-md-4">
|
||||
<header><a href="{% pageurl block %}">
|
||||
<h3>{{ block.trans_title }}</h3>
|
||||
</a></header>
|
||||
<a href="{% pageurl block %}">
|
||||
<div class="image">
|
||||
{% image block.feed_image fill-300x300 %}
|
||||
</div>
|
||||
<header>
|
||||
<h3>{{ block.trans_title }}</h3>
|
||||
</header>
|
||||
</a>
|
||||
{{ block.trans_intro|richtext }}
|
||||
</article>
|
||||
{% endfor %}
|
||||
|
|
|
@ -7,54 +7,7 @@
|
|||
<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>
|
||||
{% elif block.block_type != 'info' %}
|
||||
<p class="block-{{ block.block_type }}">
|
||||
{% include_block block %}
|
||||
</p>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<!-- Infoblocks -->
|
||||
<div class="row">
|
||||
{% for block in page.trans_body %}
|
||||
{% if block.block_type == 'info' %}
|
||||
<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 }}
|
||||
{% if block.value.action %}
|
||||
<footer>
|
||||
<a href="{{ block.value.url }}" class="btn btn-default">{{ block.value.action }}</a>
|
||||
</footer>
|
||||
{% endif %}
|
||||
</article>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% include 'home/page_content.html' %}
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
|
50
publichealth/home/templates/home/page_content.html
Normal file
50
publichealth/home/templates/home/page_content.html
Normal file
|
@ -0,0 +1,50 @@
|
|||
{% load wagtailcore_tags wagtailimages_tags %}
|
||||
|
||||
{% 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>
|
||||
{% elif block.block_type != 'info' %}
|
||||
<p class="block-{{ block.block_type }}">
|
||||
{% include_block block %}
|
||||
</p>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<!-- Infoblocks -->
|
||||
<div class="row">
|
||||
{% for block in page.trans_body %}
|
||||
{% if block.block_type == 'info' %}
|
||||
<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 }}
|
||||
{% if block.value.action %}
|
||||
<footer>
|
||||
<a href="{{ block.value.url }}" class="btn btn-default">{{ block.value.action }}</a>
|
||||
</footer>
|
||||
{% endif %}
|
||||
</article>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
|
@ -1,3 +1,3 @@
|
|||
{% for lang in languages %}
|
||||
<a{% if lang.code == currentlangcode %} class="active"{% endif %} href="/{{ lang.code }}">{{ lang.title }}</a>
|
||||
<a{% if lang.code == currentlangcode %} class="active"{% endif %} href="{{ lang.url }}">{{ lang.title }}</a>
|
||||
{% endfor %}
|
||||
|
|
|
@ -7,8 +7,12 @@ register = template.Library()
|
|||
# Language switcher
|
||||
@register.inclusion_tag('tags/language.html', takes_context=True)
|
||||
def language_switcher(context):
|
||||
url = context['page'].url
|
||||
return {
|
||||
'languages': [ { 'code': 'de', 'title': 'De' }, { 'code': 'fr', 'title': 'Fr' } ],
|
||||
'languages': [
|
||||
{ 'code': 'de', 'title': 'De', 'url': url.replace('/fr/','/de/') },
|
||||
{ 'code': 'fr', 'title': 'Fr', 'url': url.replace('/de/','/fr/') }
|
||||
],
|
||||
'currentlangcode': translation.get_language(),
|
||||
'request': context['request'],
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue