Refactored settings
This commit is contained in:
parent
d7dde4a516
commit
b520b643fa
3 changed files with 16 additions and 8 deletions
|
@ -4,6 +4,7 @@ from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils import translation
|
from django.utils import translation
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
from modelcluster.fields import ParentalKey
|
from modelcluster.fields import ParentalKey
|
||||||
|
|
||||||
|
@ -246,7 +247,7 @@ class HomePage(Page):
|
||||||
posts = EntryPage.objects.live().descendant_of(parent[0])
|
posts = EntryPage.objects.live().descendant_of(parent[0])
|
||||||
# Order by most recent date first
|
# Order by most recent date first
|
||||||
posts = posts.order_by('-date')
|
posts = posts.order_by('-date')
|
||||||
return posts[:3]
|
return posts[:settings.BLOG_ENTRIES_HOME_PAGE]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def newsentries(self):
|
def newsentries(self):
|
||||||
|
@ -265,7 +266,8 @@ class HomePage(Page):
|
||||||
if Stream2: events = entries.filter(stream=Stream2)
|
if Stream2: events = entries.filter(stream=Stream2)
|
||||||
Stream3 = Stream.objects.filter(title='Jobs')
|
Stream3 = Stream.objects.filter(title='Jobs')
|
||||||
if Stream3: jobs = entries.filter(stream=Stream3)
|
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):
|
def get_context(self, request):
|
||||||
# Update template context
|
# Update template context
|
||||||
|
@ -273,11 +275,7 @@ class HomePage(Page):
|
||||||
context['featured'] = self.featured
|
context['featured'] = self.featured
|
||||||
context['blogentries'] = self.blogentries
|
context['blogentries'] = self.blogentries
|
||||||
context['newsentries'] = self.newsentries
|
context['newsentries'] = self.newsentries
|
||||||
context['entryfeeds'] = [
|
context['entryfeeds'] = settings.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' },
|
|
||||||
]
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
parent_page_types = ['wagtailcore.Page']
|
parent_page_types = ['wagtailcore.Page']
|
||||||
|
|
|
@ -5,7 +5,6 @@ from datetime import date
|
||||||
from django.utils.dateformat import DateFormat
|
from django.utils.dateformat import DateFormat
|
||||||
from django.utils.formats import date_format
|
from django.utils.formats import date_format
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.conf import settings
|
|
||||||
|
|
||||||
from wagtail.wagtailcore.models import Page
|
from wagtail.wagtailcore.models import Page
|
||||||
from wagtail.wagtailsearch.models import Query
|
from wagtail.wagtailsearch.models import Query
|
||||||
|
|
|
@ -18,6 +18,17 @@ import os
|
||||||
PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
BASE_DIR = os.path.dirname(PROJECT_DIR)
|
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
|
# Application definition
|
||||||
|
|
||||||
INSTALLED_APPS = [
|
INSTALLED_APPS = [
|
||||||
|
|
Loading…
Add table
Reference in a new issue