From ad930a18b6048593889953598dd57d4612bf3f52 Mon Sep 17 00:00:00 2001 From: Oleg Lavrovsky Date: Wed, 26 Jul 2017 12:42:06 +0200 Subject: [PATCH] News on frontpage --- publichealth/home/models/models.py | 15 ++++++------- publichealth/home/templates/news.html | 25 +++++++++++++++++++++- publichealth/static/css/modules/_news.scss | 6 ++++++ publichealth/templates/500.html | 2 ++ 4 files changed, 39 insertions(+), 9 deletions(-) diff --git a/publichealth/home/models/models.py b/publichealth/home/models/models.py index 7283987..f1b569d 100644 --- a/publichealth/home/models/models.py +++ b/publichealth/home/models/models.py @@ -16,6 +16,8 @@ from wagtail.wagtailimages.edit_handlers import ImageChooserPanel from wagtail.wagtailsearch import index from puput.models import EntryPage, BlogPage +from feedler.models import Entry +from itertools import chain from ..util import TranslatedField @@ -193,11 +195,6 @@ class HomePage(Page): 'infos_fr', ) - # news_home_de = models.ForeignKey( - # 'puput.EntryPage', - # null=True, blank=True, on_delete=models.SET_NULL, - # ) - content_panels = Page.content_panels + [ MultiFieldPanel([ FieldPanel('intro_de', classname="full"), @@ -227,10 +224,12 @@ class HomePage(Page): if not curlang in ['de', 'fr']: curlang = 'de' # Default language parent = BlogPage.objects.filter(slug='news-%s' % curlang) if not parent: return [] - entries = EntryPage.objects.live().descendant_of(parent[0]) + posts = EntryPage.objects.live().descendant_of(parent[0]) # Order by most recent date first - entries = entries.order_by('-date') - return entries[:6] + posts = posts.order_by('-date') + # Get news entries + entries = Entry.objects.all().order_by('-published') + return list(chain(entries[:3], posts[:3])) def get_context(self, request): # Update template context diff --git a/publichealth/home/templates/news.html b/publichealth/home/templates/news.html index 91bbb18..edf9738 100644 --- a/publichealth/home/templates/news.html +++ b/publichealth/home/templates/news.html @@ -1,10 +1,13 @@ {% load wagtailcore_tags wagtailimages_tags puput_tags %} +
{% for entry in blogentries %} -
+ {% if entry.body %} + +
{% if entry.header_image %} {% image entry.header_image fill-360x270 %} @@ -23,6 +26,26 @@
+ {% else %} + +
+ {% if entry.visual %} +
+ + {% else %} +
+ {% endif %} +
+

{{ entry.title|striptags|truncatewords_html:10 }}

+

+ {{ entry.author }}

+ {{ entry.content|striptags|truncatewords_html:25 }} +

+
+ +
+
+ {% endif %} {% empty %} {% endfor %} diff --git a/publichealth/static/css/modules/_news.scss b/publichealth/static/css/modules/_news.scss index b3edf6a..14750fe 100644 --- a/publichealth/static/css/modules/_news.scss +++ b/publichealth/static/css/modules/_news.scss @@ -75,6 +75,12 @@ transform: rotateY(0); } } + + .news-entry .panel-body { + background-color: #f0f0f0; + border: 2px solid rgba(38, 67, 169, 0.8); + *,a { color: black !important; } + } } // News detail article diff --git a/publichealth/templates/500.html b/publichealth/templates/500.html index 3542ce4..c186fc9 100644 --- a/publichealth/templates/500.html +++ b/publichealth/templates/500.html @@ -10,5 +10,7 @@

Internal server error

Sorry, there seems to be an error. Please try again soon.

+ +

In case of persistent issues, write to info@datalets.ch