From e4a4ffb974ccde1842e1b2389450718f8576ad5b Mon Sep 17 00:00:00 2001 From: "Benjamin Frantzen (bfr)" Date: Wed, 18 Dec 2019 13:45:38 +0000 Subject: [PATCH] [IMP] customer ratings flow improvements - Rename the 'Use Rating on Project' feature into 'Customer Ratings' - Rename the 'Set Email Template to Stages' link to 'Set a Rating Email Template on Stages' - Add an optional list view for the Stages menu - display warning if the rating_template_id field is set and if one of the selected project_ids doesn't have the rating_status field set to true - Project form view revamp - rename the '% on tasks' stat button into 'Customer Satisfaction' - Remove the 'no option' for the rating frequency field because it is required - project form : Add a 'Go to Website' stat button - Project dashboard: remove the 'Customer Ratings' menu item in more - Ratings page: the 'Last 30 days' filter include ratings from today - remove the Appointment / Helpdesk Customer Satisfaction / Live Support menu items TASK ID : 1251 --- .../data/im_livechat_channel_demo.xml | 14 +- .../report/im_livechat_report_channel.py | 6 +- .../im_livechat/static/src/js/im_livechat.js | 2 +- .../static/src/xml/im_livechat.xml | 4 +- .../static/src/js/portal_chatter.js | 9 +- .../static/src/js/portal_composer.js | 8 +- .../static/src/js/portal_rating_composer.js | 4 +- .../portal_rating/views/rating_templates.xml | 2 +- addons/project/__manifest__.py | 1 - addons/project/controllers/__init__.py | 1 - addons/project/data/project_data.xml | 1 + addons/project/data/project_demo.xml | 4 +- .../data/project_mail_template_data.xml | 8 +- addons/project/models/project.py | 50 +-- addons/project/models/res_config_settings.py | 16 +- addons/project/tests/test_project_flow.py | 6 +- addons/project/views/project_views.xml | 334 ++++++++++-------- addons/project/views/rating_views.xml | 5 +- .../views/res_config_settings_views.xml | 2 +- addons/rating/controllers/main.py | 8 +- addons/rating/models/rating.py | 34 +- addons/rating/models/rating_mixin.py | 6 +- addons/rating/static/src/img/rating_10.png | Bin 2398 -> 0 bytes .../rating/static/src/img/rating_10_white.png | Bin 2293 -> 0 bytes addons/rating/static/src/img/rating_3.png | Bin 0 -> 2186 bytes .../rating/static/src/img/rating_3_white.png | Bin 0 -> 2180 bytes addons/rating/static/src/img/rating_5.png | Bin 2186 -> 2398 bytes .../rating/static/src/img/rating_5_white.png | Bin 2180 -> 2293 bytes addons/rating/tests/test_security.py | 6 +- .../data/website_livechat_data.xml | 4 - .../tests/tours/website_livechat_common.js | 4 +- addons/website_livechat/tests/common.py | 2 +- .../tests/test_livechat_request.py | 2 +- .../views/website_livechat.xml | 10 +- addons/website_project/__init__.py | 5 + addons/website_project/__manifest__.py | 18 + .../website_project/controllers/__init__.py | 4 + .../controllers/rating.py | 18 +- addons/website_project/models/__init__.py | 4 + addons/website_project/models/project.py | 23 ++ .../views/project_project_views.xml | 16 + .../views/project_rating_templates.xml | 72 ++-- .../website_slides/data/slide_user_demo.xml | 10 +- addons/website_slides/models/slide_channel.py | 2 +- .../views/rating_rating_views.xml | 2 +- doc/reference/mixins.rst | 4 +- 46 files changed, 407 insertions(+), 324 deletions(-) delete mode 100644 addons/rating/static/src/img/rating_10.png delete mode 100644 addons/rating/static/src/img/rating_10_white.png create mode 100644 addons/rating/static/src/img/rating_3.png create mode 100644 addons/rating/static/src/img/rating_3_white.png create mode 100644 addons/website_project/__init__.py create mode 100644 addons/website_project/__manifest__.py create mode 100644 addons/website_project/controllers/__init__.py rename addons/{project => website_project}/controllers/rating.py (85%) create mode 100644 addons/website_project/models/__init__.py create mode 100644 addons/website_project/models/project.py create mode 100644 addons/website_project/views/project_project_views.xml rename addons/{project => website_project}/views/project_rating_templates.xml (82%) diff --git a/addons/im_livechat/data/im_livechat_channel_demo.xml b/addons/im_livechat/data/im_livechat_channel_demo.xml index e6cde7dbfa6..5e3ca7fc937 100644 --- a/addons/im_livechat/data/im_livechat_channel_demo.xml +++ b/addons/im_livechat/data/im_livechat_channel_demo.xml @@ -31,7 +31,7 @@ - + mail.channel @@ -92,7 +92,7 @@ - + mail.channel @@ -205,7 +205,7 @@ - + mail.channel @@ -300,7 +300,7 @@ - + mail.channel @@ -352,7 +352,7 @@ - + mail.channel @@ -404,7 +404,7 @@ - + mail.channel @@ -514,7 +514,7 @@ - + diff --git a/addons/im_livechat/report/im_livechat_report_channel.py b/addons/im_livechat/report/im_livechat_report_channel.py index b22e040327a..07c01110b8e 100644 --- a/addons/im_livechat/report/im_livechat_report_channel.py +++ b/addons/im_livechat/report/im_livechat_report_channel.py @@ -72,14 +72,14 @@ class ImLivechatReportChannel(models.Model): END as is_anonymous, C.country_id, CASE - WHEN rate.rating = 10 THEN 1 + WHEN rate.rating = 5 THEN 1 ELSE 0 END as is_happy, Rate.rating as rating, CASE WHEN Rate.rating = 1 THEN 'Unhappy' - WHEN Rate.rating = 10 THEN 'Happy' - WHEN Rate.rating = 5 THEN 'Neutral' + WHEN Rate.rating = 5 THEN 'Happy' + WHEN Rate.rating = 3 THEN 'Neutral' ELSE null END as rating_text, CASE diff --git a/addons/im_livechat/static/src/js/im_livechat.js b/addons/im_livechat/static/src/js/im_livechat.js index 000ac6665b9..134679e933d 100644 --- a/addons/im_livechat/static/src/js/im_livechat.js +++ b/addons/im_livechat/static/src/js/im_livechat.js @@ -525,7 +525,7 @@ var Feedback = Widget.extend({ this.$('.o_livechat_rating_choices img[data-value="'+this.rating+'"]').addClass('selected'); // only display textearea if bad smiley selected - if (this.rating !== 10) { + if (this.rating !== 5) { this.$('.o_livechat_rating_reason').show(); } else { this.$('.o_livechat_rating_reason').hide(); diff --git a/addons/im_livechat/static/src/xml/im_livechat.xml b/addons/im_livechat/static/src/xml/im_livechat.xml index c19e2d09881..9e85f86baeb 100644 --- a/addons/im_livechat/static/src/xml/im_livechat.xml +++ b/addons/im_livechat/static/src/xml/im_livechat.xml @@ -9,8 +9,8 @@ Did we correctly answer your question ?
- Good - OK + Good + OK Bad
diff --git a/addons/portal_rating/static/src/js/portal_chatter.js b/addons/portal_rating/static/src/js/portal_chatter.js index 51b403b521b..baaebd17be6 100644 --- a/addons/portal_rating/static/src/js/portal_chatter.js +++ b/addons/portal_rating/static/src/js/portal_chatter.js @@ -9,7 +9,6 @@ var time = require('web.time'); var _t = core._t; var PortalChatter = portalChatter.PortalChatter; var qweb = core.qweb; -var STAR_RATING_RATIO = 2; // conversion factor from the star (1-5) to the db rating range (1-10) /** * PortalChatter @@ -67,7 +66,7 @@ PortalChatter.include({ messages = this._super.apply(this, arguments); if (this.options['display_rating']) { _.each(messages, function (m, i) { - m.rating_value = self.roundToHalf(m['rating_value'] / STAR_RATING_RATIO); + m.rating_value = self.roundToHalf(m['rating_value']); m.rating = self._preprocessCommentData(m.rating, i); }); } @@ -114,13 +113,13 @@ PortalChatter.include({ return; } var ratingData = { - 'avg': Math.round(result['rating_stats']['avg'] / STAR_RATING_RATIO * 100) / 100, + 'avg': Math.round(result['rating_stats']['avg'] * 100) / 100, 'percent': [], }; _.each(_.keys(result['rating_stats']['percent']).reverse(), function (rating) { if (rating % 2 === 0) { ratingData['percent'].push({ - 'num': rating / STAR_RATING_RATIO, + 'num': rating, 'percent': utils.round_precision(result['rating_stats']['percent'][rating], 0.01), }); } @@ -347,7 +346,7 @@ PortalChatter.include({ _onChangeRatingDomain: function () { var domain = []; if (this.get('rating_value')) { - domain = [['rating_value', '=', this.get('rating_value') * STAR_RATING_RATIO]]; + domain = [['rating_value', '=', this.get('rating_value')]]; } this._changeCurrentPage(1, domain); }, diff --git a/addons/portal_rating/static/src/js/portal_composer.js b/addons/portal_rating/static/src/js/portal_composer.js index 37b0b9e3511..63854caa302 100644 --- a/addons/portal_rating/static/src/js/portal_composer.js +++ b/addons/portal_rating/static/src/js/portal_composer.js @@ -8,8 +8,6 @@ var _t = core._t; var PortalComposer = portalComposer.PortalComposer; -var STAR_RATING_RATIO = 2; // conversion factor from the star (1-5) to the db rating range (1-10) - /** * PortalComposer * @@ -31,7 +29,7 @@ PortalComposer.include({ // apply ratio to default rating value if (options.default_rating_value) { - options.default_rating_value = parseFloat(options.default_rating_value) / STAR_RATING_RATIO; + options.default_rating_value = parseFloat(options.default_rating_value); } // default options @@ -66,7 +64,7 @@ PortalComposer.include({ // set the default value to trigger the display of star widget and update the hidden input value. self.set("star_value", self.options.default_rating_value); - self.$input.val(self.options.default_rating_value * STAR_RATING_RATIO); + self.$input.val(self.options.default_rating_value); }); }, @@ -97,7 +95,7 @@ PortalComposer.include({ var index = this.$('.stars i').index(ev.currentTarget); this.set("star_value", index + 1); this.user_click = true; - this.$input.val(this.get("star_value") * STAR_RATING_RATIO); + this.$input.val(this.get("star_value")); }, /** * @private diff --git a/addons/portal_rating/static/src/js/portal_rating_composer.js b/addons/portal_rating/static/src/js/portal_rating_composer.js index 8bf205a6cb8..af7a55b8749 100644 --- a/addons/portal_rating/static/src/js/portal_rating_composer.js +++ b/addons/portal_rating/static/src/js/portal_rating_composer.js @@ -7,8 +7,6 @@ var portalComposer = require('portal.composer'); var PortalComposer = portalComposer.PortalComposer; -var STAR_RATING_RATIO = 2; // conversion factor from the star (1-5) to the db rating range (1-10) - /** * RatingPopupComposer * @@ -25,7 +23,7 @@ var RatingPopupComposer = publicWidget.Widget.extend({ init: function (parent, options) { this._super.apply(this, arguments); - this.rating_avg = Math.round(options['ratingAvg'] / STAR_RATING_RATIO * 100) / 100 || 0.0; + this.rating_avg = Math.round(options['ratingAvg'] / 100) / 100 || 0.0; this.rating_total = options['ratingTotal'] || 0.0; this.options = _.defaults({}, options, { diff --git a/addons/portal_rating/views/rating_templates.xml b/addons/portal_rating/views/rating_templates.xml index a1faae6aa21..78561828a00 100644 --- a/addons/portal_rating/views/rating_templates.xml +++ b/addons/portal_rating/views/rating_templates.xml @@ -4,7 +4,7 @@ Rating widget static: show 5 stars (full or empty) regarding the given rating_avg and rating_count -->