From 5e59ced9ca43b30ef7eae3e50f24f338ae1a9b85 Mon Sep 17 00:00:00 2001 From: ijas ahammed Date: Tue, 17 Nov 2020 13:37:05 +0000 Subject: [PATCH] [IMP] website_slides: separate backend tags from frontend tags Backend tags are generally used internally for classification or daily process. Frontend tags are used for filtering and menu definitions. These two type of tags are not managed separately in eLearning channels right now. This commit separates backend and frontend tags using the color field. Along with that, it improves the following : Frontend - only displays channel tags that has color set; - avoids showing void tag group / menu (without any frontend tags); Backend - prevents access of the backend tags for portal/public users with a record rule (similar to online events); - adds 'Tags (tag_ids)' field in the list view of 'Course Groups' that shows all the tags (frontend as well as backend); - hides the colorless tags in slide channel kanban; - improves the form view for course channel tags; Frontend and Backend - adds a default color value while creating a new channel tag Task ID-2357942 PR odoo/odoo#62138 Signed-off-by: Thibault Delavallee (tde) --- .../models/slide_channel_tag.py | 6 +++- .../security/website_slides_security.xml | 11 ++++++ .../static/src/js/slides_course_tag_add.js | 2 +- .../views/slide_channel_tag_views.xml | 35 ++++++++++--------- .../views/slide_channel_views.xml | 2 +- .../views/website_slides_templates_course.xml | 9 ++--- .../website_slides_templates_homepage.xml | 10 +++--- .../website_slides_templates_profile.xml | 2 +- 8 files changed, 48 insertions(+), 29 deletions(-) diff --git a/addons/website_slides/models/slide_channel_tag.py b/addons/website_slides/models/slide_channel_tag.py index 67c62cf742d..04cea1657f9 100644 --- a/addons/website_slides/models/slide_channel_tag.py +++ b/addons/website_slides/models/slide_channel_tag.py @@ -1,6 +1,8 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. +from random import randint + from odoo import fields, models @@ -30,4 +32,6 @@ class SlideChannelTag(models.Model): 'Group sequence', related='group_id.sequence', index=True, readonly=True, store=True) channel_ids = fields.Many2many('slide.channel', 'slide_channel_tag_rel', 'tag_id', 'channel_id', string='Channels') - color = fields.Integer(string='Color Index', help="Color to apply to this tag (including in website).") + color = fields.Integer( + string='Color Index', default=lambda self: randint(1, 11), + help="Tag color used in both backend and website. No color means no display in kanban or front-end, to distinguish internal tags from public categorization tags") diff --git a/addons/website_slides/security/website_slides_security.xml b/addons/website_slides/security/website_slides_security.xml index ab800865dd0..f8689d090ce 100644 --- a/addons/website_slides/security/website_slides_security.xml +++ b/addons/website_slides/security/website_slides_security.xml @@ -75,6 +75,17 @@ + + Channel Tag: public/portal: color = published + + ['&', ('color', '!=', False), ('color', '!=', 0)] + + + + + + + Slide: always visible (sub rules exist) diff --git a/addons/website_slides/static/src/js/slides_course_tag_add.js b/addons/website_slides/static/src/js/slides_course_tag_add.js index b62e9cf0809..9fbbbec502e 100644 --- a/addons/website_slides/static/src/js/slides_course_tag_add.js +++ b/addons/website_slides/static/src/js/slides_course_tag_add.js @@ -67,7 +67,7 @@ var TagCourseDialog = Dialog.extend({ route: '/slides/channel/tag/search_read', params: { fields: ['name'], - domain: [['id','not in',self.tagIds]], + domain: [['id', 'not in', self.tagIds], ['color', '!=', 0]], } }); }) diff --git a/addons/website_slides/views/slide_channel_tag_views.xml b/addons/website_slides/views/slide_channel_tag_views.xml index b4c4e9ab12e..7edb459c7c3 100644 --- a/addons/website_slides/views/slide_channel_tag_views.xml +++ b/addons/website_slides/views/slide_channel_tag_views.xml @@ -63,24 +63,24 @@
+
+
-
-
+ + + + + + + + + + +
@@ -95,6 +95,7 @@ +
diff --git a/addons/website_slides/views/slide_channel_views.xml b/addons/website_slides/views/slide_channel_views.xml index 04a6363fc94..371b3f5602c 100644 --- a/addons/website_slides/views/slide_channel_views.xml +++ b/addons/website_slides/views/slide_channel_views.xml @@ -245,7 +245,7 @@
- +
diff --git a/addons/website_slides/views/website_slides_templates_course.xml b/addons/website_slides/views/website_slides_templates_course.xml index 3be29e4f2aa..c65fd96fc70 100644 --- a/addons/website_slides/views/website_slides_templates_course.xml +++ b/addons/website_slides/views/website_slides_templates_course.xml @@ -168,6 +168,7 @@
+
@@ -198,8 +199,8 @@
- - + + @@ -699,8 +700,8 @@
- - + + diff --git a/addons/website_slides/views/website_slides_templates_homepage.xml b/addons/website_slides/views/website_slides_templates_homepage.xml index 48360fae5a6..132602a2dfd 100644 --- a/addons/website_slides/views/website_slides_templates_homepage.xml +++ b/addons/website_slides/views/website_slides_templates_homepage.xml @@ -215,7 +215,8 @@