From f19d620ebe6dffb373ce13ee21c2335c67e467ef Mon Sep 17 00:00:00 2001 From: Jeremy Kersten Date: Fri, 29 Jul 2016 16:17:02 +0200 Subject: [PATCH] [FIX] website_forum: don't allow to post an empty question Instead to post the empty question, now we redirect the end user to the question page with a warning. This commit closes #12962 --- addons/website_forum/controllers/main.py | 5 ++++- addons/website_forum/views/website_forum.xml | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/addons/website_forum/controllers/main.py b/addons/website_forum/controllers/main.py index 7dbac19620a..94b5f684879 100644 --- a/addons/website_forum/controllers/main.py +++ b/addons/website_forum/controllers/main.py @@ -317,8 +317,11 @@ class WebsiteForum(http.Controller): '/forum///reply'], type='http', auth="user", methods=['POST'], website=True) def post_create(self, forum, post_parent=None, post_type=None, **post): - if post_type == 'question' and not post.get('post_name', '').strip(): + if post_type == 'question' and not post.get('post_name', ''): return request.website.render('website.http_error', {'status_code': _('Bad Request'), 'status_message': _('Title should not be empty.')}) + if post.get('content', '') == '


': + return werkzeug.utils.redirect("/forum/%s/question/%s?nocontent=1" % (slug(forum), post_parent and slug(post_parent))) + post_tag_ids = forum._tag_to_write_vals(post.get('post_tags', '')) new_question = request.env['forum.post'].create({ 'forum_id': forum.id, diff --git a/addons/website_forum/views/website_forum.xml b/addons/website_forum/views/website_forum.xml index ab29205ea40..5e5dea85da1 100644 --- a/addons/website_forum/views/website_forum.xml +++ b/addons/website_forum/views/website_forum.xml @@ -690,6 +690,9 @@ - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

+ + +