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)
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 = []
})
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:
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
# --------------------------------------------------
}, 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
'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):
<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>