Browse files

[IMP] website_slides: new modal to upload a document

With new slide type, it was required to change the
upload modaL. Now, the use select first the type
of document he wants to upload, then the correct
form appears. When filled, user can sumbit it to
be redirect to the slide he just create.

  • Loading branch information...
jem-odoo committed Feb 8, 2019
1 parent a4ecef8 commit 89ecdc5a2c3b2ce3f52de8550ea33afb033089f9
@@ -299,13 +299,14 @@ def dialog_preview(self, **data):
def create_slide(self, *args, **post):
# check the size only when we upload a file.
if post.get('datas'):
file_size = len(post['datas']) * 3 / 4 # base64
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',
'mime_type', 'datas', 'description', 'image', 'index_content', 'website_published'] if post.get(fname))

if post.get('category_id'):
if post['category_id'][0] == 0:
values['category_id'] = request.env['slide.category'].create({
@@ -330,14 +331,18 @@ def create_slide(self, *args, **post):
values['user_id'] = request.env.uid
values['website_published'] = values.get('website_published', False) and can_publish
slide = request.env['slide.slide'].sudo().create(values)
slide = request.env['slide.slide'].create(values)
except (UserError, AccessError) as e:
return {'error':}
except Exception as e:
return {'error': _('Internal server error, please try again later or contact administrator.\nHere is the error message: %s') % e}
return {'url': "/slides/slide/%s" % (}

redirect_url = "/slides/slide/%s" % (
if slide.slide_type == 'webpage':
redirect_url = "/slides/slide/%s?enable_editor=1" % (
return {'url': redirect_url}

@http.route(['/slides/tag/search_read'], type='json', auth='user', methods=['POST'], website=True)
def slide_tag_search_read(self, fields, domain):
Oops, something went wrong.

0 comments on commit 89ecdc5

Please sign in to comment.