From 47bb70550271898a53eefc6250362799c2976dbd Mon Sep 17 00:00:00 2001 From: Oleg Lavrovsky Date: Thu, 6 Jul 2017 15:51:05 +0200 Subject: [PATCH 01/14] Page not found and 404 templates --- publichealth/settings/base.py | 1 + publichealth/templates/404.html | 30 ++++++++++++++++++--- publichealth/templates/password.html | 39 ++++++++++++++++++++++++++++ requirements.txt | 2 +- 4 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 publichealth/templates/password.html diff --git a/publichealth/settings/base.py b/publichealth/settings/base.py index 13a16c0..b164686 100644 --- a/publichealth/settings/base.py +++ b/publichealth/settings/base.py @@ -127,6 +127,7 @@ AUTH_PASSWORD_VALIDATORS = [ }, ] +PASSWORD_REQUIRED_TEMPLATE = 'password.html' # Internationalization # https://docs.djangoproject.com/en/1.8/topics/i18n/ diff --git a/publichealth/templates/404.html b/publichealth/templates/404.html index c6418c4..e38515d 100644 --- a/publichealth/templates/404.html +++ b/publichealth/templates/404.html @@ -1,11 +1,35 @@ {% extends "base.html" %} -{% block title %}404 - Page not found{% endblock %} +{% block title %}404 - Seite nicht gefunden{% endblock %} {% block body_class %}template-404{% endblock %} {% block content %} -

Page not found

+
+
-

Sorry, this page could not be found.

+

Nicht gefunden/Introuvable

+ +
+ +
+ + +
+ +

+
Diese Seite konnte nicht gefunden werden. Möchten Sie eine Suche starten? +
Désolé, cette page est introuvable. Voulez-vous faire une recherche sur le site? +
Sorry, this page could not be found. Would you like to do a search of the site? +

+ +
+
+
+ + {% endblock %} diff --git a/publichealth/templates/password.html b/publichealth/templates/password.html new file mode 100644 index 0000000..9c49603 --- /dev/null +++ b/publichealth/templates/password.html @@ -0,0 +1,39 @@ +{% extends "base.html" %} + +{% block title %}Password Required{% endblock %} + +{% block body_class %}password-required{% endblock %} + +{% block content %} +
+
+ +

Password requis/erforderlich

+ +
+
+ {% csrf_token %} + + {{ form.non_field_errors }} + +
+ {{ form.password.errors }} + {{ form.password }} +
+ + {% for field in form.hidden_fields %} + {{ field }} + {% endfor %} + +
+ +

+
Sie benötigen ein Passwort, um auf diese Seite zuzugreifen. +
Vous avez besoin d'un mot de passe pour accéder à cette page. +
You need a password to access this page. +

+ +
+
+
+{% endblock %} diff --git a/requirements.txt b/requirements.txt index 2fb4de8..d0a06e8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -# Updated: 30.5.2017 +# Updated: 5.7.2017 # Core wagtail==1.11 From 2fef42bfc28450321091500a772d15d58dba3dc9 Mon Sep 17 00:00:00 2001 From: Oleg Lavrovsky Date: Thu, 6 Jul 2017 15:58:13 +0200 Subject: [PATCH 02/14] Fix feedparser without tags --- feedler/feedparser.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/feedler/feedparser.py b/feedler/feedparser.py index bc39f98..b4d4f7b 100644 --- a/feedler/feedparser.py +++ b/feedler/feedparser.py @@ -49,12 +49,13 @@ def parse(obj, raw, stream): # Collect tags tags = [] - for tag in obj.raw['tags']: - if 'label' in tag: - label = tag['label'].replace(',','-') - label = label.strip().lower() - if len(label) > 3 and not label in tags: - tags.append(label) - obj.tags = ','.join(tags) + if 'tags' in obj.raw: + for tag in obj.raw['tags']: + if 'label' in tag: + label = tag['label'].replace(',','-') + label = label.strip().lower() + if len(label) > 3 and not label in tags: + tags.append(label) + obj.tags = ','.join(tags) return obj From ad930a18b6048593889953598dd57d4612bf3f52 Mon Sep 17 00:00:00 2001 From: Oleg Lavrovsky Date: Wed, 26 Jul 2017 12:42:06 +0200 Subject: [PATCH 03/14] 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

From 71de2a8fc997dbfd3530bf822cc677a073634d4e Mon Sep 17 00:00:00 2001 From: Oleg Lavrovsky Date: Mon, 4 Sep 2017 14:29:06 +0200 Subject: [PATCH 04/14] Updated Wagtail, Django, Puput --- requirements.txt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/requirements.txt b/requirements.txt index d0a06e8..433457f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,15 +1,15 @@ -# Updated: 5.7.2017 +# Updated: 4.9.2017 # Core -wagtail==1.11 -Django==1.11.3 +wagtail==1.12.1 +Django==1.11.4 # Database -psycopg2==2.7.1 +psycopg2==2.7.3.1 dj-database-url==0.4.2 # Addons -puput==0.8 +puput==0.9 # Search elasticsearch>=2.0.0,<3.0.0 @@ -20,7 +20,7 @@ django-redis==4.8.0 # Frontend django-libsass==0.7 libsass==0.13.2 -Pillow==4.2.0 +Pillow==4.2.1 # Development tools stellar==0.4.3 @@ -29,4 +29,4 @@ stellar==0.4.3 gunicorn==19.7.1 whitenoise==3.3.0 ConcurrentLogHandler==0.9.1 -django-anymail==0.10 +django-anymail==0.11.1 From 57e8e0a72f8cbfd6af5e87f905002a9f8f1f16d8 Mon Sep 17 00:00:00 2001 From: Oleg Lavrovsky Date: Mon, 4 Sep 2017 15:30:33 +0200 Subject: [PATCH 05/14] Adjusted frontpage styles --- publichealth/home/models/models.py | 7 +++++- publichealth/home/templates/news.html | 13 +++++------ publichealth/static/css/modules/_news.scss | 25 ++++++++++++++++++---- 3 files changed, 34 insertions(+), 11 deletions(-) diff --git a/publichealth/home/models/models.py b/publichealth/home/models/models.py index f1b569d..8bd5189 100644 --- a/publichealth/home/models/models.py +++ b/publichealth/home/models/models.py @@ -227,15 +227,20 @@ class HomePage(Page): posts = EntryPage.objects.live().descendant_of(parent[0]) # Order by most recent date first posts = posts.order_by('-date') + return posts[:3] + + @property + def newsentries(self): # Get news entries entries = Entry.objects.all().order_by('-published') - return list(chain(entries[:3], posts[:3])) + return entries[:6] def get_context(self, request): # Update template context context = super(HomePage, self).get_context(request) context['featured'] = self.featured context['blogentries'] = self.blogentries + context['newsentries'] = self.newsentries return context parent_page_types = ['wagtailcore.Page'] diff --git a/publichealth/home/templates/news.html b/publichealth/home/templates/news.html index edf9738..e31f305 100644 --- a/publichealth/home/templates/news.html +++ b/publichealth/home/templates/news.html @@ -5,7 +5,6 @@
{% for entry in blogentries %} - {% if entry.body %}
@@ -21,12 +20,16 @@ {{ entry.body|striptags|truncatewords_html:40 }} {% endif %}

- Mehr erfahren + ...
- {% else %} + {% empty %} + + {% endfor %} +

Partner news

+ {% for entry in newsentries %}
{% if entry.visual %} @@ -38,14 +41,12 @@

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

- {{ entry.author }}

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

- {% endif %} {% empty %} {% endfor %} diff --git a/publichealth/static/css/modules/_news.scss b/publichealth/static/css/modules/_news.scss index 14750fe..418cec4 100644 --- a/publichealth/static/css/modules/_news.scss +++ b/publichealth/static/css/modules/_news.scss @@ -76,10 +76,27 @@ } } - .news-entry .panel-body { - background-color: #f0f0f0; - border: 2px solid rgba(38, 67, 169, 0.8); - *,a { color: black !important; } + .news-entry { + height: 8em; + .panel { + background: none; + box-shadow: none; + border: none; + } + .panel-body { + height: 50%; + background-color: #f0f0f0; + border-radius: 4px; + border-top: 3px solid $brand-primary; + // border: 2px solid rgba(38, 67, 169, 0.8); + *,a { color: black !important; } + } + } + + .partner-news { + text-align: center; + margin-top: 2em; + margin-bottom: 1em; } } From 23705a072eeb7cddc1bac50374a923e2ab60f7cc Mon Sep 17 00:00:00 2001 From: Oleg Lavrovsky Date: Mon, 4 Sep 2017 23:02:34 +0200 Subject: [PATCH 06/14] Migrate contact form --- .../migrations/0020_auto_20170904_2233.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 publichealth/home/migrations/0020_auto_20170904_2233.py diff --git a/publichealth/home/migrations/0020_auto_20170904_2233.py b/publichealth/home/migrations/0020_auto_20170904_2233.py new file mode 100644 index 0000000..a96fbe9 --- /dev/null +++ b/publichealth/home/migrations/0020_auto_20170904_2233.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.4 on 2017-09-04 20:33 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('home', '0019_auto_20170703_1244'), + ] + + operations = [ + migrations.AlterField( + model_name='contactformfield', + name='field_type', + field=models.CharField(choices=[('singleline', 'Single line text'), ('multiline', 'Multi-line text'), ('email', 'Email'), ('number', 'Number'), ('url', 'URL'), ('checkbox', 'Checkbox'), ('checkboxes', 'Checkboxes'), ('dropdown', 'Drop down'), ('multiselect', 'Multiple select'), ('radio', 'Radio buttons'), ('date', 'Date'), ('datetime', 'Date/time')], max_length=16, verbose_name='field type'), + ), + ] From 9dbee27a16f2ffeaf0bd6ea7bbe906229b963e47 Mon Sep 17 00:00:00 2001 From: Oleg Lavrovsky Date: Mon, 4 Sep 2017 23:03:01 +0200 Subject: [PATCH 07/14] Multilingual entries --- feedler/feedparser.py | 4 ++++ feedler/migrations/0003_entry_lang.py | 20 ++++++++++++++++++++ feedler/models/admin.py | 2 ++ feedler/models/models.py | 18 +++++++++++++++++- publichealth/home/models/models.py | 8 +++++++- publichealth/settings/base.py | 4 ++++ requirements.txt | 3 ++- 7 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 feedler/migrations/0003_entry_lang.py diff --git a/feedler/feedparser.py b/feedler/feedparser.py index b4d4f7b..8d7f9e0 100644 --- a/feedler/feedparser.py +++ b/feedler/feedparser.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from datetime import datetime +from guess_language import guess_language def parse(obj, raw, stream): """ @@ -47,6 +48,9 @@ def parse(obj, raw, stream): else: obj.content = '' + # Detect language + obj.lang = guess_language(obj.content) or '' + # Collect tags tags = [] if 'tags' in obj.raw: diff --git a/feedler/migrations/0003_entry_lang.py b/feedler/migrations/0003_entry_lang.py new file mode 100644 index 0000000..e27ee89 --- /dev/null +++ b/feedler/migrations/0003_entry_lang.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.4 on 2017-09-04 20:33 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('feedler', '0002_feedpage'), + ] + + operations = [ + migrations.AddField( + model_name='entry', + name='lang', + field=models.CharField(blank=True, default='', max_length=2), + ), + ] diff --git a/feedler/models/admin.py b/feedler/models/admin.py index 604b92f..c6b6587 100644 --- a/feedler/models/admin.py +++ b/feedler/models/admin.py @@ -61,5 +61,7 @@ def handle_save_settings(sender, instance, *args, **kwargs): except Entry.DoesNotExist: logger.info("Adding entry '%s'" % eid) entry = Entry() + # Parse the Feedly object entry = feedparser.parse(entry, raw_entry, stream) + # Persist resulting object entry.save() diff --git a/feedler/models/models.py b/feedler/models/models.py index 8777e58..83e9240 100644 --- a/feedler/models/models.py +++ b/feedler/models/models.py @@ -6,6 +6,8 @@ from wagtail.wagtailcore.models import Page, Orderable from wagtail.wagtailadmin.edit_handlers import FieldPanel from wagtail.wagtailcore.fields import RichTextField +from django.utils import translation + class Stream(models.Model): title = models.CharField(max_length=255) ident = models.CharField(max_length=255) @@ -13,6 +15,14 @@ class Stream(models.Model): def __str__(self): return self.title +LANGUAGE_CHOICES = ( + ('de', 'Deutsch'), + ('fr', 'Français'), + ('it', 'Italiano'), + ('en', 'English'), + ('', ' * * * '), +) + class Entry(models.Model): """Implementation of the Entry from the feedly API as generic Django model """ @@ -25,7 +35,7 @@ class Entry(models.Model): author = models.CharField(max_length=255, blank=True) link = models.URLField() visual = models.URLField(blank=True) - + lang = models.CharField(max_length=2, blank=True, default='', choices=LANGUAGE_CHOICES) content = models.TextField() tags = models.TextField(blank=True) @@ -53,6 +63,12 @@ class FeedPage(Page): entries = Entry.objects.filter(stream=self.stream) else: entries = Entry.objects.all() + # Filter out by chosen language + curlang = translation.get_language() + if curlang in ['de']: + entries = entries.exclude(lang='fr') + elif curlang in ['fr']: + entries = entries.exclude(lang='de') # Order by most recent date first entries = entries.order_by('-published') return entries[:10] diff --git a/publichealth/home/models/models.py b/publichealth/home/models/models.py index 8bd5189..5354862 100644 --- a/publichealth/home/models/models.py +++ b/publichealth/home/models/models.py @@ -231,8 +231,14 @@ class HomePage(Page): @property def newsentries(self): - # Get news entries + # Get the last few news entries entries = Entry.objects.all().order_by('-published') + # Filter out by current language + curlang = translation.get_language() + if curlang in ['de']: + entries = entries.exclude(lang='fr') + elif curlang in ['fr']: + entries = entries.exclude(lang='de') return entries[:6] def get_context(self, request): diff --git a/publichealth/settings/base.py b/publichealth/settings/base.py index b164686..8559d48 100644 --- a/publichealth/settings/base.py +++ b/publichealth/settings/base.py @@ -132,6 +132,10 @@ PASSWORD_REQUIRED_TEMPLATE = 'password.html' # Internationalization # https://docs.djangoproject.com/en/1.8/topics/i18n/ +LANGUAGES = ( + ('de', u'Deutsch'), + ('fr', u'Français'), +) LANGUAGE_CODE = 'de' # default language TIME_ZONE = 'Europe/Zurich' diff --git a/requirements.txt b/requirements.txt index 433457f..8c9e836 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,8 +8,9 @@ Django==1.11.4 psycopg2==2.7.3.1 dj-database-url==0.4.2 -# Addons +# Content puput==0.9 +guess-language==0.2 # Search elasticsearch>=2.0.0,<3.0.0 From ec0db08faa72f35255841e2f7a5b096a2f083793 Mon Sep 17 00:00:00 2001 From: Oleg Lavrovsky Date: Mon, 4 Sep 2017 23:06:09 +0200 Subject: [PATCH 08/14] Correct module name --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 8c9e836..69283b0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,7 +10,7 @@ dj-database-url==0.4.2 # Content puput==0.9 -guess-language==0.2 +guess-language-spirit==0.5.3 # Search elasticsearch>=2.0.0,<3.0.0 From afbfb16a3571bd631993cf911042e9dca1a544eb Mon Sep 17 00:00:00 2001 From: Oleg Lavrovsky Date: Mon, 4 Sep 2017 23:22:38 +0200 Subject: [PATCH 09/14] Revert feed layout styles --- feedler/templates/feedler/feed_page.html | 4 ++-- publichealth/home/templates/news.html | 3 ++- publichealth/static/css/modules/_news.scss | 10 ++++++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/feedler/templates/feedler/feed_page.html b/feedler/templates/feedler/feed_page.html index df5c33e..2792e81 100644 --- a/feedler/templates/feedler/feed_page.html +++ b/feedler/templates/feedler/feed_page.html @@ -34,8 +34,8 @@

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

- {{ entry.author }}

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

diff --git a/publichealth/home/templates/news.html b/publichealth/home/templates/news.html index e31f305..6ebb419 100644 --- a/publichealth/home/templates/news.html +++ b/publichealth/home/templates/news.html @@ -41,7 +41,8 @@

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

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

diff --git a/publichealth/static/css/modules/_news.scss b/publichealth/static/css/modules/_news.scss index 418cec4..f823a59 100644 --- a/publichealth/static/css/modules/_news.scss +++ b/publichealth/static/css/modules/_news.scss @@ -46,6 +46,12 @@ margin: 10px 0 0 15px; text-align: center; } + em { + display: block; + font-size: 95%; + margin: 0.5em 0; + font-weight: 500; + } } // expand link over the thumbnail @@ -77,14 +83,14 @@ } .news-entry { - height: 8em; + // height: 8em; .panel { background: none; box-shadow: none; border: none; } .panel-body { - height: 50%; + // height: 50%; background-color: #f0f0f0; border-radius: 4px; border-top: 3px solid $brand-primary; From b332697aba9230a9f795cb000616633dc4a326b2 Mon Sep 17 00:00:00 2001 From: Oleg Lavrovsky Date: Tue, 5 Sep 2017 10:54:43 +0200 Subject: [PATCH 10/14] Pagination --- feedler/models/models.py | 18 +++++++++++++----- feedler/templates/feedler/feed_page.html | 20 ++++++++++++++++++++ publichealth/home/models/models.py | 2 +- publichealth/home/templates/news.html | 7 ++++--- publichealth/static/css/modules/_news.scss | 2 +- 5 files changed, 39 insertions(+), 10 deletions(-) diff --git a/feedler/models/models.py b/feedler/models/models.py index 83e9240..b47fc14 100644 --- a/feedler/models/models.py +++ b/feedler/models/models.py @@ -1,13 +1,13 @@ # -*- coding: utf-8 -*- from django.db import models +from django.utils import translation +from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger from wagtail.wagtailcore.models import Page, Orderable from wagtail.wagtailadmin.edit_handlers import FieldPanel from wagtail.wagtailcore.fields import RichTextField -from django.utils import translation - class Stream(models.Model): title = models.CharField(max_length=255) ident = models.CharField(max_length=255) @@ -70,13 +70,21 @@ class FeedPage(Page): elif curlang in ['fr']: entries = entries.exclude(lang='de') # Order by most recent date first - entries = entries.order_by('-published') - return entries[:10] + return entries.order_by('-published') def get_context(self, request): # Update template context context = super(FeedPage, self).get_context(request) - context['feedentries'] = self.feedentries + + # Wrap with pagination + paginator = Paginator(self.feedentries, 9) + page = request.GET.get('page') + try: + feedentries = paginator.page(page) + except (PageNotAnInteger, EmptyPage): + feedentries = paginator.page(1) + + context['feedentries'] = feedentries return context class Meta: diff --git a/feedler/templates/feedler/feed_page.html b/feedler/templates/feedler/feed_page.html index 2792e81..3a6eab6 100644 --- a/feedler/templates/feedler/feed_page.html +++ b/feedler/templates/feedler/feed_page.html @@ -19,9 +19,29 @@
+
+ + +
+
    + {% if feedentries.has_previous %} +
  • +
  • + {% endif %} + {% for page_num in feedentries.paginator.page_range %} +
  • + {{ page_num }}
  • + {% endfor %} + {% if feedentries.has_next %} +
  • +
  • + {% endif %} +
+
+
{% for entry in feedentries %}
diff --git a/publichealth/home/models/models.py b/publichealth/home/models/models.py index 5354862..6fd1eb1 100644 --- a/publichealth/home/models/models.py +++ b/publichealth/home/models/models.py @@ -239,7 +239,7 @@ class HomePage(Page): entries = entries.exclude(lang='fr') elif curlang in ['fr']: entries = entries.exclude(lang='de') - return entries[:6] + return entries[:3] def get_context(self, request): # Update template context diff --git a/publichealth/home/templates/news.html b/publichealth/home/templates/news.html index 6ebb419..168393f 100644 --- a/publichealth/home/templates/news.html +++ b/publichealth/home/templates/news.html @@ -20,7 +20,7 @@ {{ entry.body|striptags|truncatewords_html:40 }} {% endif %}

- ... + 🡆
@@ -28,7 +28,7 @@ {% empty %} {% endfor %} -

Partner news

+ {% for entry in newsentries %}
@@ -45,7 +45,8 @@ {{ entry.author }}

- + +
{% empty %} diff --git a/publichealth/static/css/modules/_news.scss b/publichealth/static/css/modules/_news.scss index f823a59..0fd3bd7 100644 --- a/publichealth/static/css/modules/_news.scss +++ b/publichealth/static/css/modules/_news.scss @@ -91,7 +91,7 @@ } .panel-body { // height: 50%; - background-color: #f0f0f0; + background-color: #ffffff; border-radius: 4px; border-top: 3px solid $brand-primary; // border: 2px solid rgba(38, 67, 169, 0.8); From 671768700a8d5eff87b25f2943ad4872387aa3bc Mon Sep 17 00:00:00 2001 From: Oleg Lavrovsky Date: Tue, 5 Sep 2017 10:57:33 +0200 Subject: [PATCH 11/14] Max 8 pages of results --- feedler/models/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/feedler/models/models.py b/feedler/models/models.py index b47fc14..3b77c6c 100644 --- a/feedler/models/models.py +++ b/feedler/models/models.py @@ -70,7 +70,7 @@ class FeedPage(Page): elif curlang in ['fr']: entries = entries.exclude(lang='de') # Order by most recent date first - return entries.order_by('-published') + return entries.order_by('-published')[:72] def get_context(self, request): # Update template context From ef3cca5218c3cdcab318bc65a3efb2ec243b0d2c Mon Sep 17 00:00:00 2001 From: Oleg Lavrovsky Date: Tue, 5 Sep 2017 11:02:54 +0200 Subject: [PATCH 12/14] Home page container sections --- publichealth/home/templates/home/home_page.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/publichealth/home/templates/home/home_page.html b/publichealth/home/templates/home/home_page.html index 4c5e3ff..df0d537 100644 --- a/publichealth/home/templates/home/home_page.html +++ b/publichealth/home/templates/home/home_page.html @@ -13,6 +13,8 @@ {% include 'banner.html' %} +
+ {% include 'news.html' %} @@ -28,4 +30,6 @@ {% include 'infos.html' %} +
+ {% endblock %} From 05f7349ed702744032f333a42d1e9a37f5e8507c Mon Sep 17 00:00:00 2001 From: Oleg Lavrovsky Date: Tue, 5 Sep 2017 11:08:18 +0200 Subject: [PATCH 13/14] Front page colors --- publichealth/home/templates/news.html | 2 +- publichealth/static/css/modules/_banner.scss | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/publichealth/home/templates/news.html b/publichealth/home/templates/news.html index 168393f..c4fe148 100644 --- a/publichealth/home/templates/news.html +++ b/publichealth/home/templates/news.html @@ -45,7 +45,7 @@ {{ entry.author }}

- + diff --git a/publichealth/static/css/modules/_banner.scss b/publichealth/static/css/modules/_banner.scss index 38b279a..19f4f20 100644 --- a/publichealth/static/css/modules/_banner.scss +++ b/publichealth/static/css/modules/_banner.scss @@ -80,8 +80,11 @@ } } - - +/* Home page banner background */ +body.template-frontpage { + background: $gray-lighter; + .home_page section:nth-child(even) { background: white; } +} /* Page header */ $banner-height: 700px; From dd9691524f5851732a1133d6883661cdc4a8aac9 Mon Sep 17 00:00:00 2001 From: Oleg Lavrovsky Date: Tue, 5 Sep 2017 11:14:12 +0200 Subject: [PATCH 14/14] Disable pastel colors and raw data --- feedler/templates/feedler/feed_page.html | 3 +-- publichealth/static/js/main.js | 12 ++++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/feedler/templates/feedler/feed_page.html b/feedler/templates/feedler/feed_page.html index 3a6eab6..34ed625 100644 --- a/feedler/templates/feedler/feed_page.html +++ b/feedler/templates/feedler/feed_page.html @@ -44,7 +44,7 @@
{% for entry in feedentries %} -
+
{% if entry.visual %}
@@ -61,7 +61,6 @@
- {% empty %} {% endfor %} diff --git a/publichealth/static/js/main.js b/publichealth/static/js/main.js index 3c51033..982e842 100644 --- a/publichealth/static/js/main.js +++ b/publichealth/static/js/main.js @@ -18,11 +18,11 @@ $(document).ready(function() { nextArrow: '', }); - // Formatting of live news - $('.feedpage-body .panel').each(function() { - var hue = Math.floor(Math.random() * 360); - var pastel = 'hsl(' + hue + ', 100%, 87.5%)'; - $(this).css('border-top', '3px solid ' + pastel); - }); + // Pastel colors on live news + // $('.feedpage-body .panel').each(function() { + // var hue = Math.floor(Math.random() * 360); + // var pastel = 'hsl(' + hue + ', 100%, 87.5%)'; + // $(this).css('border-top', '3px solid ' + pastel); + // }); });