summaryrefslogtreecommitdiff
path: root/addons/website_slides/controllers
diff options
context:
space:
mode:
authorDavid Beguin <dbe@odoo.com>2019-02-14 10:36:26 +0000
committerDavid Beguin <dbe@odoo.com>2019-02-18 15:01:40 +0000
commit705376a982d64fb41800f148a167ef0fc28ce4c6 (patch)
tree115fbfb9f45d8cb15fbb83df3b73f47eee6e8b01 /addons/website_slides/controllers
parent0fe26b382c88859f61ea4389c2e6965a7f27fb46 (diff)
[IMP] website_slides : add karma gain rules
To gamify the new elearning, karma can be gained on various actions - rank a slide_channel (course) - vote for a slide - finish a course This commit also fix the 'completed' computation on slide.channel.partner Task ID : 1922159 PR #31109
Diffstat (limited to 'addons/website_slides/controllers')
-rw-r--r--addons/website_slides/controllers/__init__.py1
-rw-r--r--addons/website_slides/controllers/portal.py20
2 files changed, 21 insertions, 0 deletions
diff --git a/addons/website_slides/controllers/__init__.py b/addons/website_slides/controllers/__init__.py
index 17b391fb0a4..acf000fd92c 100644
--- a/addons/website_slides/controllers/__init__.py
+++ b/addons/website_slides/controllers/__init__.py
@@ -2,3 +2,4 @@
from . import mail
from . import main
+from . import portal
diff --git a/addons/website_slides/controllers/portal.py b/addons/website_slides/controllers/portal.py
new file mode 100644
index 00000000000..ae07dd85f8a
--- /dev/null
+++ b/addons/website_slides/controllers/portal.py
@@ -0,0 +1,20 @@
+# -*- 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 SlidesPortalChatter(PortalChatter):
+
+ @http.route(['/mail/chatter_post'], type='http', methods=['POST'], auth='public', website=True)
+ def portal_chatter_post(self, res_model, res_id, message, **kw):
+ result = super(SlidesPortalChatter, self).portal_chatter_post(res_model, res_id, message, **kw)
+ if res_model == 'slide.channel':
+ rating_value = kw.get('rating_value', False)
+ slide_channel = request.env[res_model].sudo().browse(int(res_id))
+ if rating_value and slide_channel and request.env.user.partner_id.id == int(kw.get('pid')):
+ # apply karma gain rule only once
+ request.env.user.add_karma(slide_channel.karma_gen_channel_rank)
+ return result