diff options
| author | Thibault Delavallée <tde@openerp.com> | 2014-04-11 18:19:16 +0200 |
|---|---|---|
| committer | Thibault Delavallée <tde@openerp.com> | 2014-04-11 18:19:16 +0200 |
| commit | b6a1359b4f9d7015d8ea06e3b8d1a3741fd24555 (patch) | |
| tree | d2e8b632a11876c88be7f6e3a6cd6e682c21c300 | |
| parent | 907a97b15b789967a83ea39a8bf39f92640739a5 (diff) | |
[FIX] website_forum: convert comment to post is back and works
bzr revid: tde@openerp.com-20140411161916-rlobfxosniii66m4
| -rw-r--r-- | addons/website_forum/controllers/main.py | 45 | ||||
| -rw-r--r-- | addons/website_forum/static/src/css/website_forum.css | 3 | ||||
| -rw-r--r-- | addons/website_forum/static/src/css/website_forum.sass | 3 | ||||
| -rw-r--r-- | addons/website_forum/views/website_forum.xml | 16 |
4 files changed, 38 insertions, 29 deletions
diff --git a/addons/website_forum/controllers/main.py b/addons/website_forum/controllers/main.py index 4ed78147b8e..0964c9e5f1a 100644 --- a/addons/website_forum/controllers/main.py +++ b/addons/website_forum/controllers/main.py @@ -115,7 +115,7 @@ class WebsiteForum(http.Controller): return request.website.render("website_forum.forum_index", values) @http.route(['/forum/<model("forum.forum"):forum>/faq'], type='http', auth="public", website=True, multilang=True) - def faq(self, forum, **post): + def forum_faq(self, forum, **post): values = self._prepare_forum_values(forum=forum, searches=dict(), **post) return request.website.render("website_forum.faq", values) @@ -148,7 +148,7 @@ class WebsiteForum(http.Controller): return request.website.render("website_forum.ask_question", values) @http.route('/forum/<model("forum.forum"):forum>/question/new', type='http', auth="user", multilang=True, methods=['POST'], website=True) - def register_question(self, forum, **post): + def question_create(self, forum, **post): cr, uid, context = request.cr, request.uid, request.context Tag = request.registry['forum.tag'] question_tag_ids = [] @@ -186,23 +186,6 @@ class WebsiteForum(http.Controller): }) return request.website.render("website_forum.post_description_full", values) - @http.route('/forum/<model("forum.forum"):forum>/post/<model("forum.post"):post>/comment', type='http', auth="public", methods=['POST'], website=True) - def post_comment(self, forum, post, **kwargs): - # tde: fix post / question - if not request.session.uid: - return login_redirect() - cr, uid, context = request.cr, request.uid, request.context - if kwargs.get('comment'): - # TDE FIXME: check that post_id is the question or one of its answers - if request.registry['res.users'].has_group(cr, uid, 'website_mail.group_comment'): - request.registry['forum.post'].message_post( - cr, uid, post.id, - body=kwargs.get('comment'), - type='comment', - subtype='mt_comment', - context=dict(context, mail_create_nosubcribe=True)) - return werkzeug.utils.redirect("/forum/%s/question/%s" % (slug(forum), slug(post))) - @http.route('/forum/<int:forum_id>/question/<int:question_id>/toggle_favourite', type='json', auth="user", multilang=True, website=True) def question_toggle_favorite_tmp(self, forum_id, question_id, **post): if not request.session.uid: @@ -281,6 +264,9 @@ class WebsiteForum(http.Controller): request.registry['forum.post'].write(request.cr, request.uid, [question.id], {'active': True}, context=request.context) return werkzeug.utils.redirect("/forum/%s/question/%s" % (slug(forum), slug(question))) + # Answers + # -------------------------------------------------- + # Post # -------------------------------------------------- @@ -296,6 +282,24 @@ class WebsiteForum(http.Controller): }, context=request.context) return werkzeug.utils.redirect("/forum/%s/question/%s" % (slug(forum), slug(post))) + @http.route('/forum/<model("forum.forum"):forum>/post/<model("forum.post"):post>/comment', type='http', auth="public", methods=['POST'], website=True) + def post_comment(self, forum, post, **kwargs): + # tde: fix post / question + if not request.session.uid: + return login_redirect() + question = post.parent_id if post.parent_id else post + cr, uid, context = request.cr, request.uid, request.context + if kwargs.get('comment') and post.forum_id.id == forum.id: + # TDE FIXME: check that post_id is the question or one of its answers + if request.registry['res.users'].has_group(cr, uid, 'website_mail.group_comment'): + request.registry['forum.post'].message_post( + cr, uid, post.id, + body=kwargs.get('comment'), + type='comment', + subtype='mt_comment', + context=dict(context, mail_create_nosubcribe=True)) + return werkzeug.utils.redirect("/forum/%s/question/%s" % (slug(forum), slug(question))) + @http.route('/forum/<model("forum.forum"):forum>/post/<model("forum.post"):post>/toggle_correct', type='json', auth="public", website=True) def post_toggle_correct(self, forum, post, **kwargs): cr, uid, context = request.cr, request.uid, request.context @@ -563,7 +567,8 @@ class WebsiteForum(http.Controller): '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) + question = post.parent_id if post.parent_id else post + return self.post_new(forum, question, **values) @http.route('/forum/<model("forum.forum"):forum>/post/<model("forum.post"):post>/convert_to_comment', type='http', auth="user", multilang=True, website=True) def convert_answer_to_comment(self, forum, post, **kwarg): diff --git a/addons/website_forum/static/src/css/website_forum.css b/addons/website_forum/static/src/css/website_forum.css index e83242c1484..1155ded81aa 100644 --- a/addons/website_forum/static/src/css/website_forum.css +++ b/addons/website_forum/static/src/css/website_forum.css @@ -63,7 +63,8 @@ a.no-decoration { } .oe_comment_grey { - color: whitesmoke; + background-color: whitesmoke; + padding: 4px; } .country_flag { diff --git a/addons/website_forum/static/src/css/website_forum.sass b/addons/website_forum/static/src/css/website_forum.sass index d3c239b7dc4..f5bfb667b74 100644 --- a/addons/website_forum/static/src/css/website_forum.sass +++ b/addons/website_forum/static/src/css/website_forum.sass @@ -50,7 +50,8 @@ a.no-decoration color: #428bca .oe_comment_grey - color: #f5f5f5 + background-color: #f5f5f5 + padding: 4px .country_flag max-height: 16px diff --git a/addons/website_forum/views/website_forum.xml b/addons/website_forum/views/website_forum.xml index eb09d518e7d..90bff158412 100644 --- a/addons/website_forum/views/website_forum.xml +++ b/addons/website_forum/views/website_forum.xml @@ -542,19 +542,21 @@ <template id="post_comment"> <div class="row clearfix"> <div class="col-sm-10 col-sm-offset-2"> - <div t-foreach="reversed(object.website_message_ids)" t-as="message" id="comment" class="oe_comment_grey" style="padding: 4px;"> + <div t-foreach="reversed(object.website_message_ids)" t-as="message" id="comment" class="oe_comment_grey mb8"> <small class="text-muted"> - <button type="button" t-if="user.karma>=750" t-att-id="message.id" class="close comment_delete">&times;</button> + <button type="button" t-if="user.partner_id.id == message.author_id.id and user.karma>=750" t-att-id="message.id" class="close comment_delete">&times;</button> <span t-field="message.body"/> - <a t-attf-href="/forum/#{slug(forum)}/user/#{message.id}" - t-field="message.author_id" t-field-options='{"widget": "contact", "country_image": true, "fields": ["name", "country_id"]}' - style="display: inline-block;"/> - on <span t-field="message.date" t-field-options='{"format":"short"}'/> + <a t-attf-href="/forum/#{slug(forum)}/user/#{message.id}" + t-field="message.author_id" t-field-options='{"widget": "contact", "country_image": true, "fields": ["name", "country_id"]}' + style="display: inline-block;"/> + on <span t-field="message.date" t-field-options='{"format":"short"}'/> + <a class="fa fa-magic text-muted pull-right" + t-attf-href="/forum/#{slug(forum)}/post/#{slug(object)}/comment/#{slug(message)}/convert_to_answer">Convert as an answer</a> </small> </div> <div class="css_editable_mode_hidden"> <form t-attf-id="comment#{ object._name.replace('.','') + '-' + str(object.id) }" class="collapse" - t-attf-action="/forum/#{slug(forum)}/question/#{slug(object)}/comment" method="POST"> + t-attf-action="/forum/#{slug(forum)}/post/#{slug(object)}/comment" method="POST"> <input name="post_id" t-att-value="object.id" type="hidden"/> <textarea name="comment" class="form-control" placeholder="Comment this post..."/> <button type="submit" class="btn btn-primary mt8">Post</button> |
