From daf305d1237059e0f49c61b139dd30c47f078f78 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 23 Dec 2017 11:22:39 +0000 Subject: [PATCH] more content --- content/templates/latest_content.html | 34 +++++++++++++-------------- content/templates/preview.html | 13 +++++++++- content/templates/section_index.html | 4 ++++ content/views.py | 11 +++++---- 4 files changed, 40 insertions(+), 22 deletions(-) diff --git a/content/templates/latest_content.html b/content/templates/latest_content.html index 3ccd65e..16b50fa 100644 --- a/content/templates/latest_content.html +++ b/content/templates/latest_content.html @@ -1,18 +1,18 @@ -{% if latest_content_list %} -
- {% include "related.html" with related=content.children.all %} - -
- {% for content in latest_content_list %} - {% include "preview.html" with content=content %} - {% endfor %} - {% with section|lower|add:'_list' as section_list %} - {% if has_more_content %} - more - {% endif %} - {% endwith %} -
+
+ {% include "related.html" with related=content.children.all %} + {% if latest_content_list %} + +
+ {% for content in latest_content_list %} + {% include "preview.html" with content=content %} + {% endfor %} + {% with section|lower|add:'_list' as section_list %} + {% if has_more_content %} + more + {% endif %} + {% endwith %}
-{% else %} -

No content.

-{% endif %} + {% else %} + {% if 0 %}

No content.

{% endif %} + {% endif %} +
diff --git a/content/templates/preview.html b/content/templates/preview.html index ad69f93..e72dffb 100644 --- a/content/templates/preview.html +++ b/content/templates/preview.html @@ -1,4 +1,14 @@
+ {% if content.type.name == 'news' %} +
+ +
+ {% else %}
{% if content.image_url %} @@ -15,5 +25,6 @@ {% endif %}

{{ content.formatted_teaser }}

-
+
+ {% endif %}
diff --git a/content/templates/section_index.html b/content/templates/section_index.html index 6cf6545..2380eee 100644 --- a/content/templates/section_index.html +++ b/content/templates/section_index.html @@ -4,6 +4,7 @@ {% include "featured.html" %}
+ {% if content %}
{% for content in content %} @@ -19,8 +20,11 @@
{% endfor %} + {% if more_content %} more + {% endif %} + {% endif %} {% endblock %} diff --git a/content/views.py b/content/views.py index 4808492..b0d2a91 100644 --- a/content/views.py +++ b/content/views.py @@ -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):