Use poster file as preview for film projects
This commit is contained in:
@@ -198,7 +198,27 @@ def courses():
|
|||||||
def open_projects():
|
def open_projects():
|
||||||
@current_app.cache.cached(timeout=3600, unless=current_user_is_authenticated)
|
@current_app.cache.cached(timeout=3600, unless=current_user_is_authenticated)
|
||||||
def render_page():
|
def render_page():
|
||||||
projects = get_projects('film')
|
api = system_util.pillar_api()
|
||||||
|
projects = Project.all({
|
||||||
|
'where': {
|
||||||
|
'category': 'film',
|
||||||
|
'is_private': False
|
||||||
|
},
|
||||||
|
'sort': '-_created',
|
||||||
|
}, api=api)
|
||||||
|
for project in projects._items:
|
||||||
|
# Attach poster file (ensure the extension_props.cloud.poster attributes exists)
|
||||||
|
if 'extension_props' not in project:
|
||||||
|
continue
|
||||||
|
if EXTENSION_NAME not in project['extension_props']:
|
||||||
|
continue
|
||||||
|
if 'poster' not in project['extension_props'][EXTENSION_NAME]:
|
||||||
|
continue
|
||||||
|
project.extension_props.cloud.poster = get_file(
|
||||||
|
project.extension_props.cloud.poster, api=api)
|
||||||
|
# Add convenience attribute that specifies the presence of the poster file
|
||||||
|
project.has_poster = True
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
'films.html',
|
'films.html',
|
||||||
title='films',
|
title='films',
|
||||||
|
@@ -29,14 +29,13 @@ include mixins/components
|
|||||||
|
|
||||||
.films-item.col-md-4.col-sm-6.col-lg-3.my-5
|
.films-item.col-md-4.col-sm-6.col-lg-3.my-5
|
||||||
.d-flex.flex-column.h-100
|
.d-flex.flex-column.h-100
|
||||||
|
| {% if project.has_poster %} {# Check convenience attribute set in open_projects() #}
|
||||||
| {% if project.picture_header %}
|
|
||||||
a.mx-auto(
|
a.mx-auto(
|
||||||
href="{{ project_url }}",
|
href="{{ project_url }}",
|
||||||
tabindex='{{ loop.index }}')
|
tabindex='{{ loop.index }}')
|
||||||
img.rounded.w-100(
|
img.rounded.w-100(
|
||||||
alt="{{ project.name }}",
|
alt="{{ project.name }}",
|
||||||
src="{{ project.picture_header.thumbnail('l', api=api) }}")
|
src="{{ project.extension_props.cloud.poster.thumbnail('l', api=api) }}")
|
||||||
| {% endif %}
|
| {% endif %}
|
||||||
|
|
||||||
h4.pt-5.pb-3.text-center
|
h4.pt-5.pb-3.text-center
|
||||||
|
Reference in New Issue
Block a user