diff options
| author | jem-odoo <jem@openerp.com> | 2019-02-18 09:31:57 +0000 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2019-02-21 16:38:14 +0000 |
| commit | 7d1af42c0630d02b2027d07dd3d20aec3d22ccbe (patch) | |
| tree | 7bf2e6e365c1e1cab9cb25d2ae860de003b0395d | |
| parent | 55f93a240fcfa7d153435d7198632b8a2a50120e (diff) | |
[FIX] website_slides: fix some rating issues
Last review should be a comment. When fetching the last message on a course
the returned message can be a system notification (like "Channel created").
This is not what we want, mostly with the feature allowing to modify the body
of a message. This commit add restriction on the domain fetch last message.
Fix default rating value on popup widget. The conversation ratio (rating 1-10
and 5 stars) was not applied everywhere. So, the number of displayed stars was
doubled. This is now fixed.
Commit linked to task ID 1941250 and PR #31317.
5 files changed, 12 insertions, 5 deletions
diff --git a/addons/website_rating/static/src/js/website_mail.js b/addons/website_rating/static/src/js/website_mail.js index 8f21f740c98..6fd9a305e95 100644 --- a/addons/website_rating/static/src/js/website_mail.js +++ b/addons/website_rating/static/src/js/website_mail.js @@ -33,6 +33,11 @@ odoo.define('website_rating.thread', function(require) { init: function(parent, options){ this._super.apply(this, arguments); + // apply ratio to default rating value + if (options.default_rating_value) { + options.default_rating_value = parseFloat(options.default_rating_value) / STAR_RATING_RATIO; + } + // default options this.options = _.defaults(this.options, { 'default_message': false, @@ -50,7 +55,7 @@ odoo.define('website_rating.thread', function(require) { '5': _t("I love it"), }; this.user_click = false; // user has click or not - this.set("star_value", this.options.rating_default_value); + this.set("star_value", this.options.default_rating_value); this.on("change:star_value", this, this._onChangeStarValue); }, start: function(){ @@ -59,7 +64,7 @@ odoo.define('website_rating.thread', function(require) { // rating stars self.$input = self.$('input[name="rating_value"]'); self.$star_list = self.$('.stars').find('i'); - self.set("star_value", self.options.rating_default_value); // set the default value to trigger the display of star widget + self.set("star_value", self.options.default_rating_value); // set the default value to trigger the display of star widget }); }, @@ -265,7 +270,7 @@ odoo.define('website_rating.thread', function(require) { _onChangeRatingDomain: function(){ var domain = []; if(this.get('rating_value')){ - domain = [['rating_value', '=', this.get('rating_value')]]; + domain = [['rating_value', '=', this.get('rating_value') * STAR_RATING_RATIO]]; } this._changeCurrentPage(1, domain); }, diff --git a/addons/website_rating/static/src/xml/website_mail.xml b/addons/website_rating/static/src/xml/website_mail.xml index 11534a768c2..d4e8dd83218 100644 --- a/addons/website_rating/static/src/xml/website_mail.xml +++ b/addons/website_rating/static/src/xml/website_mail.xml @@ -79,7 +79,7 @@ <div class="rate_text"> <span class="badge badge-info"></span> </div> - <input type="hidden" readonly="readonly" name="rating_value" t-att-value="default_rating"/> + <input type="hidden" readonly="readonly" name="rating_value" t-att-value="default_rating || ''"/> </div> </t> diff --git a/addons/website_rating/views/website_rating_templates.xml b/addons/website_rating/views/website_rating_templates.xml index 32dc3d3c573..8ce20495b32 100644 --- a/addons/website_rating/views/website_rating_templates.xml +++ b/addons/website_rating/views/website_rating_templates.xml @@ -18,7 +18,7 @@ Rating widget static: show 5 stars (full or empty) regarding the given rating_avg and rating_count --> <template id="rating_widget_stars_static" name="Rating: static star widget"> - <t t-set="rating_avg" t-value="round(rating_avg * 100) / 100"/> + <t t-set="rating_avg" t-value="round(rating_avg * 100) / 100 / 2"/> <t t-set="val_decimal" t-value="round(rating_avg % 1, 1)"/> <t t-set="val_integer" t-value="int(rating_avg)"/> <t t-set="empty_star" t-value="5 - (val_integer+1) if val_decimal else 5 - val_integer"/> diff --git a/addons/website_slides/controllers/mail.py b/addons/website_slides/controllers/mail.py index 1273ebe1119..5ec41d9de88 100644 --- a/addons/website_slides/controllers/mail.py +++ b/addons/website_slides/controllers/mail.py @@ -33,6 +33,7 @@ class SlidesMail(http.Controller): ('res_id', '=', res_id), ('website_published', '=', True), ('author_id', '=', request.env.user.partner_id.id), + ('message_type', '=', 'comment'), ('id', '=', message_id) ] # restrict to the given message_id message = request.env['mail.message'].search(domain, limit=1) diff --git a/addons/website_slides/controllers/main.py b/addons/website_slides/controllers/main.py index 73f7de00384..9b9eda1442e 100644 --- a/addons/website_slides/controllers/main.py +++ b/addons/website_slides/controllers/main.py @@ -300,6 +300,7 @@ class WebsiteSlides(WebsiteProfile): ('model', '=', channel._name), ('res_id', '=', channel.id), ('author_id', '=', request.env.user.partner_id.id), + ('message_type', '=', 'comment'), ('website_published', '=', True) ], order='write_date DESC', limit=1).read(['body', 'rating_value']) last_message_data = last_message_values[0] if last_message_values else {} |
