summaryrefslogtreecommitdiff
path: root/addons/portal_rating/controllers/portal_rating.py
blob: 2e8e4884730fe8bdee603045117406e60c3b6b03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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]