summaryrefslogtreecommitdiff
path: root/addons/website_slides/controllers
diff options
context:
space:
mode:
authorJérémy Hennecart <jeh@odoo.com>2019-12-27 06:50:45 +0000
committerJérémy Hennecart <jeh@odoo.com>2020-02-12 12:55:35 +0000
commitc9ace2713560905ea2aa5905e5ebe70312cd57ab (patch)
tree8e5d7212108748837fda0d6f523f9f616191ad98 /addons/website_slides/controllers
parent67e49915b51ace0dd9b7e17bc0b6247c7cb77ffb (diff)
[IMP] website_slides: improve the ui on a course (documentation)
Before, uncategorized slides weren't display correctly on the slide_channel. It was impossible to view all the slides if there were more than 4 slides uncategorized because the "View all" link wasn't display. Now, when there is no section/category on a course, it displays the last 4 slides with the "View all" link which allows to be redirected to the uncategorized category (category_id=-1). This request displays all the uncategorized slides with a pager if the limit of 12 slides per page is exceeded. If there is at least one category created, all uncategorized slides are displayed under a section "Uncategorized". Additionaly, there is a new button which allows to create a category directly on the course page to allow the user to organize is course more effectively. task-2161391
Diffstat (limited to 'addons/website_slides/controllers')
-rw-r--r--addons/website_slides/controllers/main.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/addons/website_slides/controllers/main.py b/addons/website_slides/controllers/main.py
index 05d4b455b06..ee023857b95 100644
--- a/addons/website_slides/controllers/main.py
+++ b/addons/website_slides/controllers/main.py
@@ -348,9 +348,12 @@ class WebsiteSlides(WebsiteProfile):
'/slides/<model("slide.channel"):channel>/tag/<model("slide.tag"):tag>',
'/slides/<model("slide.channel"):channel>/tag/<model("slide.tag"):tag>/page/<int:page>',
'/slides/<model("slide.channel"):channel>/category/<model("slide.slide"):category>',
- '/slides/<model("slide.channel"):channel>/category/<model("slide.slide"):category>/page/<int:page>'
+ '/slides/<model("slide.channel"):channel>/category/<model("slide.slide"):category>/page/<int:page>',
], type='http', auth="public", website=True, sitemap=sitemap_slide)
def channel(self, channel, category=None, tag=None, page=1, slide_type=None, uncategorized=False, sorting=None, search=None, **kw):
+ """
+ Will return all necessary data to display the requested slide_channel along with a possible category.
+ """
if not channel.can_access_from_current_website():
raise werkzeug.exceptions.NotFound()
@@ -376,7 +379,7 @@ class WebsiteSlides(WebsiteProfile):
pager_url += "/tag/%s" % tag.id
if uncategorized:
domain += [('category_id', '=', False)]
- pager_url += "?uncategorized=1"
+ pager_args['uncategorized'] = 1
elif slide_type:
domain += [('slide_type', '=', slide_type)]
pager_url += "?slide_type=%s" % slide_type
@@ -463,10 +466,18 @@ class WebsiteSlides(WebsiteProfile):
# documentation mode may display less slides than content by category but overhead of
# computation is reasonable
values['slide_promoted'] = request.env['slide.slide'].sudo().search(domain, limit=1, order=order)
+
+ limit_category_data = False
+ if channel.channel_type == 'documentation':
+ if category or uncategorized:
+ limit_category_data = self._slides_per_page
+ else:
+ limit_category_data = self._slides_per_category
+
values['category_data'] = channel._get_categorized_slides(
domain, order,
force_void=not category,
- limit=False if channel.channel_type != 'documentation' else self._slides_per_page if category else self._slides_per_category,
+ limit=limit_category_data,
offset=pager['offset'])
values['channel_progress'] = self._get_channel_progress(channel, include_quiz=True)