Homepage streams with icons

This commit is contained in:
Oleg Lavrovsky 2017-09-14 13:39:10 +02:00
parent c87ee12ec5
commit d7dde4a516
3 changed files with 42 additions and 25 deletions

View File

@ -16,7 +16,7 @@ from wagtail.wagtailimages.edit_handlers import ImageChooserPanel
from wagtail.wagtailsearch import index
from puput.models import EntryPage, BlogPage
from feedler.models import Entry
from feedler.models import Entry, Stream
from itertools import chain
from ..util import TranslatedField
@ -250,7 +250,7 @@ class HomePage(Page):
@property
def newsentries(self):
# Get the last few news entries
# Get the last few news entries for the home page
entries = Entry.objects.all().order_by('-published')
# Filter out by current language
curlang = translation.get_language()
@ -258,7 +258,14 @@ class HomePage(Page):
entries = entries.exclude(lang='fr')
elif curlang in ['fr']:
entries = entries.exclude(lang='de')
return entries[:3]
news = events = jobs = []
Stream1 = Stream.objects.filter(title='News')
if Stream1: news = entries.filter(stream=Stream1)
Stream2 = Stream.objects.filter(title='Events')
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]))
def get_context(self, request):
# Update template context
@ -266,6 +273,11 @@ 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' },
]
return context
parent_page_types = ['wagtailcore.Page']

View File

@ -28,30 +28,33 @@
{% empty %}
<!-- No blogs today -->
{% endfor %}
<!-- <h4 class="partner-news"><a href="/aktuelles/">Partner news</a></h4> -->
{% for entry in newsentries %}
<!-- News entry {{ entry.id }} -->
<div class="col-md-4 col-sm-6 col-xs-12 news-entry">
{% if entry.visual %}
<div class="panel panel-default">
<img src="{{ entry.visual }}">
{% else %}
<div class="panel panel-fulltext">
{% endif %}
<div class="panel-body">
<h3><span>{{ entry.title|striptags|truncatewords_html:10 }}</span></h3>
<p>
{{ entry.content|striptags|truncatewords_html:25 }}
<em><span>{{ entry.author }}</span></em>
</p>
</div>
<a href="/aktuelles/" class="fill"></a>
<!-- <a href="{{ entry.link }}" target="_blank" class="fill"></a> -->
{% for feedType in entryfeeds %}
<div class="col-md-4 col-sm-6 col-xs-12 news-entry">
<h4 class="partner-news"><a href="/aktuelles/" title="{{ feedType.title }}">
<span class="glyphicon {{ feedType.icon }}" aria-hidden="true"></span>
</a></h4>
<div class="panel panel-fulltext">
<div class="panel-body">
<ul>
{% for entry in newsentries %}
{% if feedType.name in entry.stream.title %}
<li><!-- News entry {{ entry.id }} -->
<a href="{{ entry.link }}" target="_blank">
{{ entry.title|striptags|truncatewords_html:10 }}
</a>
<br><small>{{ entry.published }}</small>
</li>
{% endif %}
{% empty %}
<!-- No news today -->
{% endfor %}
<ul>
</div>
</div>
{% empty %}
<!-- No news today -->
{% endfor %}
</div><!-- /news-entry -->
{% endfor %}
</div>
</div>
</section>

View File

@ -96,6 +96,8 @@
border-top: 3px solid $brand-primary;
// border: 2px solid rgba(38, 67, 169, 0.8);
*,a { color: black !important; }
a { margin: 0px; font-size: 15pt; }
li { margin-top: 1em; line-height: 20pt; }
}
}