diff --git a/addons/website_forum/controllers/main.py b/addons/website_forum/controllers/main.py index cc63e1fbdbb..f6cabb4307f 100644 --- a/addons/website_forum/controllers/main.py +++ b/addons/website_forum/controllers/main.py @@ -40,7 +40,7 @@ controllers = controllers() class website_forum(http.Controller): - @http.route(['/forum/'], type='http', auth="public", website=True, multilang=True) + @http.route(['/forum'], type='http', auth="public", website=True, multilang=True) def forum(self, **searches): cr, uid, context = request.cr, request.uid, request.context Forum = request.registry['website.forum'] @@ -48,7 +48,7 @@ class website_forum(http.Controller): forums = Forum.browse(cr, uid, obj_ids, context=context) return request.website.render("website_forum.forum_index", { 'forums': forums }) - @http.route('/forum/add_forum/', type='http', auth="user", multilang=True, website=True) + @http.route('/forum/add_forum', type='http', auth="user", multilang=True, website=True) def add_forum(self, forum_name="New Forum", **kwargs): forum_id = request.registry['website.forum'].create(request.cr, request.uid, { 'name': forum_name, @@ -128,7 +128,7 @@ class website_forum(http.Controller): user = request.registry['res.users'].browse(cr, uid, uid, context=context) return {"user": user, "notifications": notifications} - @http.route('/forum/notification_read/', type='json', auth="user", multilang=True, methods=['POST'], website=True) + @http.route('/forum/notification_read', type='json', auth="user", multilang=True, methods=['POST'], website=True) def notification_read(self, **kwarg): request.registry['mail.message'].set_message_read(request.cr, request.uid, [int(kwarg.get('notification_id'))], read=True, context=request.context) return True @@ -292,11 +292,12 @@ class website_forum(http.Controller): 'searches': {}, 'forum': forum, 'user': user, + 'ask_question': True, 'notifications': self._get_notifications(), } return request.website.render("website_forum.ask_question", values) - @http.route('/forum//question/ask/', type='http', auth="user", multilang=True, methods=['POST'], website=True) + @http.route('/forum//question/ask', type='http', auth="user", multilang=True, methods=['POST'], website=True) def register_question(self, forum, **question): cr, uid, context = request.cr, request.uid, request.context create_context = dict(context) @@ -305,7 +306,7 @@ class website_forum(http.Controller): tags = question.get('question_tags').strip('[]').replace('"','').split(",") question_tags = [] for tag in tags: - tag_ids = Tag.search(cr, uid, [('name', 'like', tag)], context=context) + tag_ids = Tag.search(cr, uid, [('name', '=', tag)], context=context) if tag_ids: question_tags.append((4,tag_ids[0])) else: @@ -323,7 +324,7 @@ class website_forum(http.Controller): }, context=create_context) return werkzeug.utils.redirect("/forum/%s/question/%s" % (slug(forum),new_question_id)) - @http.route('/forum//question/postanswer/', type='http', auth="public", multilang=True, methods=['POST'], website=True) + @http.route('/forum//question/postanswer', type='http', auth="public", multilang=True, methods=['POST'], website=True) def post_answer(self, forum , post_id, **question): if not request.session.uid: return login_redirect() @@ -395,12 +396,13 @@ class website_forum(http.Controller): tags = post.get('question_tag').strip('[]').replace('"','').split(",") question_tags = [] for tag in tags: - tag_ids = Tag.search(cr, uid, [('name', 'like', tag)], context=context) + tag_ids = Tag.search(cr, uid, [('name', '=', tag)], context=context) if tag_ids: - question_tags.append((6, 0, tag_ids)) + question_tags += tag_ids else: - question_tags.append((0,0,{'name' : tag,'forum_id' : forum.id})) - vals.update({'tags': question_tags, 'name': post.get('question_name')}) + 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')}) 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) @@ -471,7 +473,7 @@ class website_forum(http.Controller): return request.website.render("website_forum.users", values) - @http.route('/forum/post_vote/', type='json', auth="public", multilang=True, methods=['POST'], website=True) + @http.route('/forum/post_vote', type='json', auth="public", multilang=True, methods=['POST'], website=True) def post_vote(self, **post): if not request.session.uid: return {'error': 'anonymous_user'} @@ -479,7 +481,7 @@ class website_forum(http.Controller): Vote = request.registry['website.forum.post.vote'] return Vote.vote(cr, uid, post_id, post.get('vote'), context) - @http.route('/forum/post_delete/', type='json', auth="user", multilang=True, methods=['POST'], website=True) + @http.route('/forum/post_delete', type='json', auth="user", multilang=True, methods=['POST'], website=True) def delete_answer(self, **kwarg): request.registry['website.forum.post'].unlink(request.cr, request.uid, [int(kwarg.get('post_id'))], context=request.context) return True @@ -499,7 +501,7 @@ class website_forum(http.Controller): }, context=request.context) return werkzeug.utils.redirect("/forum/%s/question/%s" % (slug(forum),post.id)) - @http.route('/forum/message_delete/', type='json', auth="user", multilang=True, methods=['POST'], website=True) + @http.route('/forum/message_delete', type='json', auth="user", multilang=True, methods=['POST'], website=True) def delete_comment(self, **kwarg): request.registry['mail.message'].unlink(request.cr, SUPERUSER_ID, [int(kwarg.get('message_id'))], context=request.context) return True @@ -518,7 +520,7 @@ class website_forum(http.Controller): } return data - @http.route('/forum/correct_answer/', type='json', auth="public", multilang=True, methods=['POST'], website=True) + @http.route('/forum/correct_answer', type='json', auth="public", multilang=True, methods=['POST'], website=True) def correct_answer(self, **kwarg): cr, uid, context = request.cr, request.uid, request.context if not request.session.uid: @@ -556,7 +558,7 @@ class website_forum(http.Controller): } return request.website.render("website_forum.close_question", values) - @http.route('/forum//question/close/', type='http', auth="user", multilang=True, methods=['POST'], website=True) + @http.route('/forum//question/close', type='http', auth="user", multilang=True, methods=['POST'], website=True) def close(self, forum, **post): request.registry['website.forum.post'].write( request.cr, request.uid, [int(post.get('post_id'))], { 'state': 'close', @@ -588,7 +590,7 @@ class website_forum(http.Controller): } return request.website.render("website_forum.edit_profile", values) - @http.route('/forum//save/profile/', type='http', auth="user", multilang=True, website=True) + @http.route('/forum//save/profile', type='http', auth="user", multilang=True, website=True) def save_edited_profile(self, forum, **post): cr, uid, context = request.cr, request.uid, request.context user = request.registry['res.users'].browse(cr, uid, int(post.get('user_id')),context=context) @@ -605,7 +607,7 @@ class website_forum(http.Controller): @http.route('/forum//post//commet//converttoanswer', type='http', auth="public", multilang=True, website=True) def convert_to_answer(self, forum, post, comment, **kwarg): values = { - 'answer_content': comment.body, + 'content': comment.body, } request.registry['mail.message'].unlink(request.cr, request.uid, [comment.id], context=request.context) return self.post_answer(forum, post.parent_id and post.parent_id.id or post.id, **values) @@ -644,4 +646,3 @@ class website_forum(http.Controller): post_ids.append(post.id) request.registry['website.forum.post'].message_unsubscribe( cr, uid, post_ids, [partner_id], context=context) return werkzeug.utils.redirect("/forum/%s/question/%s" % (slug(forum),post.id)) - diff --git a/addons/website_forum/data/forum_default_faq.html b/addons/website_forum/data/forum_default_faq.html index 591417f02d1..8c6d32e43ed 100644 --- a/addons/website_forum/data/forum_default_faq.html +++ b/addons/website_forum/data/forum_default_faq.html @@ -1,5 +1,5 @@

Guidelines

-

What kinds of questions can I ask here?

+

What kinds of questions can I ask here?

This community is for professional and enthusiast users, partners and programmers. You can ask questions about: @@ -19,7 +19,7 @@ Please avoid asking questions that are too subjective and argumentative or not relevant to this community.

-

What should I avoid in my questions?

+

What should I avoid in my questions?

You should only ask practical, answerable questions based on actual problems that you face. Chatty, open-ended @@ -54,7 +54,7 @@

  • Answers shouldn't just provide a link a solution. Instead provide the solution description text in your answer, even if it's just a copy/paste. Links are welcome, but should complementary to answer, referring sources or additional reading.
  • -

    What should I avoid in my answers?

    +

    What should I avoid in my answers?

    Answers should not add or expand questions. Instead either edit the question or add a comment. @@ -132,7 +132,7 @@ -

    Why can other people edit my questions/answers?

    +

    Why can other people edit my questions/answers?

    The goal of this site is create a relevant knowledge base that would answer questions related to OpenERP. diff --git a/addons/website_forum/static/src/css/Makefile b/addons/website_forum/static/src/css/Makefile index 8d2edfb2ed2..867a1fedb38 100644 --- a/addons/website_forum/static/src/css/Makefile +++ b/addons/website_forum/static/src/css/Makefile @@ -1,2 +1,2 @@ sass: - sass --compass --unix-newlines -t expanded website_forum.sass:website_forum.css + sass --compass --unix-newlines -t expanded website_forum.sass:website_forum.css diff --git a/addons/website_forum/static/src/css/website_forum.css b/addons/website_forum/static/src/css/website_forum.css index b4c6e2315ac..e8f0978cc2e 100644 --- a/addons/website_forum/static/src/css/website_forum.css +++ b/addons/website_forum/static/src/css/website_forum.css @@ -45,6 +45,25 @@ color: #999 } +.load_tags{ + width: 845px !important; +} + +.fa-thumbs-up, .fa-thumbs-down, .oe_answer_true, .oe_answer_false { + cursor:pointer; +} + +.faq-question:hover { + text-decoration: none !important; + color: #428bca; +} + +.oe_comment_grey { + -moz-box-shadow: 0px 4px 6px 2px #eeeeee; + -webkit-box-shadow: 0px 4px 6px 2px #eeeeee; + box-shadow: 0px 4px 6px 2px #eeeeee; +} + .tag_text .text-core .text-wrap textarea, .tag_text .text-core .text-wrap input, .tag_text .text-core .text-wrap .text-dropdown, @@ -55,12 +74,4 @@ .tag_text .text-core .text-wrap .text-tags .text-tag .text-button { height: 1.2em !important; -} - -.load_tags{ - width: 845px !important; -} - -.fa-thumbs-up, .fa-thumbs-down, .oe_answer_true, .oe_answer_false { - cursor:pointer; } \ No newline at end of file diff --git a/addons/website_forum/static/src/js/website_forum.js b/addons/website_forum/static/src/js/website_forum.js index 2f950b58c23..f19d7a5aeea 100644 --- a/addons/website_forum/static/src/js/website_forum.js +++ b/addons/website_forum/static/src/js/website_forum.js @@ -5,7 +5,7 @@ $(document).ready(function () { var $link = $(ev.currentTarget); var value = $link.attr("value") - openerp.jsonRpc("/forum/post_vote/", 'call', { + openerp.jsonRpc("/forum/post_vote", 'call', { 'post_id': $link.attr("id"), 'vote': value}) .then(function (data) { @@ -52,7 +52,7 @@ $(document).ready(function () { $('.delete').on('click', function (ev) { ev.preventDefault(); var $link = $(ev.currentTarget); - openerp.jsonRpc("/forum/post_delete/", 'call', { + openerp.jsonRpc("/forum/post_delete", 'call', { 'post_id': $link.attr("id")}) .then(function (data) { $link.parents('#answer').remove(); @@ -60,10 +60,10 @@ $(document).ready(function () { return false; }); - $('.fa-check').on('click', function (ev) { + $('.fa-check-circle').on('click', function (ev) { ev.preventDefault(); var $link = $(ev.currentTarget); - openerp.jsonRpc("/forum/correct_answer/", 'call', { + openerp.jsonRpc("/forum/correct_answer", 'call', { 'post_id': $link.attr("id")}) .then(function (data) { if (data['error']) { @@ -93,7 +93,7 @@ $(document).ready(function () { $('.comment_delete').on('click', function (ev) { ev.preventDefault(); var $link = $(ev.currentTarget); - openerp.jsonRpc("/forum/message_delete/", 'call', { + openerp.jsonRpc("/forum/message_delete", 'call', { 'message_id': $link.attr("id")}) .then(function (data) { $link.parents('#comment').remove(); @@ -104,7 +104,7 @@ $(document).ready(function () { $('.notification_close').on('click', function (ev) { ev.preventDefault(); var $link = $(ev.currentTarget); - openerp.jsonRpc("/forum/notification_read/", 'call', { + openerp.jsonRpc("/forum/notification_read", 'call', { 'notification_id': $link.attr("id")}) return true; }); diff --git a/addons/website_forum/views/website_forum.xml b/addons/website_forum/views/website_forum.xml index f270ce30e63..86430d47f91 100644 --- a/addons/website_forum/views/website_forum.xml +++ b/addons/website_forum/views/website_forum.xml @@ -28,6 +28,7 @@

    +
    Answers
    Answer
    @@ -124,7 +125,7 @@
    - Ask a Question + Ask a Question
    @@ -273,7 +274,7 @@
  • provide enough details and, if possible, give an example
  • be clear and concise, avoid unnecessary introductions (Hi, ... Thanks...)
  • -
    +
    Please enter a descriptive question (should finish by a '?')
    @@ -333,7 +334,7 @@