summaryrefslogtreecommitdiff
path: root/addons/website_slides/controllers
diff options
context:
space:
mode:
authorqmo-odoo <qmo@odoo.com>2019-12-30 08:17:23 +0000
committerThibault Delavallée <tde@odoo.com>2020-03-26 15:57:43 +0000
commit12c6d77e7f4ebdbe099ce35c7c7dbd326e33dd50 (patch)
tree36b4d70d6c7a342ae1619c93daec03d90b5b4998 /addons/website_slides/controllers
parent843caa270c7d13e6c81ef8f077e469bd9746a2cf (diff)
[FIX] website_slides: fix slide reordering in frontend
This commit fixes the reordering of slides on upload or drag and drop in frontend. This issue was due to the fact that in a previous commit (c4eba6f) uncategorized slides were moved to the bottom of the list, which broke the reordering after drag and drop. Indeed we use the dom order itself to reorder the slides with a simple rpc call to dataset/resequence. Instead we revert part of the previous fix to display uncategorized slides at the top. It allows to be coherent with resequence and with backend behavior that displays uncategorized at the top of the list. Another issue was that, on slide upload, in the controller, we used the category_id on the slide (which seems to not always be correct at this stage) instead of the one given by the javascript. This caused the slide to not be uploaded in the right section. This commit also adds some margin to the categories in frontend for training courses. Otherwise uncategorized slides are too close to the first category. Task ID 2090927 X-original-commit: 7bd042d6e20c44558b90641409a6e3f8fa8000ed
Diffstat (limited to 'addons/website_slides/controllers')
-rw-r--r--addons/website_slides/controllers/main.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/addons/website_slides/controllers/main.py b/addons/website_slides/controllers/main.py
index b271560a6b4..8691313dc88 100644
--- a/addons/website_slides/controllers/main.py
+++ b/addons/website_slides/controllers/main.py
@@ -1024,19 +1024,18 @@ class WebsiteSlides(WebsiteProfile):
# minutes to hours conversion
values['completion_time'] = int(post['duration']) / 60
+ category_id = False
# handle creation of new categories on the fly
if post.get('category_id'):
- if post['category_id'][0] == 0:
+ category_id = post['category_id'][0]
+ if category_id == 0:
category = request.env['slide.slide'].create(self._get_new_slide_category_values(channel, post['category_id'][1]['name']))
- values['category_id'] = category.id
values['sequence'] = category.sequence + 1
+ category_id = category.id
else:
values.update({
- 'category_id': post['category_id'][0],
'sequence': request.env['slide.slide'].browse(post['category_id'][0]).sequence + 1
})
- else:
- values['sequence'] = -1
# create slide itself
try:
@@ -1051,7 +1050,7 @@ class WebsiteSlides(WebsiteProfile):
return {'error': _('Internal server error, please try again later or contact administrator.\nHere is the error message: %s') % e}
# ensure correct ordering by re sequencing slides in front-end (backend should be ok thanks to list view)
- channel._resequence_slides(slide)
+ channel._resequence_slides(slide, category_id)
redirect_url = "/slides/slide/%s" % (slide.id)
if channel.channel_type == "training" and not slide.slide_type == "webpage":