From 6721db92a65a9bdc82edf2f06de8616e139572d7 Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Mon, 24 Feb 2014 12:32:06 +0530 Subject: [PATCH] [IMP] add template of answers and improved code bzr revid: tpa@tinyerp.com-20140224070206-pxxet6kfgpyftclc --- addons/website_forum/controllers/main.py | 26 +-- addons/website_forum/views/website_forum.xml | 202 ++++++++----------- 2 files changed, 94 insertions(+), 134 deletions(-) diff --git a/addons/website_forum/controllers/main.py b/addons/website_forum/controllers/main.py index 1246d7066a4..b3cea3d26a9 100644 --- a/addons/website_forum/controllers/main.py +++ b/addons/website_forum/controllers/main.py @@ -35,19 +35,19 @@ from openerp.addons.website.controllers.main import Website as controllers controllers = controllers() class website_forum(http.Controller): - + @http.route(['/questions/', '/question/page/'], type='http', auth="public", website=True, multilang=True) def questions(self, page=1, **searches): cr, uid, context = request.cr, request.uid, request.context forum_obj = request.registry['website.forum.post'] tag_obj = request.registry['website.forum.tag'] - + step = 5 question_count = forum_obj.search( request.cr, request.uid, [], count=True, context=request.context) pager = request.website.pager(url="/questions/", total=question_count, page=page, step=step, scope=5) - + obj_ids = forum_obj.search( request.cr, request.uid, [], limit=step, offset=pager['offset'], context=request.context) @@ -69,20 +69,20 @@ class website_forum(http.Controller): } return request.website.render(page, values) -# @http.route(['/question/'], type='http', auth="public", website=True, multilang=True) -# def question_register(self, question, **post): -# values = { -# 'question': question, -# 'main_object': question, -# 'range': range, -# } -# return request.website.render("website_forum.question_description_full", values) + @http.route(['/question/'], type='http', auth="public", website=True, multilang=True) + def question_register(self, question, **post): + values = { + 'question': question, + 'main_object': question, + 'range': range, + } + return request.website.render("website_forum.question_description_full", values) @http.route('/question/postquestion/', type='http', auth="user", multilang=True, website=True) def post_question(self, question_name="New question", **kwargs): #TODO : reply a page that allows user to post a question return self._add_question(question_name, request.context, **kwargs) - + @http.route('/question/new/', type='http', auth="user", multilang=True, methods=['POST'], website=True) def register_question(self, forum_id=1, **question): cr, uid, context = request.cr, request.uid, request.context @@ -97,7 +97,7 @@ class website_forum(http.Controller): 'active': True, }, context=create_context) return werkzeug.utils.redirect("/question/%s" % new_question_id) - + @http.route('/question/new/', type='http', auth="user", multilang=True, methods=['POST'], website=True) def post_answer(self, post_id, forum_id=1, **question): cr, uid, context = request.cr, request.uid, request.context diff --git a/addons/website_forum/views/website_forum.xml b/addons/website_forum/views/website_forum.xml index 49ffaf8ae4a..79c18ae5e01 100644 --- a/addons/website_forum/views/website_forum.xml +++ b/addons/website_forum/views/website_forum.xml @@ -67,35 +67,59 @@ -
-
- - - Votes - -
-
-
-
- - - Answers - -
-
-
-
- - - Views - -
-
- +
+
+ + + Votes + +
+
+
+
+ + + Answers + +
+
+
+
+ + + Views + +
+
+ + +