diff --git a/addons/website_forum/controllers/main.py b/addons/website_forum/controllers/main.py index 5de5f2e4558..5e62af098e6 100644 --- a/addons/website_forum/controllers/main.py +++ b/addons/website_forum/controllers/main.py @@ -446,6 +446,39 @@ class website_forum(http.Controller): }, context=context) return correct + @http.route('/forum//close/question/', type='http', auth="user", multilang=True, website=True) + def close_question(self, forum, post, **kwarg): + #have to remove by applying selection widget + reasons = [{'name': 'duplicate', 'value': 'duplicate question'}, + {'name': 'off_topic', 'value': 'question is off-topic or not relevant'}, + {'name': 'argumentative', 'value': 'too subjective and argumentative'}, + {'name': 'not_question', 'value': 'not a real question'}, + {'name': 'answer_accepted', 'value': 'the question is answered, right answer was accepted'}, + {'name': 'out_dated', 'value': 'question is not relevant or out dated'}, + {'name': 'offensive', 'value': 'question contains offensive or malicious remarks'}, + {'name': 'advertising', 'value': 'spam or advertising'}, + {'name': 'localized', 'value': 'too localized'} + ] + + values = { + 'post': post, + 'forum': forum, + 'searches': kwarg, + 'reasons': reasons, + 'notifications': self._get_notifications(), + } + return request.website.render("website_forum.close_question", values) + + @http.route('/forum//question/close/', type='http', auth="user", multilang=True, methods=['POST'], website=True) + def save_edited_question(self, forum, **post): + request.registry['website.forum.post'].write( request.cr, request.uid, [int(post.get('post_id'))], { + 'state': 'close', + 'closed_by': request.uid, + 'closed_date': datetime.today().strftime(tools.DEFAULT_SERVER_DATETIME_FORMAT), + 'reason': post.get('reason'), + }, context=request.context) + return werkzeug.utils.redirect("/forum/%s/question/%s" % (slug(forum),post.get('post_id'))) + @http.route('/forum//edit/profile/', type='http', auth="user", multilang=True, website=True) def edit_profile(self, forum, user, **kwarg): cr,context = request.cr, request.context diff --git a/addons/website_forum/models/forum.py b/addons/website_forum/models/forum.py index 6cf2b4531a1..5c6cc4b2418 100644 --- a/addons/website_forum/models/forum.py +++ b/addons/website_forum/models/forum.py @@ -150,7 +150,21 @@ class Post(osv.Model): 'website.forum.post.vote': (_get_vote, [], 10), } ), + 'correct': fields.boolean('Correct Answer'), + 'reason': fields.selection([ + ('duplicate', 'duplicate question'), + ('off_topic', 'question is off-topic or not relevant'), + ('argumentative','too subjective and argumentative'), + ('not_question', 'not a real question'), + ('answer_accepted', 'the question is answered, right answer was accepted'), + ('out_dated', 'question is not relevant or out dated'), + ('offensive', 'question contains offensive or malicious remarks'), + ('advertising', 'spam or advertising'), + ('localized', 'too localized'), + ], 'Reason'), + 'closed_by': fields.many2one('res.users', 'Closed by'), + 'closed_date': fields.datetime('Closed on', readonly=True), } _defaults = { 'state': 'active', diff --git a/addons/website_forum/views/website_forum.xml b/addons/website_forum/views/website_forum.xml index 932db50387b..854e64f0889 100644 --- a/addons/website_forum/views/website_forum.xml +++ b/addons/website_forum/views/website_forum.xml @@ -307,6 +307,31 @@ + +