more content

This commit is contained in:
root 2017-12-23 11:22:39 +00:00
parent f25482a3e1
commit daf305d123
4 changed files with 40 additions and 22 deletions

View File

@ -1,6 +1,6 @@
{% if latest_content_list %}
<div class="large-4 medium-4 columns">
<div class="large-4 medium-4 columns">
{% include "related.html" with related=content.children.all %}
{% if latest_content_list %}
<h4 class="sidebar-h4">{{section}}</h4>
<div class="row">
{% for content in latest_content_list %}
@ -12,7 +12,7 @@
{% endif %}
{% endwith %}
</div>
</div>
{% else %}
<p>No content.</p>
{% endif %}
{% else %}
{% if 0 %}<p>No content.</p>{% endif %}
{% endif %}
</div>

View File

@ -1,4 +1,14 @@
<div class="row right-items">
{% if content.type.name == 'news' %}
<div class= "small-12 columns">
<h6 class="sidebar-date">
<font color="#ef4e5c"> <b> {{content.datestart}} </b>
{{ content.title }} <br />
{{ content.formatted_header }}
</font>
</h6>
</div>
{% else %}
<div class="small-6 columns">
{% if content.image_url %}
<a href="{{ content.get_absolute_url }}"><img src="{{ content.image_url }}"></a>
@ -16,4 +26,5 @@
{% endif %}
<p> {{ content.formatted_teaser }} </p>
</div>
{% endif %}
</div>

View File

@ -4,6 +4,7 @@
{% include "featured.html" %}
<div class="large-4 medium-4 columns">
{% if content %}
<h4 class="sidebar-h4"> {{ section }} </h4>
<div class="row">
{% for content in content %}
@ -19,8 +20,11 @@
</div>
</div>
{% endfor %}
{% if more_content %}
<a href="index/">more</a>
{% endif %}
</div>
{% endif %}
</div>
{% endblock %}

View File

@ -50,16 +50,19 @@ def section_content(section):
return content
def section_index(request, section):
def section_index(request, section, max_length=10):
types = SECTION_TYPE.get(section, [section.lower()])
featured = Content.objects.filter(type__name__in=types, featured=True).order_by('-datestart')[:1]
content = section_content(section)
if featured:
content = content.exclude(pk=featured[0].pk)
more_content = content.count() > max_length
content = content[:max_length]
return render(request, 'section_index.html', {
'section': section,
'featured': featured,
'content': content
'content': content,
'more_content': more_content,
})
@ -117,7 +120,7 @@ def get_related_content(types, current=None, max_length=10):
if current:
latest_content_list = latest_content_list.exclude(pk=current.pk)
latest_content_list = latest_content_list.filter(published=True)
more = latest_content_list.count > max_length
more = latest_content_list.count() > max_length
latest_content_list = latest_content_list[:max_length]
return latest_content_list, more
@ -153,7 +156,7 @@ def works(request, shortname=None):
def texts(request, shortname=None):
return render_content(requests, shortname, 'Texts', 'content.html', ['texts'])
return render_content(request, shortname, 'Texts', 'content.html', ['texts'])
def page(request, shortname):