[MOV] website_rating: move to portal_rating
PURPOSE Clean posting process and improve mail.message definition and comprehension. Move as much possible content from website_* modules to portal_* modules to ease their use in customer portal SPECIFICATIONS Now that publish feature is replaced by internal directly in mail and portal rating portal inclusion can be done safely in a portal_ratign module instead of website_rating. It allows to remove the dependency and give the rating feature of customer chatter directly in portal applications. LINKS Task ID 2071556 PR #38692
This commit is contained in:
@@ -119,7 +119,7 @@
|
||||
<button class="btn btn-danger"
|
||||
title="Currently restricted to internal employees, click to make it available to everyone viewing this document.">Employees Only</button>
|
||||
<button class="btn btn-success"
|
||||
title="Current available to everyone viewing this document, click to restrict to internal employees.">Visible</button>
|
||||
title="Currently available to everyone viewing this document, click to restrict to internal employees.">Visible</button>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
|
||||
@@ -2,13 +2,17 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
{
|
||||
'name': 'Website Rating',
|
||||
'name': 'Portal Rating',
|
||||
'category': 'Hidden',
|
||||
'version': '1.0',
|
||||
'description': """
|
||||
Bridge module for rating on website stuff.
|
||||
Bridge module adding rating capabilities on portal. It includes notably
|
||||
inclusion of rating directly within the customer portal discuss widget.
|
||||
""",
|
||||
'depends': ['rating', 'website_mail'],
|
||||
'depends': [
|
||||
'portal',
|
||||
'rating',
|
||||
],
|
||||
'data': [
|
||||
'views/assets.xml',
|
||||
'views/rating_views.xml',
|
||||
+5
-5
@@ -30,8 +30,8 @@ PortalChatter.include({
|
||||
}),
|
||||
xmlDependencies: (PortalChatter.prototype.xmlDependencies || [])
|
||||
.concat([
|
||||
'/website_rating/static/src/xml/portal_tools.xml',
|
||||
'/website_rating/static/src/xml/portal_chatter.xml'
|
||||
'/portal_rating/static/src/xml/portal_tools.xml',
|
||||
'/portal_rating/static/src/xml/portal_chatter.xml'
|
||||
]),
|
||||
|
||||
/**
|
||||
@@ -256,7 +256,7 @@ PortalChatter.include({
|
||||
|
||||
var oldRating = this.messages[messageIndex].rating;
|
||||
data.rating.publisher_comment = oldRating.publisher_comment ? oldRating.publisher_comment : '';
|
||||
this._getCommentContainer($source).html($(qweb.render("website_rating.chatter_rating_publisher_form", data)));
|
||||
this._getCommentContainer($source).html($(qweb.render("portal_rating.chatter_rating_publisher_form", data)));
|
||||
this._focusTextComment($source);
|
||||
},
|
||||
|
||||
@@ -309,7 +309,7 @@ PortalChatter.include({
|
||||
if (self.messages[messageIndex].rating.publisher_comment !== '') {
|
||||
// Remove the button comment if exist and render the comment
|
||||
self._getCommentButton($source).addClass('d-none');
|
||||
self._getCommentContainer($source).html($(qweb.render("website_rating.chatter_rating_publisher_comment", {
|
||||
self._getCommentContainer($source).html($(qweb.render("portal_rating.chatter_rating_publisher_comment", {
|
||||
rating: self.messages[messageIndex].rating,
|
||||
is_publisher: self.options.is_user_publisher
|
||||
})));
|
||||
@@ -335,7 +335,7 @@ PortalChatter.include({
|
||||
rating: this.messages[messageIndex].rating,
|
||||
is_publisher: this.options.is_user_publisher
|
||||
};
|
||||
this._getCommentContainer($source).html($(qweb.render("website_rating.chatter_rating_publisher_comment", data)));
|
||||
this._getCommentContainer($source).html($(qweb.render("portal_rating.chatter_rating_publisher_comment", data)));
|
||||
} else {
|
||||
this._getCommentContainer($source).empty();
|
||||
}
|
||||
+3
-3
@@ -16,11 +16,11 @@ var STAR_RATING_RATIO = 2; // conversion factor from the star (1-5) to the db r
|
||||
* a popup with the portal composer when clicking on it.
|
||||
**/
|
||||
var RatingPopupComposer = publicWidget.Widget.extend({
|
||||
template: 'website_rating.PopupComposer',
|
||||
template: 'portal_rating.PopupComposer',
|
||||
xmlDependencies: [
|
||||
'/portal/static/src/xml/portal_chatter.xml',
|
||||
'/website_rating/static/src/xml/portal_tools.xml',
|
||||
'/website_rating/static/src/xml/portal_rating_composer.xml',
|
||||
'/portal_rating/static/src/xml/portal_tools.xml',
|
||||
'/portal_rating/static/src/xml/portal_rating_composer.xml',
|
||||
],
|
||||
|
||||
init: function (parent, options) {
|
||||
+8
-8
@@ -9,7 +9,7 @@
|
||||
<attribute name="t-attf-action">#{widget.options['force_submit_url'] ? widget.options['force_submit_url'] : '/mail/chatter_post'}</attribute>
|
||||
</t>
|
||||
<t t-jquery=".o_portal_chatter_composer_form input[name='csrf_token']" t-operation="after">
|
||||
<t t-call="website_rating.rating_star_input">
|
||||
<t t-call="portal_rating.rating_star_input">
|
||||
<t t-set="default_rating" t-value="widget.options['default_rating_value']"/>
|
||||
</t>
|
||||
<input type="hidden" name="message_id" t-att-value="widget.options['default_message_id']" t-if="widget.options['default_message_id']"/>
|
||||
@@ -19,7 +19,7 @@
|
||||
<t t-extend="portal.chatter_messages">
|
||||
<t t-jquery="t[t-raw='message.body']" t-operation="before">
|
||||
<t t-if="message['rating_value']">
|
||||
<t t-call="website_rating.rating_stars_static">
|
||||
<t t-call="portal_rating.rating_stars_static">
|
||||
<t t-set="val" t-value="message.rating_value"/>
|
||||
</t>
|
||||
</t>
|
||||
@@ -28,7 +28,7 @@
|
||||
<!--Only possible if a rating is link to the message, for now we can't comment if no rating
|
||||
is link to the message (because publisher comment data
|
||||
is on the rating.rating model - one comment max) -->
|
||||
<t t-if="message.rating and message.rating.id" t-call="website_rating.chatter_rating_publisher">
|
||||
<t t-if="message.rating and message.rating.id" t-call="portal_rating.chatter_rating_publisher">
|
||||
<t t-set="is_publisher" t-value="widget.options['is_user_publisher']"/>
|
||||
<t t-set="rating" t-value="message.rating"/>
|
||||
</t>
|
||||
@@ -38,7 +38,7 @@
|
||||
<t t-extend="portal.Chatter">
|
||||
<t t-jquery="t[t-call='portal.chatter_message_count']" t-operation="replace">
|
||||
<t t-if="widget.options['display_rating']">
|
||||
<t t-call="website_rating.rating_card"/>
|
||||
<t t-call="portal_rating.rating_card"/>
|
||||
</t>
|
||||
<t t-if="!widget.options['display_rating']">
|
||||
<t t-call="portal.chatter_message_count"/>
|
||||
@@ -49,7 +49,7 @@
|
||||
<!--
|
||||
New templates specific of rating in Chatter
|
||||
-->
|
||||
<t t-name="website_rating.chatter_rating_publisher">
|
||||
<t t-name="portal_rating.chatter_rating_publisher">
|
||||
<div class="o_wrating_publisher_container">
|
||||
<button t-if="is_publisher"
|
||||
t-attf-class="btn px-2 btn-sm border o_wrating_js_publisher_comment_btn {{ rating.publisher_comment !== '' ? 'd-none' : '' }}"
|
||||
@@ -57,12 +57,12 @@
|
||||
<i class="fa fa-comment text-muted mr-1"/>Comment
|
||||
</button>
|
||||
<div class="o_wrating_publisher_comment mt-2 mb-2">
|
||||
<t t-if="rating.publisher_comment" t-call="website_rating.chatter_rating_publisher_comment"/>
|
||||
<t t-if="rating.publisher_comment" t-call="portal_rating.chatter_rating_publisher_comment"/>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
<t t-name="website_rating.chatter_rating_publisher_comment">
|
||||
<t t-name="portal_rating.chatter_rating_publisher_comment">
|
||||
<div class="media o_portal_chatter_message">
|
||||
<img class="o_portal_chatter_avatar" t-att-src="rating.publisher_avatar" alt="avatar"/>
|
||||
<div class="media-body">
|
||||
@@ -89,7 +89,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
<t t-name="website_rating.chatter_rating_publisher_form">
|
||||
<t t-name="portal_rating.chatter_rating_publisher_form">
|
||||
<div t-if="is_publisher" class="media o_portal_chatter_message shadow bg-white rounded px-3 py-3 my-1">
|
||||
<img class="o_portal_chatter_avatar" t-att-src="rating.publisher_avatar" alt="avatar"/>
|
||||
<div class="media-body">
|
||||
+2
-2
@@ -4,10 +4,10 @@
|
||||
Popup Rating Composer Widget
|
||||
It can alse be used to modify a message
|
||||
-->
|
||||
<t t-name="website_rating.PopupComposer">
|
||||
<t t-name="portal_rating.PopupComposer">
|
||||
<div class="d-flex flex-wrap align-items-center">
|
||||
<div class="text-nowrap">
|
||||
<t t-call="website_rating.rating_stars_static">
|
||||
<t t-call="portal_rating.rating_stars_static">
|
||||
<t t-set="val" t-value="widget.rating_avg || 0"/>
|
||||
<t t-set="inline_mode" t-value="true"/>
|
||||
</t>
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates id="template" xml:space="preserve">
|
||||
<t t-name="website_rating.rating_stars_static">
|
||||
<t t-name="portal_rating.rating_stars_static">
|
||||
<t t-set="val_integer" t-value="Math.floor(val)"/>
|
||||
<t t-set="val_decimal" t-value="val - val_integer"/>
|
||||
<t t-set="empty_star" t-value="5 - (val_integer+Math.ceil(val_decimal))"/>
|
||||
@@ -17,13 +17,13 @@
|
||||
</div>
|
||||
</t>
|
||||
|
||||
<t t-name="website_rating.rating_card">
|
||||
<t t-name="portal_rating.rating_card">
|
||||
<div class="row o_website_rating_card_container">
|
||||
<div class="col-lg-3 offset-lg-2" t-if="!_.isEmpty(widget.get('rating_card_values'))">
|
||||
<p><strong>Average</strong></p>
|
||||
<div class="o_website_rating_avg text-center">
|
||||
<h1><t t-esc="widget.get('rating_card_values')['avg']"/></h1>
|
||||
<t t-call="website_rating.rating_stars_static">
|
||||
<t t-call="portal_rating.rating_stars_static">
|
||||
<t t-set="val" t-value="widget.get('rating_card_values')['avg'] || 0"/>
|
||||
</t>
|
||||
<t t-call="portal.chatter_message_count"/>
|
||||
@@ -61,7 +61,7 @@
|
||||
</div>
|
||||
</t>
|
||||
|
||||
<t t-name="website_rating.rating_star_input">
|
||||
<t t-name="portal_rating.rating_star_input">
|
||||
<div class="o_rating_star_card" t-if="widget.options['display_rating']">
|
||||
<t t-set="val_integer" t-value="Math.floor(default_rating)"/>
|
||||
<t t-set="val_decimal" t-value="default_rating - val_integer"/>
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<template id="assets_frontend" inherit_id="web_editor.assets_frontend" name="Portal Rating Assets">
|
||||
<xpath expr="//link[last()]" position="after">
|
||||
<link rel="stylesheet" type="text/scss" href="/portal_rating/static/src/scss/portal_rating.scss"/>
|
||||
</xpath>
|
||||
<xpath expr="//script[last()]" position="after">
|
||||
<script type="text/javascript" src="/portal_rating/static/src/js/portal_chatter.js"></script>
|
||||
<script type="text/javascript" src="/portal_rating/static/src/js/portal_composer.js"></script>
|
||||
<script type="text/javascript" src="/portal_rating/static/src/js/portal_rating_composer.js"></script>
|
||||
</xpath>
|
||||
</template>
|
||||
</odoo>
|
||||
@@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<template id="assets_frontend" inherit_id="web_editor.assets_frontend" name="Portal Rating Assets">
|
||||
<xpath expr="//link[last()]" position="after">
|
||||
<link rel="stylesheet" type="text/scss" href="/website_rating/static/src/scss/website_rating.scss"/>
|
||||
</xpath>
|
||||
<xpath expr="//script[last()]" position="after">
|
||||
<script type="text/javascript" src="/website_rating/static/src/js/portal_chatter.js"></script>
|
||||
<script type="text/javascript" src="/website_rating/static/src/js/portal_composer.js"></script>
|
||||
<script type="text/javascript" src="/website_rating/static/src/js/portal_rating_composer.js"></script>
|
||||
</xpath>
|
||||
</template>
|
||||
</odoo>
|
||||
@@ -6,7 +6,7 @@
|
||||
'website': 'https://www.odoo.com/page/e-commerce',
|
||||
'version': '1.0',
|
||||
'description': "",
|
||||
'depends': ['website', 'sale', 'website_payment', 'website_mail', 'website_form', 'website_rating', 'digest'],
|
||||
'depends': ['website', 'sale', 'website_payment', 'website_mail', 'website_form', 'portal_rating', 'digest'],
|
||||
'data': [
|
||||
'security/ir.model.access.csv',
|
||||
'security/website_sale.xml',
|
||||
|
||||
@@ -1243,7 +1243,7 @@ class WebsiteSale(http.Controller):
|
||||
res_product.update(combination_info)
|
||||
res_product['price'] = FieldMonetary.value_to_html(res_product['price'], monetary_options)
|
||||
if rating:
|
||||
res_product['rating'] = request.env["ir.ui.view"].render_template('website_rating.rating_widget_stars_static', values={
|
||||
res_product['rating'] = request.env["ir.ui.view"].render_template('portal_rating.rating_widget_stars_static', values={
|
||||
'rating_avg': product.rating_avg,
|
||||
'rating_count': product.rating_count,
|
||||
})
|
||||
|
||||
@@ -20,10 +20,11 @@ Featuring
|
||||
* Statistics
|
||||
""",
|
||||
'depends': [
|
||||
'portal_rating',
|
||||
'website',
|
||||
'website_mail',
|
||||
'website_profile',
|
||||
'website_rating'],
|
||||
],
|
||||
'data': [
|
||||
'views/assets.xml',
|
||||
'views/res_config_settings_views.xml',
|
||||
|
||||
@@ -10,8 +10,8 @@ var QWeb = core.qweb;
|
||||
|
||||
var FieldFloatRating = basicFields.FieldFloat.extend({
|
||||
xmlDependencies: !basicFields.FieldFloat.prototype.xmlDependencies ?
|
||||
['/website_rating/static/src/xml/portal_tools.xml'] : basicFields.FieldFloat.prototype.xmlDependencies.concat(
|
||||
['/website_rating/static/src/xml/portal_tools.xml']
|
||||
['/portal_rating/static/src/xml/portal_tools.xml'] : basicFields.FieldFloat.prototype.xmlDependencies.concat(
|
||||
['/portal_rating/static/src/xml/portal_tools.xml']
|
||||
),
|
||||
//--------------------------------------------------------------------------
|
||||
// Private
|
||||
@@ -25,7 +25,7 @@ var FieldFloatRating = basicFields.FieldFloat.extend({
|
||||
var self = this;
|
||||
|
||||
return Promise.resolve(this._super()).then(function () {
|
||||
self.$el.html(QWeb.render('website_rating.rating_stars_static', {
|
||||
self.$el.html(QWeb.render('portal_rating.rating_stars_static', {
|
||||
'val': self.value / 2,
|
||||
'inline_mode': true
|
||||
}));
|
||||
|
||||
@@ -137,7 +137,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex flex-column justify-content-center h5 flex-grow-1 mb-md-5" t-if="channel.allow_comment">
|
||||
<t t-call="website_rating.rating_stars_static_popup_composer">
|
||||
<t t-call="portal_rating.rating_stars_static_popup_composer">
|
||||
<t t-set="btn_classes" t-value="'btn-warning'"/>
|
||||
<t t-set="rating_avg" t-value="rating_avg"/>
|
||||
<t t-set="rating_total" t-value="rating_count"/>
|
||||
|
||||
Reference in New Issue
Block a user