[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) <tde@openerp.com>
This commit is contained in:
committed by
Thibault Delavallée
parent
877d1ab20f
commit
5e59ced9ca
@@ -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")
|
||||
|
||||
@@ -75,6 +75,17 @@
|
||||
<field name="perm_create" eval="1"/>
|
||||
</record>
|
||||
|
||||
<record id="rule_slide_channel_tag_public" model="ir.rule">
|
||||
<field name="name">Channel Tag: public/portal: color = published</field>
|
||||
<field name="model_id" ref="model_slide_channel_tag"/>
|
||||
<field name="domain_force">['&', ('color', '!=', False), ('color', '!=', 0)]</field>
|
||||
<field name="groups" eval="[(4, ref('base.group_public')), (4, ref('base.group_portal'))]"/>
|
||||
<field name="perm_read" eval="True"/>
|
||||
<field name="perm_write" eval="False"/>
|
||||
<field name="perm_create" eval="False"/>
|
||||
<field name="perm_unlink" eval="False"/>
|
||||
</record>
|
||||
|
||||
<!-- SLIDE -->
|
||||
<record id="rule_slide_slide_global" model="ir.rule">
|
||||
<field name="name">Slide: always visible (sub rules exist)</field>
|
||||
|
||||
@@ -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]],
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
@@ -63,24 +63,24 @@
|
||||
<field name="arch" type="xml">
|
||||
<form string="Course Tag Group">
|
||||
<sheet>
|
||||
<div class="oe_title">
|
||||
<label for="name" class="oe_edit_only" string="Course Group Name"/>
|
||||
<h1><field name="name" default_focus="1" placeholder="Course Group Name"/></h1>
|
||||
<label for="is_published" string="Menu Entry"/>
|
||||
<field name="is_published"/><br/>
|
||||
</div>
|
||||
<group>
|
||||
<div class="oe_title">
|
||||
<label for="name" class="oe_edit_only" string="Group Name"/>
|
||||
<h1><field name="name" default_focus="1" placeholder="Group Name"/></h1>
|
||||
<label for="is_published" string="Menu Entry"/>
|
||||
<field name="is_published"/><br/>
|
||||
<field name="tag_ids">
|
||||
<tree editable="bottom">
|
||||
<field name="sequence" widget="handle"/>
|
||||
<field name="group_sequence" invisible="1"/>
|
||||
<field name="name" string="Tag Name"/>
|
||||
<field name="color" string="Color" widget="color_picker"/>
|
||||
<control>
|
||||
<create string="Add a tag"/>
|
||||
</control>
|
||||
</tree>
|
||||
</field>
|
||||
</div>
|
||||
<field name="tag_ids">
|
||||
<tree editable="bottom">
|
||||
<field name="sequence" widget="handle"/>
|
||||
<field name="group_sequence" invisible="1"/>
|
||||
<field name="name" string="Tag Name"/>
|
||||
<field name="color" string="Color" widget="color_picker"/>
|
||||
<control>
|
||||
<create string="Add a tag"/>
|
||||
</control>
|
||||
</tree>
|
||||
</field>
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
@@ -95,6 +95,7 @@
|
||||
<field name="sequence" widget="handle"/>
|
||||
<field name="name"/>
|
||||
<field name="is_published" string="Menu Entry"/>
|
||||
<field name="tag_ids" widget="many2many_tags" options="{'color_field': 'color'}"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -245,7 +245,7 @@
|
||||
</a>
|
||||
</div>
|
||||
<div t-if="record.tag_ids">
|
||||
<field name="tag_ids" widget="many2many_tags"/>
|
||||
<field name="tag_ids" widget="many2many_tags" options="{'color_field': 'color'}"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -168,6 +168,7 @@
|
||||
</t>
|
||||
|
||||
<div class="o_wslides_course_main">
|
||||
<t t-set="channel_frontend_tags" t-value="channel.tag_ids.filtered(lambda tag: tag.color)"/>
|
||||
<!-- ========== TRAINING COURSE ========== -->
|
||||
<div t-if="channel.channel_type == 'training'" class="container">
|
||||
<div class="row">
|
||||
@@ -198,8 +199,8 @@
|
||||
<div class="tab-content py-4 o_wslides_tabs_content mb-4" id="courseMainTabContent">
|
||||
<div t-att-class="'tab-pane fade %s' % ('show active' if active_tab == 'home' else '')" id="home" role="tabpanel" aria-labelledby="home-tab">
|
||||
<div class="mb-2 pt-1">
|
||||
<t t-if="channel.tag_ids">
|
||||
<t t-foreach="channel.tag_ids" t-as="channel_tag">
|
||||
<t t-if="channel_frontend_tags">
|
||||
<t t-foreach="channel_frontend_tags" t-as="channel_tag">
|
||||
<span t-attf-class="badge o_wslides_channel_tag #{'o_tag_color_'+str(channel_tag.color)}" t-esc="channel_tag.name"/>
|
||||
</t>
|
||||
</t>
|
||||
@@ -699,8 +700,8 @@
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="mb-2 pt-1 text-left col">
|
||||
<t t-if="channel.tag_ids">
|
||||
<t t-foreach="channel.tag_ids" t-as="channel_tag">
|
||||
<t t-if="channel_frontend_tags">
|
||||
<t t-foreach="channel_frontend_tags" t-as="channel_tag">
|
||||
<span t-attf-class="badge o_wslides_channel_tag #{'o_tag_color_'+str(channel_tag.color)}" t-esc="channel_tag.name"/>
|
||||
</t>
|
||||
</t>
|
||||
|
||||
@@ -215,7 +215,8 @@
|
||||
<t t-set="search_tag_groups" t-value="search_tags.mapped('group_id')"/>
|
||||
<ul class="navbar-nav flex-grow-1">
|
||||
<t t-foreach="tag_groups" t-as="tag_group">
|
||||
<li t-att-class="'nav-item dropdown ml16 %s' % ('active' if tag_group in search_tag_groups else '')">
|
||||
<t t-set="group_frontend_tags" t-value="tag_group.tag_ids.filtered(lambda tag: tag.color)"/>
|
||||
<li t-att-class="'nav-item dropdown ml16 %s' % ('active' if tag_group in search_tag_groups else '')" t-if="group_frontend_tags">
|
||||
<a class="nav-link dropdown-toggle"
|
||||
href="/slides/all"
|
||||
t-att-data-target="'#navToogleTagGroup%s' % tag_group.id"
|
||||
@@ -223,7 +224,7 @@
|
||||
aria-haspopup="true" aria-expanded="false"
|
||||
t-esc="tag_group.name"/>
|
||||
<div class="dropdown-menu" t-att-id="'navToogleTagGroup%s' % tag_group.id">
|
||||
<t t-foreach="tag_group.tag_ids" t-as="tag">
|
||||
<t t-foreach="group_frontend_tags" t-as="tag">
|
||||
<a rel="nofollow" t-att-class="'dropdown-item post_link %s' % ('active' if tag in search_tags else '')"
|
||||
t-att-href="slide_query_url(tag=slugify_tags(search_tags.ids, toggle_tag_id=tag.id), my=search_my, search=search_term, slide_type=search_slide_type)"
|
||||
t-esc="tag.name"/>
|
||||
@@ -319,6 +320,7 @@
|
||||
<template id='course_card' name="Course Card">
|
||||
<div t-attf-class="card w-100 o_wslides_course_card mb-4 #{'o_wslides_course_unpublished' if not channel.is_published else ''}">
|
||||
<t t-set="course_image" t-value="website.image_url(channel, 'image_1024')"/>
|
||||
<t t-set="channel_frontend_tags" t-value="channel.tag_ids.filtered(lambda tag: tag.color)"/>
|
||||
<a t-attf-href="/slides/#{slug(channel)}" t-title="channel.name">
|
||||
<t t-if="channel.partner_has_new_content" t-call="website_slides.course_card_information"/>
|
||||
<div t-if="channel.image_1024" class="card-img-top" t-attf-style="padding-top: 50%; background-image: url(#{course_image}); background-size: cover; background-position:center"/>
|
||||
@@ -331,8 +333,8 @@
|
||||
<span t-if="not channel.is_published" class="badge badge-danger p-1">Unpublished</span>
|
||||
<div class="card-text mt-1">
|
||||
<div class="font-weight-light o_wslides_desc_truncate_3" t-field="channel.description_short"/>
|
||||
<div t-if="channel.tag_ids" class="mt-2 pt-1 o_wslides_desc_truncate_2">
|
||||
<t t-foreach="channel.tag_ids" t-as="tag">
|
||||
<div t-if="channel_frontend_tags" class="mt-2 pt-1 o_wslides_desc_truncate_2">
|
||||
<t t-foreach="channel_frontend_tags" t-as="tag">
|
||||
<t t-if="search_tags">
|
||||
<a t-att-href="slide_query_url(tag=slugify_tags(search_tags.ids, toggle_tag_id=tag.id), my=search_my, search=search_term, slide_type=search_slide_type)" t-attf-class="badge post_link #{'badge-primary' if tag in search_tags else 'o_wslides_channel_tag o_tag_color_0'}" t-att-rel="search_tags and 'nofollow'" t-esc="tag.name"/>
|
||||
</t>
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
<h5 class="mt-0 mb-1" t-field="course.channel_id.name"/>
|
||||
|
||||
<div class="overflow-hidden mb-1" style="height:24px">
|
||||
<t t-foreach="course.channel_id.tag_ids" t-as="tag">
|
||||
<t t-foreach="course.channel_id.tag_ids.filtered(lambda tag: tag.color)" t-as="tag">
|
||||
<a t-att-href="'/slides/all/tag/%s' % slug(tag)" t-attf-class="badge o_wslides_channel_tag post_link #{'o_tag_color_'+str(tag.color)}" t-esc="tag.name"/>
|
||||
</t>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user