summaryrefslogtreecommitdiff
path: root/addons/rating
diff options
context:
space:
mode:
authorYannick Tivisse <yti@odoo.com>2020-05-07 09:40:26 +0000
committerYannick Tivisse <yti@odoo.com>2020-05-08 12:17:20 +0000
commit8ca96078dbeb61678f8c0656f90b09ab8a82981a (patch)
tree457131a047d674e6b6e38fecd8abc50bce1e47de /addons/rating
parente4a4ffb974ccde1842e1b2389450718f8576ad5b (diff)
[IMP] rating: Add a retrocompatibily route
Purpose ======= Even if the routes are correctly updated and the existing data is correctly updated, the emails that were already sent to the customers will be problematic, as we will provide a value which is not handled anymore (10 for example). To provide a retrocompatibility, deprecated the old route and introduce a new one. closes odoo/odoo#46296 Taskid: 2083096 Related: odoo/upgrade#889 Related: odoo/enterprise#10312 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Diffstat (limited to 'addons/rating')
-rw-r--r--addons/rating/controllers/main.py27
-rw-r--r--addons/rating/views/rating_template.xml2
2 files changed, 26 insertions, 3 deletions
diff --git a/addons/rating/controllers/main.py b/addons/rating/controllers/main.py
index e27fc6b7c53..a35f1af8662 100644
--- a/addons/rating/controllers/main.py
+++ b/addons/rating/controllers/main.py
@@ -1,16 +1,39 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
+import logging
+
from odoo import http
from odoo.http import request
from odoo.tools.translate import _
from odoo.tools.misc import get_lang
+_logger = logging.getLogger(__name__)
+
+MAPPED_RATES = {
+ 1: 1,
+ 5: 3,
+ 10: 5,
+}
class Rating(http.Controller):
@http.route('/rating/<string:token>/<int:rate>', type='http', auth="public", website=True)
def open_rating(self, token, rate, **kwargs):
+ _logger.warning('/rating is deprecated, use /rate instead')
+ assert rate in (1, 5, 10), "Incorrect rating"
+ return self.action_open_rating(token, MAPPED_RATES.get(rate), **kwargs)
+
+ @http.route(['/rating/<string:token>/submit_feedback'], type="http", auth="public", methods=['post'], website=True)
+ def submit_rating(self, token, **kwargs):
+ _logger.warning('/rating is deprecated, use /rate instead')
+ rate = int(kwargs.get('rate'))
+ assert rate in (1, 5, 10), "Incorrect rating"
+ kwargs['rate'] = MAPPED_RATES.gate(rate)
+ return self.action_submit_rating(token, **kwargs)
+
+ @http.route('/rate/<string:token>/<int:rate>', type='http', auth="public", website=True)
+ def action_open_rating(self, token, rate, **kwargs):
assert rate in (1, 3, 5), "Incorrect rating"
rating = request.env['rating.rating'].sudo().search([('access_token', '=', token)])
if not rating:
@@ -27,8 +50,8 @@ class Rating(http.Controller):
'rate_names': rate_names, 'rate': rate
})
- @http.route(['/rating/<string:token>/submit_feedback'], type="http", auth="public", methods=['post'], website=True)
- def submit_rating(self, token, **kwargs):
+ @http.route(['/rate/<string:token>/submit_feedback'], type="http", auth="public", methods=['post'], website=True)
+ def action_submit_rating(self, token, **kwargs):
rate = int(kwargs.get('rate'))
assert rate in (1, 3, 5), "Incorrect rating"
rating = request.env['rating.rating'].sudo().search([('access_token', '=', token)])
diff --git a/addons/rating/views/rating_template.xml b/addons/rating/views/rating_template.xml
index 5b9552e2ffc..9b988b60535 100644
--- a/addons/rating/views/rating_template.xml
+++ b/addons/rating/views/rating_template.xml
@@ -21,7 +21,7 @@
<div class="card-body">
<div clas="row">
<h1 class="mt-5">Thank you for rating our services!</h1>
- <form t-attf-action="/rating/#{token}/submit_feedback" method="post">
+ <form t-attf-action="/rate/#{token}/submit_feedback" method="post">
<div class="btn-group btn-group-toggle row" data-toggle="buttons">
<t t-foreach="rate_names" t-as="rate_name">
<label t-attf-class="col-xs-12 btn o_rating_label shadow-none {{rate == rate_name and 'active' or ''}}">