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',
|
||||
}, 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]:
|
||||
# Attach poster file (ensure the extension_props.cloud.poster
|
||||
# attributes exists)
|
||||
try:
|
||||
# If the attribute exists, but is None, continue
|
||||
if not project['extension_props'][EXTENSION_NAME]['poster']:
|
||||
continue
|
||||
# Fetch the file and embed it in the document
|
||||
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
|
||||
# Add convenience attribute that specifies the presence of the
|
||||
# poster file
|
||||
project.has_poster = True
|
||||
# If there was a key error because one of the nested attributes is
|
||||
# missing,
|
||||
except KeyError:
|
||||
continue
|
||||
|
||||
return render_template(
|
||||
'films.html',
|
||||
|
Reference in New Issue
Block a user