From 369143c986e45c51bca000c2cef77f73f98f2389 Mon Sep 17 00:00:00 2001 From: Quentin Mourier Date: Wed, 22 May 2019 09:09:23 +0000 Subject: [PATCH] [FIX] website_profile: allow to edit its profile Move code from website_forum allowing to edit its own profile. Otherwise fields to update are not white listed. Also add an unpublished flag when seeing unpublished users in order to know it if you have access to depending on ACLs. Linked to task 1978530 Related to PR #33559 --- addons/website_forum/models/res_users.py | 15 --------------- addons/website_profile/controllers/main.py | 1 + addons/website_profile/models/res_users.py | 9 +++++++++ addons/website_profile/views/website_profile.xml | 4 ++++ 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/addons/website_forum/models/res_users.py b/addons/website_forum/models/res_users.py index 67326175ac9..35a5fc32545 100644 --- a/addons/website_forum/models/res_users.py +++ b/addons/website_forum/models/res_users.py @@ -1,27 +1,12 @@ # -*- 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") diff --git a/addons/website_profile/controllers/main.py b/addons/website_profile/controllers/main.py index 19f9e117ded..2fca601fcb7 100644 --- a/addons/website_profile/controllers/main.py +++ b/addons/website_profile/controllers/main.py @@ -204,6 +204,7 @@ class WebsiteProfile(http.Controller): 'rank': user.rank_id.name, 'karma': user.karma, 'badge_count': len(user.badge_ids), + 'website_published': user.website_published } @http.route(['/profile/users', diff --git a/addons/website_profile/models/res_users.py b/addons/website_profile/models/res_users.py index 5bf49be0a78..fd440665f44 100644 --- a/addons/website_profile/models/res_users.py +++ b/addons/website_profile/models/res_users.py @@ -14,6 +14,15 @@ VALIDATION_KARMA_GAIN = 3 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 + @api.model def _generate_profile_token(self, user_id, email): """Return a token for email validation. This token is valid for the day diff --git a/addons/website_profile/views/website_profile.xml b/addons/website_profile/views/website_profile.xml index f30170548d7..a1f66e2f485 100644 --- a/addons/website_profile/views/website_profile.xml +++ b/addons/website_profile/views/website_profile.xml @@ -497,6 +497,7 @@ User rank

+ Unpublished