summaryrefslogtreecommitdiff
path: root/addons/website_forum/controllers/main.py
diff options
context:
space:
mode:
authorDavid Beguin <dbe@odoo.com>2019-02-20 16:54:36 +0000
committerDavid Beguin <dbe@odoo.com>2019-03-15 14:58:28 +0000
commitfb40c6bf6018f7f208201e1d4a4d413fd2ce3080 (patch)
treed6df1ec5f2e7aca08311a51fad7f2ab3162a6806 /addons/website_forum/controllers/main.py
parentbbedcdb19054527940fb040a0d4f22115d5be265 (diff)
[IMP] website(_profile,_forum,_slides): move validation email to profile and use in forum and elearning
Email validation was necessary on the forum to be able to begin to use the forum (ask or answer questions, vote, etc..) As the new elearning also uses karma since 705376a982d64fb41800f148a167ef0fc28ce4c6, the email validation is now also necessary in the eLearning platform. This is why this commit is moving the email validation process to website_profile and extend website_slides (eLearning) and website_forum to use this feature. In function of where the user asked to send him the validation email, the user is redirected on the forum or on the elearning when he clicks on 'Validate my account' in the received 'email validation' email. Task ID : 1943788 PR #31321
Diffstat (limited to 'addons/website_forum/controllers/main.py')
-rw-r--r--addons/website_forum/controllers/main.py37
1 files changed, 14 insertions, 23 deletions
diff --git a/addons/website_forum/controllers/main.py b/addons/website_forum/controllers/main.py
index f31b59e430f..ed2cb30df2e 100644
--- a/addons/website_forum/controllers/main.py
+++ b/addons/website_forum/controllers/main.py
@@ -3,6 +3,7 @@
import json
import lxml
import requests
+import logging
import werkzeug.exceptions
import werkzeug.urls
import werkzeug.wrappers
@@ -15,6 +16,8 @@ from odoo.addons.website.models.ir_http import sitemap_qs2dom
from odoo.addons.website_profile.controllers.main import WebsiteProfile
from odoo.http import request
+_logger = logging.getLogger(__name__)
+
class WebsiteForum(WebsiteProfile):
_post_per_page = 10
@@ -26,8 +29,6 @@ class WebsiteForum(WebsiteProfile):
values.update({
'header': kwargs.get('header', dict()),
'searches': kwargs.get('searches', dict()),
- 'validation_email_sent': request.session.get('validation_email_sent', False),
- 'validation_email_done': request.session.get('validation_email_done', False),
})
if kwargs.get('forum'):
values['forum'] = kwargs.get('forum')
@@ -37,32 +38,21 @@ class WebsiteForum(WebsiteProfile):
# User and validation
# --------------------------------------------------
-
+ # TODO DBE : Those 3 are deprecated. To remove in v13.
@http.route('/forum/send_validation_email', type='json', auth='user', website=True)
- def send_validation_email(self, forum_id=None, **kwargs):
- if request.env.uid != request.website.user_id.id:
- request.env.user._send_forum_validation_email(forum_id=forum_id)
- request.session['validation_email_sent'] = True
- return True
+ def send_forum_validation_email(self, forum_id=None, **kwargs):
+ _logger.warning("The method send_forum_validation_email() is deprecated and should be removed in v13.")
+ return self.send_forum_validation_email(forum_id=forum_id, **kwargs)
@http.route('/forum/validate_email', type='http', auth='public', website=True, sitemap=False)
- def validate_email(self, token, id, email, forum_id=None, **kwargs):
- if forum_id:
- try:
- forum_id = int(forum_id)
- except ValueError:
- forum_id = None
- done = request.env['res.users'].sudo().browse(int(id)).process_forum_validation_token(token, email, forum_id=forum_id)[0]
- if done:
- request.session['validation_email_done'] = True
- if forum_id:
- return request.redirect("/forum/%s" % int(forum_id))
- return request.redirect('/forum')
+ def forum_validate_email(self, token, user_id, email, forum_id=None, **kwargs):
+ _logger.warning("The method forum_validate_email() is deprecated and should be removed in v13.")
+ return self.forum_validate_email(token=token, user_id=user_id, email=email, forum_id=forum_id, **kwargs)
@http.route('/forum/validate_email/close', type='json', auth='public', website=True)
- def validate_email_done(self):
- request.session['validation_email_done'] = False
- return True
+ def forum_validate_email_done(self, **kwargs):
+ _logger.warning("The method forum_validate_email_done() is deprecated and should be removed in v13.")
+ return self.validate_email_done(**kwargs)
# Forum
# --------------------------------------------------
@@ -550,6 +540,7 @@ class WebsiteForum(WebsiteProfile):
# Profile
# -----------------------------------
+
@http.route(['/forum/<model("forum.forum"):forum>/user/<int:user_id>'], type='http', auth="public", website=True)
def view_user_forum_profile(self, forum, user_id, **post):
return werkzeug.utils.redirect('/profile/user/' + str(user_id) + '?forum_id=' + str(forum.id))