diff options
| author | Thibault Delavallée <tde@odoo.com> | 2019-10-24 14:05:48 +0000 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2019-12-02 15:18:45 +0000 |
| commit | 9e0677882d64ac2be92cd1ea147ce823e2d9f69b (patch) | |
| tree | 389e992bf7ee18cf77ea08ca2e32a945d02c400d /addons/website_rating/controllers | |
| parent | 82f56ffddfc6aed21030214dc95c0a3e9f5d9a93 (diff) | |
[MOV] website_rating: move to portal_rating
PURPOSE
Clean posting process and improve mail.message definition and comprehension.
Move as much possible content from website_* modules to portal_* modules
to ease their use in customer portal
SPECIFICATIONS
Now that publish feature is replaced by internal directly in mail and portal
rating portal inclusion can be done safely in a portal_ratign module instead
of website_rating. It allows to remove the dependency and give the rating
feature of customer chatter directly in portal applications.
LINKS
Task ID 2071556
PR #38692
Diffstat (limited to 'addons/website_rating/controllers')
| -rw-r--r-- | addons/website_rating/controllers/__init__.py | 5 | ||||
| -rw-r--r-- | addons/website_rating/controllers/portal_chatter.py | 40 | ||||
| -rw-r--r-- | addons/website_rating/controllers/portal_rating.py | 17 |
3 files changed, 0 insertions, 62 deletions
diff --git a/addons/website_rating/controllers/__init__.py b/addons/website_rating/controllers/__init__.py deleted file mode 100644 index 514e3fde3d2..00000000000 --- a/addons/website_rating/controllers/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from . import portal_chatter -from . import portal_rating diff --git a/addons/website_rating/controllers/portal_chatter.py b/addons/website_rating/controllers/portal_chatter.py deleted file mode 100644 index fb3116bc774..00000000000 --- a/addons/website_rating/controllers/portal_chatter.py +++ /dev/null @@ -1,40 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from odoo import http -from odoo.http import request - -from odoo.addons.portal.controllers.mail import PortalChatter - - -class PortalChatter(PortalChatter): - - def _portal_post_filter_params(self): - fields = super(PortalChatter, self)._portal_post_filter_params() - fields += ['rating_value', 'rating_feedback'] - return fields - - @http.route() - def portal_chatter_post(self, res_model, res_id, message, redirect=None, attachment_ids='', attachment_tokens='', **kwargs): - if kwargs.get('rating_value'): - kwargs['rating_feedback'] = kwargs.pop('rating_feedback', message) - return super(PortalChatter, self).portal_chatter_post(res_model, res_id, message, redirect=redirect, attachment_ids=attachment_ids, attachment_tokens=attachment_tokens, **kwargs) - - @http.route() - def portal_chatter_init(self, res_model, res_id, domain=False, limit=False, **kwargs): - result = super(PortalChatter, self).portal_chatter_init(res_model, res_id, domain=domain, limit=limit, **kwargs) - # get the rating statistics about the record - if kwargs.get('rating_include'): - record = request.env[res_model].browse(res_id) - if hasattr(record, 'rating_get_stats'): - result['rating_stats'] = record.sudo().rating_get_stats() - return result - - @http.route() - def portal_message_fetch(self, res_model, res_id, domain=False, limit=False, offset=False, **kw): - # add 'rating_include' in context, to fetch them in portal_message_format - if kw.get('rating_include'): - context = dict(request.context) - context['rating_include'] = True - request.context = context - return super(PortalChatter, self).portal_message_fetch(res_model, res_id, domain=domain, limit=limit, offset=offset, **kw) diff --git a/addons/website_rating/controllers/portal_rating.py b/addons/website_rating/controllers/portal_rating.py deleted file mode 100644 index 06d1fe06ac1..00000000000 --- a/addons/website_rating/controllers/portal_rating.py +++ /dev/null @@ -1,17 +0,0 @@ -# -*- 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", method=['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] |
