From 12c6d77e7f4ebdbe099ce35c7c7dbd326e33dd50 Mon Sep 17 00:00:00 2001 From: qmo-odoo Date: Mon, 30 Dec 2019 08:17:23 +0000 Subject: [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 --- addons/website_slides/tests/test_slide_utils.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'addons/website_slides/tests/test_slide_utils.py') diff --git a/addons/website_slides/tests/test_slide_utils.py b/addons/website_slides/tests/test_slide_utils.py index 489f2de0d0f..b4e58b0bbfd 100644 --- a/addons/website_slides/tests/test_slide_utils.py +++ b/addons/website_slides/tests/test_slide_utils.py @@ -5,6 +5,25 @@ from odoo.addons.website_slides.tests import common as slides_common from odoo.tests.common import users +class TestSlidesManagement(slides_common.SlidesCase): + + @users('user_officer') + def test_get_categorized_slides(self): + new_category = self.env['slide.slide'].create({ + 'name': 'Cooking Tips for Cooking Humans', + 'channel_id': self.channel.id, + 'is_category': True, + 'sequence': 5, + }) + order = self.env['slide.slide']._order_by_strategy['sequence'] + categorized_slides = self.channel._get_categorized_slides([], order) + self.assertEqual(categorized_slides[0]['category'], False) + self.assertEqual(categorized_slides[1]['category'], self.category) + self.assertEqual(categorized_slides[1]['total_slides'], 2) + self.assertEqual(categorized_slides[2]['total_slides'], 0) + self.assertEqual(categorized_slides[2]['category'], new_category) + + class TestSequencing(slides_common.SlidesCase): @users('user_officer') -- cgit v1.2.3