Files
odoo_source/addons/website_forum/models/res_users.py
T
David Beguin fb40c6bf60 [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 705376a982,
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
2019-03-15 14:58:28 +00:00

47 lines
1.5 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import hashlib
from datetime import datetime
from werkzeug import urls
from odoo import api, fields, models
class Users(models.Model):
_inherit = 'res.users'
def __init__(self, pool, cr):
init_res = super(Users, self).__init__(pool, cr)
type(self).SELF_WRITEABLE_FIELDS = list(
set(
self.SELF_WRITEABLE_FIELDS +
['country_id', 'city', 'website', 'website_description', 'website_published']))
type(self).SELF_READABLE_FIELDS = type(self).SELF_READABLE_FIELDS + ['karma']
return init_res
create_date = fields.Datetime('Create Date', readonly=True, index=True)
forum_waiting_posts_count = fields.Integer('Waiting post', compute="_get_user_waiting_post")
@api.multi
def _get_user_waiting_post(self):
for user in self:
Post = self.env['forum.post']
domain = [('parent_id', '=', False), ('state', '=', 'pending'), ('create_uid', '=', user.id)]
user.forum_waiting_posts_count = Post.search_count(domain)
# Wrapper for call_kw with inherits
@api.multi
def open_website_url(self):
return self.mapped('partner_id').open_website_url()
def get_gamification_redirection_data(self):
res = super(Users, self).get_gamification_redirection_data()
res.append({
'url': '/forum',
'label': 'See our Forum'
})
return res