summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Kersten <jke@odoo.com>2017-11-08 11:29:41 +0100
committerJeremy Kersten <jke@odoo.com>2017-11-08 13:00:07 +0100
commit35aa2a977f5169db12b6a7367f7d3b7fa87277cc (patch)
tree508c9f55e121c928dce05fc20eeb8b407f09065c
parent43e5f5a67f089ef89b11c10fb8ec8aac6ea2a6d6 (diff)
[FIX] website_slide: fix traceback when slide is a google doc or youtube link
In case we are not uploading a file but add a slide based on google doc url or youtube link, post['datas'] is not set and the code will crash. Javascript don't check the onError, so the user never see the error and wait that nothing happend.
-rw-r--r--addons/website_slides/controllers/main.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/addons/website_slides/controllers/main.py b/addons/website_slides/controllers/main.py
index 70f83b18a37..b49fb349069 100644
--- a/addons/website_slides/controllers/main.py
+++ b/addons/website_slides/controllers/main.py
@@ -292,9 +292,11 @@ class website_slides(http.Controller):
@http.route(['/slides/add_slide'], type='json', auth='user', methods=['POST'], website=True)
def create_slide(self, *args, **post):
- file_size = len(post['datas']) * 3 / 4; # base64
- if (file_size / 1024.0 / 1024.0) > 25:
- return {'error': _('File is too big. File size cannot exceed 25MB')}
+ # check the size only when we upload a file.
+ if post.get('datas'):
+ file_size = len(post['datas']) * 3 / 4 # base64
+ if (file_size / 1024.0 / 1024.0) > 25:
+ return {'error': _('File is too big. File size cannot exceed 25MB')}
values = dict((fname, post[fname]) for fname in [
'name', 'url', 'tag_ids', 'slide_type', 'channel_id',