diff --git a/publichealth/home/models/models.py b/publichealth/home/models/models.py index ec68901..69ec811 100644 --- a/publichealth/home/models/models.py +++ b/publichealth/home/models/models.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals from django.db import models from django.utils import translation +from django.conf import settings from modelcluster.fields import ParentalKey @@ -246,7 +247,7 @@ 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] + return posts[:settings.BLOG_ENTRIES_HOME_PAGE] @property def newsentries(self): @@ -265,7 +266,8 @@ class HomePage(Page): if Stream2: events = entries.filter(stream=Stream2) Stream3 = Stream.objects.filter(title='Jobs') if Stream3: jobs = entries.filter(stream=Stream3) - return list(chain(news[:5], events[:5], jobs[:5])) + i = settings.NEWS_ENTRIES_HOME_PAGE + return list(chain(news[:i], events[:i], jobs[:i])) def get_context(self, request): # Update template context @@ -273,11 +275,7 @@ class HomePage(Page): context['featured'] = self.featured context['blogentries'] = self.blogentries context['newsentries'] = self.newsentries - context['entryfeeds'] = [ - { 'name': 'News', 'title': 'News', 'icon': 'glyphicon-eye-open' }, - { 'name': 'Events', 'title': 'Events', 'icon': 'glyphicon-time' }, - { 'name': 'Jobs', 'title': 'Jobs', 'icon': 'glyphicon-briefcase' }, - ] + context['entryfeeds'] = settings.STREAMS_ON_HOME_PAGE return context parent_page_types = ['wagtailcore.Page'] diff --git a/publichealth/home/routes.py b/publichealth/home/routes.py index e04e0f6..3e7ce4a 100644 --- a/publichealth/home/routes.py +++ b/publichealth/home/routes.py @@ -5,7 +5,6 @@ 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 diff --git a/publichealth/settings/base.py b/publichealth/settings/base.py index 8559d48..25df17e 100644 --- a/publichealth/settings/base.py +++ b/publichealth/settings/base.py @@ -18,6 +18,17 @@ import os PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) BASE_DIR = os.path.dirname(PROJECT_DIR) +# Project custom settings + +NEWS_ENTRIES_HOME_PAGE = 2 +BLOG_ENTRIES_HOME_PAGE = 3 + +STREAMS_ON_HOME_PAGE = [ + { 'name': 'News', 'title': 'News', 'icon': 'glyphicon-eye-open' }, + { 'name': 'Events', 'title': 'Events', 'icon': 'glyphicon-time' }, + { 'name': 'Jobs', 'title': 'Jobs', 'icon': 'glyphicon-briefcase' }, +] + # Application definition INSTALLED_APPS = [