summaryrefslogtreecommitdiff
path: root/addons/portal_rating/controllers/portal_rating.py
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/portal_rating/controllers/portal_rating.py
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/portal_rating/controllers/portal_rating.py')
-rw-r--r--addons/portal_rating/controllers/portal_rating.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/addons/portal_rating/controllers/portal_rating.py b/addons/portal_rating/controllers/portal_rating.py
new file mode 100644
index 00000000..2e8e4884
--- /dev/null
+++ b/addons/portal_rating/controllers/portal_rating.py
@@ -0,0 +1,17 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo import http, _
+from odoo.http import request
+
+
+class PortalRating(http.Controller):
+
+ @http.route(['/website/rating/comment'], type='json', auth="user", methods=['POST'], website=True)
+ def publish_rating_comment(self, rating_id, publisher_comment):
+ rating = request.env['rating.rating'].search([('id', '=', int(rating_id))])
+ if not rating:
+ return {'error': _('Invalid rating')}
+ rating.write({'publisher_comment': publisher_comment})
+ # return to the front-end the created/updated publisher comment
+ return rating.read(['publisher_comment', 'publisher_id', 'publisher_datetime'])[0]