diff --git a/addons/website_forum/controllers/main.py b/addons/website_forum/controllers/main.py index d05601025c2..408ca000f19 100644 --- a/addons/website_forum/controllers/main.py +++ b/addons/website_forum/controllers/main.py @@ -467,9 +467,13 @@ class website_forum(http.Controller): @http.route('/forum//edit/question/', type='http', auth="user", multilang=True, website=True) def edit_question(self, forum, post, **kwarg): + post_history_obj = request.registry['website.forum.post.history']; tags = "" for tag_name in post.tags: tags += tag_name.name + "," + + ids = post_history_obj.search(request.cr, request.uid, [('post_id','=', post.id)], context=request.context) + post_history = post_history_obj.browse(request.cr, request.uid, ids, context=request.context) values = { 'post': post, @@ -477,6 +481,7 @@ class website_forum(http.Controller): 'forum': forum, 'searches': kwarg, 'notifications': self._get_notifications(), + 'history': post_history, } return request.website.render("website_forum.edit_question", values) @@ -637,3 +642,9 @@ class website_forum(http.Controller): post_ids.append(post.id) request.registry['website.forum.post'].message_unsubscribe( cr, uid, post_ids, [partner_id], context=context) return werkzeug.utils.redirect("/forum/%s/question/%s" % (slug(forum),post.id)) + + @http.route('/forum/change_question/', type='json', auth="user", multilang=True, methods=['POST'], website=True) + def correct_answer(self, **kwarg): + cr, uid, context = request.cr, request.uid, request.context + return True + diff --git a/addons/website_forum/models/forum.py b/addons/website_forum/models/forum.py index f0f14d4b2fc..72544b13d1e 100644 --- a/addons/website_forum/models/forum.py +++ b/addons/website_forum/models/forum.py @@ -227,9 +227,9 @@ class Post(osv.Model): return post_id def write(self, cr, uid, ids, vals, context=None): - self.create_history(cr, uid, ids, vals, context=context) #NOTE: to avoid message post on write of last comment time if not vals.get('message_last_post'): + self.create_history(cr, uid, ids, vals, context=context) for post in self.browse(cr, uid, ids, context=context): body, subtype = "Edited question", "website_forum.mt_question_edit" if post.parent_id: diff --git a/addons/website_forum/static/src/js/website_forum.js b/addons/website_forum/static/src/js/website_forum.js index 4dd3b66d255..7981e769a5a 100644 --- a/addons/website_forum/static/src/js/website_forum.js +++ b/addons/website_forum/static/src/js/website_forum.js @@ -116,4 +116,13 @@ $(document).ready(function () { }); }; + $('.change_question').change(function (ev) { + var $option = $(ev.currentTarget); + openerp.jsonRpc("/forum/change_question/", 'call', { + 'option': $option.attr("id")}) + .then(function (data) { + }) + return true; + }); + }); \ No newline at end of file diff --git a/addons/website_forum/views/website_forum.xml b/addons/website_forum/views/website_forum.xml index 34cf953617f..1c4de931a7c 100644 --- a/addons/website_forum/views/website_forum.xml +++ b/addons/website_forum/views/website_forum.xml @@ -295,6 +295,11 @@

Edit question

+
Please enter a descriptive question (should finish by a '?')