Fix for exception in /open-movies
When extension_props.cloud.poster was set to empty string, we would try to get file anyway and we would set the has_poster has_poster convenience attribute to true. This would lead to an exception when trying to access the poster file object in the template.
This commit is contained in:
@@ -207,17 +207,22 @@ def open_projects():
|
|||||||
'sort': '-_created',
|
'sort': '-_created',
|
||||||
}, api=api)
|
}, api=api)
|
||||||
for project in projects._items:
|
for project in projects._items:
|
||||||
# Attach poster file (ensure the extension_props.cloud.poster attributes exists)
|
# Attach poster file (ensure the extension_props.cloud.poster
|
||||||
if 'extension_props' not in project:
|
# attributes exists)
|
||||||
continue
|
try:
|
||||||
if EXTENSION_NAME not in project['extension_props']:
|
# If the attribute exists, but is None, continue
|
||||||
continue
|
if not project['extension_props'][EXTENSION_NAME]['poster']:
|
||||||
if 'poster' not in project['extension_props'][EXTENSION_NAME]:
|
|
||||||
continue
|
continue
|
||||||
|
# Fetch the file and embed it in the document
|
||||||
project.extension_props.cloud.poster = get_file(
|
project.extension_props.cloud.poster = get_file(
|
||||||
project.extension_props.cloud.poster, api=api)
|
project.extension_props.cloud.poster, api=api)
|
||||||
# Add convenience attribute that specifies the presence of the poster file
|
# Add convenience attribute that specifies the presence of the
|
||||||
|
# poster file
|
||||||
project.has_poster = True
|
project.has_poster = True
|
||||||
|
# If there was a key error because one of the nested attributes is
|
||||||
|
# missing,
|
||||||
|
except KeyError:
|
||||||
|
continue
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
'films.html',
|
'films.html',
|
||||||
|
Reference in New Issue
Block a user