Permalink
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.

Task-1938643
  • Loading branch information...
jem-odoo committed Feb 8, 2019
1 parent 2f8319a commit 1fe94d5677a07a0b41ef9a0e72fc105024e2322d
@@ -296,13 +296,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({
@@ -334,7 +335,11 @@ def create_slide(self, *args, **post):
except Exception as e:
_logger.error(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" % (slide.id)}

redirect_url = "/slides/slide/%s" % (slide.id)
if slide.slide_type == 'webpage':
redirect_url = "/slides/slide/%s?enable_editor=1" % (slide.id)
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 1fe94d5

Please sign in to comment.