From c9ace2713560905ea2aa5905e5ebe70312cd57ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Hennecart?= Date: Fri, 27 Dec 2019 06:50:45 +0000 Subject: [PATCH] [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 --- addons/website_slides/controllers/main.py | 17 +++++++++++--- .../views/website_slides_templates_course.xml | 23 +++++++++++-------- 2 files changed, 27 insertions(+), 13 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//tag/', '/slides//tag//page/', '/slides//category/', - '/slides//category//page/' + '/slides//category//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) diff --git a/addons/website_slides/views/website_slides_templates_course.xml b/addons/website_slides/views/website_slides_templates_course.xml index 6f8887a8345..ab253f7ebb0 100644 --- a/addons/website_slides/views/website_slides_templates_course.xml +++ b/addons/website_slides/views/website_slides_templates_course.xml @@ -549,6 +549,12 @@ t-att-data-can-publish="channel.can_publish"> Upload new content + + Add a section +
@@ -592,11 +598,14 @@
-
- + + +
+
+ View all
@@ -609,14 +618,8 @@
- - -
- -
-
- +