Skip to content

Commit

Permalink
[FIX] website_slides: crash if no image
Browse files Browse the repository at this point in the history
Google might return an empty 'image' value, leading to a crash when we try
to analyze it.

opw-703750
  • Loading branch information
nim-odoo committed Feb 3, 2017
1 parent a01188e commit 6178488
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions addons/website_slides/models/slides.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,12 +566,13 @@ def _parse_youtube_document(self, document_id, only_preview_fields):
def _parse_google_document(self, document_id, only_preview_fields):
def get_slide_type(vals):
# TDE FIXME: WTF ??
image = Image.open(io.BytesIO(vals['image'].decode('base64')))
width, height = image.size
if height > width:
return 'document'
else:
return 'presentation'
slide_type = 'presentation'
if vals.get('image'):
image = Image.open(io.BytesIO(vals['image'].decode('base64')))
width, height = image.size
if height > width:
return 'document'
return slide_type

# Google drive doesn't use a simple API key to access the data, but requires an access
# token. However, this token is generated in module google_drive, which is not in the
Expand Down

0 comments on commit 6178488

Please sign in to comment.