From 55479a4cc2fc15c30aad23aa8db2574d9d008312 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 5 May 2014 17:45:23 +0200 Subject: [PATCH] [FIX] website_forum: new batch of fixes : - fixed reopen link that was broken (python code appearing) - fixed close link that was leading to a 500 error due to post -> question - fixed link to question author, was redirecting to the current user - fixed displayed number of questions in the forum, now displaying actual question number, not number of displayed questions in the page - improved guidelines: added link back to the forum - fixed tags display: now by posts_count desc, unused tags are not shown - users are now displayed by desc karma - converting a comment as an answer does not allow to create a new answer if another one by uid is already present, it just moves the comment bzr revid: tde@openerp.com-20140505154523-6dld9sfm0nc0oulu --- addons/website_forum/controllers/main.py | 16 +++++++++------- addons/website_forum/views/website_forum.xml | 15 ++++++++------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/addons/website_forum/controllers/main.py b/addons/website_forum/controllers/main.py index 365221f9574..cd36a802422 100644 --- a/addons/website_forum/controllers/main.py +++ b/addons/website_forum/controllers/main.py @@ -124,6 +124,7 @@ class WebsiteForum(http.Controller): values.update({ 'main_object': tag or forum, 'question_ids': question_ids, + 'question_count': question_count, 'pager': pager, 'tag': tag, 'filters': filters, @@ -134,7 +135,7 @@ class WebsiteForum(http.Controller): @http.route(['/forum//faq'], type='http', auth="public", website=True, multilang=True) def forum_faq(self, forum, **post): - values = self._prepare_forum_values(forum=forum, searches=dict(), **post) + values = self._prepare_forum_values(forum=forum, searches=dict(), header={'is_guidelines': True}, **post) return request.website.render("website_forum.faq", values) @http.route('/forum/get_tags', type='http', auth="public", multilang=True, methods=['GET'], website=True) @@ -147,7 +148,7 @@ class WebsiteForum(http.Controller): def tags(self, forum, page=1, **post): cr, uid, context = request.cr, request.uid, request.context Tag = request.registry['forum.tag'] - obj_ids = Tag.search(cr, uid, [('forum_id', '=', forum.id)], limit=None, context=context) + obj_ids = Tag.search(cr, uid, [('forum_id', '=', forum.id), ('posts_count', '>', 0)], limit=None, order='posts_count DESC', context=context) tags = Tag.browse(cr, uid, obj_ids, context=context) values = self._prepare_forum_values(forum=forum, searches={'tags': True}, **post) values.update({ @@ -426,7 +427,7 @@ class WebsiteForum(http.Controller): tag_count = User.search(cr, SUPERUSER_ID, [('karma', '>', 1)], count=True, context=context) pager = request.website.pager(url="/forum/users", total=tag_count, page=page, step=step, scope=30) - obj_ids = User.search(cr, SUPERUSER_ID, [('karma', '>', 1)], limit=step, offset=pager['offset'], context=context) + obj_ids = User.search(cr, SUPERUSER_ID, [('karma', '>', 1)], limit=step, offset=pager['offset'], order='karma DESC', context=context) users = User.browse(cr, SUPERUSER_ID, obj_ids, context=context) searches['users'] = 'True' @@ -590,12 +591,13 @@ class WebsiteForum(http.Controller): @http.route('/forum//post//comment//convert_to_answer', type='http', auth="public", multilang=True, website=True) def convert_comment_to_answer(self, forum, post, comment, **kwarg): - values = { - 'content': comment.body, - } + body = comment.body request.registry['mail.message'].unlink(request.cr, request.uid, [comment.id], context=request.context) question = post.parent_id if post.parent_id else post - return self.post_new(forum, question, **values) + for answer in question.child_ids: + if answer.create_uid.id == request.uid: + return self.post_comment(forum, answer, comment=html2plaintext(body)) + return self.post_new(forum, question, content=body) @http.route('/forum//post//convert_to_comment', type='http', auth="user", multilang=True, website=True) def convert_answer_to_comment(self, forum, post, **kwarg): diff --git a/addons/website_forum/views/website_forum.xml b/addons/website_forum/views/website_forum.xml index bd8b47f0817..e75b85387b0 100644 --- a/addons/website_forum/views/website_forum.xml +++ b/addons/website_forum/views/website_forum.xml @@ -92,7 +92,8 @@
@@ -208,7 +209,7 @@