summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSunil Sharma <ssh@tinyerp.com>2014-04-07 19:05:09 +0530
committerSunil Sharma <ssh@tinyerp.com>2014-04-07 19:05:09 +0530
commit1aee6d631b1c8f54f6734b1911d0e55942d4f875 (patch)
tree96563e047adf56b6065cd1243a7952c793a998b3
parent847d0a94080a564cbe7a0fbf1e8899fad548b2ec (diff)
[imp]:improve remove tag as space in ask question and edit question
bzr revid: ssh@tinyerp.com-20140407133509-cmeyb8xt7z9xkuaj
-rw-r--r--addons/website_forum/controllers/main.py23
1 files changed, 12 insertions, 11 deletions
diff --git a/addons/website_forum/controllers/main.py b/addons/website_forum/controllers/main.py
index 19f627fe14f..403d54dc6d1 100644
--- a/addons/website_forum/controllers/main.py
+++ b/addons/website_forum/controllers/main.py
@@ -308,15 +308,16 @@ class website_forum(http.Controller):
create_context = dict(context)
Tag = request.registry['website.forum.tag']
- tags = question.get('question_tags').strip('[]').replace('"','').split(",")
question_tags = []
- for tag in tags:
- tag_ids = Tag.search(cr, uid, [('name', '=', tag)], context=context)
- if tag_ids:
- question_tags.append((4,tag_ids[0]))
- else:
- question_tags.append((0,0,{'name' : tag,'forum_id' : forum.id}))
-
+ if question.get('question_tags').strip('[]'):
+ tags = question.get('question_tags').strip('[]').replace('"','').split(",")
+ for tag in tags:
+ tag_ids = Tag.search(cr, uid, [('name', '=', tag)], context=context)
+ if tag_ids:
+ question_tags.append((4,tag_ids[0]))
+ else:
+ question_tags.append((0,0,{'name' : tag,'forum_id' : forum.id}))
+
new_question_id = request.registry['website.forum.post'].create(
request.cr, request.uid, {
'user_id': uid,
@@ -396,10 +397,10 @@ class website_forum(http.Controller):
vals = {
'content': post.get('content'),
}
- if post.get('question_tag'):
+ question_tags = []
+ if post.get('question_tag').strip('[]'):
Tag = request.registry['website.forum.tag']
tags = post.get('question_tag').strip('[]').replace('"','').split(",")
- question_tags = []
for tag in tags:
tag_ids = Tag.search(cr, uid, [('name', '=', tag)], context=context)
if tag_ids:
@@ -407,7 +408,7 @@ class website_forum(http.Controller):
else:
new_tag = Tag.create(cr, uid, {'name' : tag,'forum_id' : forum.id}, context=context)
question_tags.append(new_tag)
- vals.update({'tags': [(6, 0, question_tags)], 'name': post.get('question_name')})
+ vals.update({'tags': [(6, 0, question_tags)], 'name': post.get('question_name')})
post_id = post.get('answer_id') if post.get('answer_id') else post.get('question_id')
new_question_id = request.registry['website.forum.post'].write( cr, uid, [int(post_id)], vals, context=context)