diff --git a/addons/website_forum/controllers/main.py b/addons/website_forum/controllers/main.py index 2294daf73de..ca536bc28bd 100644 --- a/addons/website_forum/controllers/main.py +++ b/addons/website_forum/controllers/main.py @@ -705,6 +705,13 @@ class WebsiteForum(http.Controller): 'country_id': int(kwargs.get('country')) if kwargs.get('country') else False, 'website_description': kwargs.get('description'), } + + if 'clear_image' in kwargs: + values['image'] = False + elif kwargs.get('ufile'): + image = kwargs.get('ufile').read() + values['image'] = image.encode('base64') + if request.uid == user.id: # the controller allows to edit only its own privacy settings; use partner management for other cases values['website_published'] = kwargs.get('website_published') == 'True' user.write(values) diff --git a/addons/website_forum/static/src/js/website_forum.js b/addons/website_forum/static/src/js/website_forum.js index 60073ffd70a..703e7cc61ea 100644 --- a/addons/website_forum/static/src/js/website_forum.js +++ b/addons/website_forum/static/src/js/website_forum.js @@ -40,6 +40,33 @@ if(!$('.website_forum').length) { $(this).find('.o_forum_tag_follow_box').stop().fadeOut().css('display','none'); }); + $('.o_forum_profile_pic_edit').on('click', function(ev) { + ev.preventDefault(); + $(this).closest('form').find('.o_forum_file_upload').trigger('click'); + }); + + $('.o_forum_file_upload').on('change', function() { + if (this.files.length) { + var $form = $(this).closest('form'); + var reader = new FileReader(); + reader.onload = function(ev) { + $form.find('.o_forum_avatar_img').attr('src', ev.target.result); + }; + reader.readAsDataURL(this.files[0]); + $form.find('#forum_clear_image').remove(); + } + }); + + $('.o_forum_profile_pic_clear').click(function() { + var $form = $(this).closest('form'); + $form.find('.o_forum_avatar_img').attr("src", "/web/static/src/img/placeholder.png"); + $form.append($('', { + name: 'clear_image', + id: 'forum_clear_image', + type: 'hidden', + })); + }); + // Extended user biography toogle $('.o_forum_user_info').hover( function () { diff --git a/addons/website_forum/views/website_forum.xml b/addons/website_forum/views/website_forum.xml index 15d8c8f77e6..301bbb7e482 100644 --- a/addons/website_forum/views/website_forum.xml +++ b/addons/website_forum/views/website_forum.xml @@ -1261,74 +1261,80 @@ Edit Profile - - - - - + - - - Real name - - - + + + + + + + + + - - Public profile - - - + + + + Real name + + + - - - Website - - + + Public profile + + + + - - - - x - Please enter a valid email address in order to receive notifications from answers or comments. + + Website + + + - Email - - + + + x + Please enter a valid email address in order to receive notifications from answers or comments. + + Email + + + - - - City - - + + City + + + - - - Country - - - Country... - - - - + + Country + + + Country... + + + + + - - - - Biography - - + + + Biography + + + + + + Update - - - Update - - @@ -1389,10 +1395,12 @@ - - Edit Your Bio - + + + Edit Your Profile + +
Please enter a valid email address in order to receive notifications from answers or comments.