From 2240982d10daec7d323acc451a8610fda41718d5 Mon Sep 17 00:00:00 2001 From: Yoan Le Clanche Date: Thu, 3 Dec 2020 17:46:32 +0100 Subject: [PATCH] Merge fixes --- teleforma/templates/teleforma/inc/conference_list.html | 4 ++-- teleforma/templates/teleforma/inc/document_list.html | 6 +++--- teleforma/templates/teleforma/inc/media_list.html | 6 +++--- .../templates/teleforma/inc/media_list_pending.html | 4 ++-- teleforma/templatetags/teleforma_tags.py | 9 +++++++-- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/teleforma/templates/teleforma/inc/conference_list.html b/teleforma/templates/teleforma/inc/conference_list.html index c750fbc1..e80f7235 100644 --- a/teleforma/templates/teleforma/inc/conference_list.html +++ b/teleforma/templates/teleforma/inc/conference_list.html @@ -2,14 +2,14 @@ {% load i18n %} {% with course.conference.all|from_course_type:type|streaming_only as conferences %} -{% if conferences|from_period:period %} +{% if conferences|from_periods:period %}

{% trans "Live conferences"%}

- {% for conference in conferences|from_period:period %} + {% for conference in conferences|from_periods:period %} {% for stream in conference.livestream.all %} {% if stream.stream_type == 'webm' %} diff --git a/teleforma/templates/teleforma/inc/document_list.html b/teleforma/templates/teleforma/inc/document_list.html index 236a15a6..f07d07ba 100644 --- a/teleforma/templates/teleforma/inc/document_list.html +++ b/teleforma/templates/teleforma/inc/document_list.html @@ -1,7 +1,7 @@ {% load teleforma_tags %} {% load i18n %} -{% if course.document.all|from_course_type:type|from_period:period|published %} +{% if course.document.all|from_course_type:type|from_periods:period|published %}

{% trans "Documents"%}

@@ -9,11 +9,11 @@ {% with course.document.all as docs %} {% for doc_type in doc_types %} -{% if docs|from_course_type:type|from_doc_type:doc_type|from_period:period and not type_counter > 2 %} +{% if docs|from_course_type:type|from_doc_type:doc_type|from_periods:period and not type_counter > 2 %} {{ doc_type }}
- {% for doc in docs|from_course_type:type|from_doc_type:doc_type|from_period:period|published %} + {% for doc in docs|from_course_type:type|from_doc_type:doc_type|from_periods:period|published %} diff --git a/teleforma/templates/teleforma/inc/media_list.html b/teleforma/templates/teleforma/inc/media_list.html index c96bbd86..2f502189 100644 --- a/teleforma/templates/teleforma/inc/media_list.html +++ b/teleforma/templates/teleforma/inc/media_list.html @@ -14,12 +14,12 @@ {% if media.type == 'webm' %}
{% if doc.file %}{% endif %} {{ doc.title }}{% if doc.file %}{% endif %} {{ doc.date_added }}
- + {% if media.item.related.all %} {% for related in media.item.related.all %} {% if related.title == "preview" %} {% thumbnail related.file "168x96" as im %} -
+
{% trans 'Click here' %}
{% endthumbnail %} @@ -52,7 +52,7 @@ {% endif %} {% if media.item.file and user.is_staff %} -
+ {% endif %} diff --git a/teleforma/templates/teleforma/inc/media_list_pending.html b/teleforma/templates/teleforma/inc/media_list_pending.html index b4502105..6cf3bd6e 100644 --- a/teleforma/templates/teleforma/inc/media_list_pending.html +++ b/teleforma/templates/teleforma/inc/media_list_pending.html @@ -2,14 +2,14 @@ {% load thumbnail %} {% load i18n %} -{% if course.media.all|from_course_type:type|from_period:period %} +{% if course.media.all|from_course_type:type|from_periods:period %}

{% trans "Passed conferences"%}

- {% for media in course.media.all|from_course_type:type|from_period:period %} + {% for media in course.media.all|from_course_type:type|from_periods:period %} {% if not media.is_published and user.is_staff %} {% if media.type == 'webm' %} diff --git a/teleforma/templatetags/teleforma_tags.py b/teleforma/templatetags/teleforma_tags.py index 751dea08..69885a7c 100644 --- a/teleforma/templatetags/teleforma_tags.py +++ b/teleforma/templatetags/teleforma_tags.py @@ -150,12 +150,17 @@ def from_doc_type(contents, type): return contents.filter(type=type) @register.filter -def from_period(contents, period): +def from_periods(contents, period): if contents: if type(contents[0]) == Document: return contents.filter(periods__in=(period,)) else: - return contents.filter(period=period) + # check if it's a list before building the query + try: + iter(period) + return contents.filter(period__in=period) + except: + return contents.filter(period=period) @register.assignment_tag def get_all_professors(): -- 2.39.5