[imp]:improve post history
bzr revid: sunilsharma.sharma07@gmail.com-20140328133404-e6vkg9f4rjm6qmp8
This commit is contained in:
parent
ec7f01c69d
commit
160f7fd3a8
|
@ -467,9 +467,13 @@ class website_forum(http.Controller):
|
|||
|
||||
@http.route('/forum/<model("website.forum"):forum>/edit/question/<model("website.forum.post"):post>', type='http', auth="user", multilang=True, website=True)
|
||||
def edit_question(self, forum, post, **kwarg):
|
||||
post_history_obj = request.registry['website.forum.post.history'];
|
||||
tags = ""
|
||||
for tag_name in post.tags:
|
||||
tags += tag_name.name + ","
|
||||
|
||||
ids = post_history_obj.search(request.cr, request.uid, [('post_id','=', post.id)], context=request.context)
|
||||
post_history = post_history_obj.browse(request.cr, request.uid, ids, context=request.context)
|
||||
|
||||
values = {
|
||||
'post': post,
|
||||
|
@ -477,6 +481,7 @@ class website_forum(http.Controller):
|
|||
'forum': forum,
|
||||
'searches': kwarg,
|
||||
'notifications': self._get_notifications(),
|
||||
'history': post_history,
|
||||
}
|
||||
return request.website.render("website_forum.edit_question", values)
|
||||
|
||||
|
@ -637,3 +642,9 @@ 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))
|
||||
|
||||
@http.route('/forum/change_question/', type='json', auth="user", multilang=True, methods=['POST'], website=True)
|
||||
def correct_answer(self, **kwarg):
|
||||
cr, uid, context = request.cr, request.uid, request.context
|
||||
return True
|
||||
|
||||
|
|
|
@ -227,9 +227,9 @@ class Post(osv.Model):
|
|||
return post_id
|
||||
|
||||
def write(self, cr, uid, ids, vals, context=None):
|
||||
self.create_history(cr, uid, ids, vals, context=context)
|
||||
#NOTE: to avoid message post on write of last comment time
|
||||
if not vals.get('message_last_post'):
|
||||
self.create_history(cr, uid, ids, vals, context=context)
|
||||
for post in self.browse(cr, uid, ids, context=context):
|
||||
body, subtype = "Edited question", "website_forum.mt_question_edit"
|
||||
if post.parent_id:
|
||||
|
|
|
@ -116,4 +116,13 @@ $(document).ready(function () {
|
|||
});
|
||||
};
|
||||
|
||||
$('.change_question').change(function (ev) {
|
||||
var $option = $(ev.currentTarget);
|
||||
openerp.jsonRpc("/forum/change_question/", 'call', {
|
||||
'option': $option.attr("id")})
|
||||
.then(function (data) {
|
||||
})
|
||||
return true;
|
||||
});
|
||||
|
||||
});
|
|
@ -295,6 +295,11 @@
|
|||
<t t-call="website_forum.header">
|
||||
<h3>Edit question</h3>
|
||||
<form t-attf-action="/forum/#{ slug(forum) }/question/savequestion/" method="post" role="form" class="tag_text">
|
||||
<select class="form-control change_question" id="change_que">
|
||||
<t t-foreach="history" t-as="history_post">
|
||||
<option t-att-value="history_post.id"><t t-esc="history_post.name"/></option>
|
||||
</t>
|
||||
</select>
|
||||
<input type="text" name="question_name" required="True" t-attf-value="#{post.name or ''}"
|
||||
class="form-control" placeholder="Edit your Question"/>
|
||||
<h5 class="mt20">Please enter a descriptive question (should finish by a '?')</h5>
|
||||
|
|
Loading…
Reference in New Issue