[imp]:improve delete question and answer via menu
bzr revid: sunilsharma.sharma07@gmail.com-20140311091228-dch3p1vwjd3jfxyx
This commit is contained in:
parent
99de16334c
commit
53c7fa165d
|
@ -331,3 +331,17 @@ class website_forum(http.Controller):
|
|||
record = Post.browse(cr, uid, post_id, context=context)
|
||||
|
||||
return record.vote_count
|
||||
|
||||
@http.route('/forum/post_delete/', type='json', auth="user", multilang=True, methods=['POST'], website=True)
|
||||
def delete_answer(self, **kwarg):
|
||||
cr, uid, context = request.cr, request.uid, request.context
|
||||
Post = request.registry['website.forum.post']
|
||||
Post.unlink(cr, uid, [int(kwarg.get('post_id'))], context=context)
|
||||
return True
|
||||
|
||||
@http.route('/forum/<model("website.forum"):forum>/delete/question/<model("website.forum.post"):post>', type='http', auth="user", multilang=True, website=True)
|
||||
def delete_question(self, forum, post, **kwarg):
|
||||
cr, uid, context = request.cr, request.uid, request.context
|
||||
Post = request.registry['website.forum.post']
|
||||
Post.unlink(cr, uid, [post.id], context=context)
|
||||
return werkzeug.utils.redirect("/forum/%s/" % (slug(forum)))
|
||||
|
|
|
@ -106,7 +106,7 @@ class Post(osv.Model):
|
|||
'active': fields.boolean('Active'),
|
||||
'views': fields.integer('Page Views'),
|
||||
|
||||
'parent_id': fields.many2one('website.forum.post', 'Question'),
|
||||
'parent_id': fields.many2one('website.forum.post', 'Question', ondelete='cascade'),
|
||||
'child_ids': fields.one2many('website.forum.post', 'parent_id', 'Answers'),
|
||||
|
||||
'history_ids': fields.one2many('blog.post.history', 'post_id', 'History', help='Last post modifications'),
|
||||
|
|
|
@ -55,4 +55,17 @@ $(document).ready(function () {
|
|||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.delete').on('click', function (ev) {
|
||||
ev.preventDefault();
|
||||
var $link = $(ev.currentTarget);
|
||||
var value = $link.attr("value")
|
||||
openerp.jsonRpc("/forum/post_delete/", 'call', {
|
||||
'post_id': $link.attr("id")})
|
||||
.then(function (data) {
|
||||
$link.parents('#answer').remove();
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
});
|
|
@ -322,7 +322,7 @@
|
|||
</a>
|
||||
</li>
|
||||
<li><a class="text-muted" href="">edit</a></li>
|
||||
<li><a class="text-muted" href="">delete</a></li>
|
||||
<li><a class="text-muted" t-attf-href="/forum/#{ slug(forum) }/delete/question/#{ question.id }">delete</a></li>
|
||||
<li><a class="text-muted" href="">share</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -338,7 +338,7 @@
|
|||
</div>
|
||||
<hr/>
|
||||
|
||||
<div t-foreach="question.child_ids" t-as="answer" class="mt16 mb32">
|
||||
<div t-foreach="question.child_ids" t-as="answer" class="mt16 mb32" id="answer">
|
||||
<div class="text-center pull-left">
|
||||
<div t-attf-class="box oe_grey">
|
||||
<a t-attf-class="fa fa-thumbs-up #{answer.user_vote == 1 and 'text-success' or ''}"
|
||||
|
@ -365,7 +365,7 @@
|
|||
</a>
|
||||
</li>
|
||||
<li><a class="text-muted" href="">edit</a></li>
|
||||
<li><a class="text-muted" href="">delete</a></li>
|
||||
<li><a class="text-muted delete" href="" t-attf-id="#{answer.id}">delete</a></li>
|
||||
<li><a class="text-muted" href="">share</a></li>
|
||||
</ul>
|
||||
<t t-set="user" t-value="answer.create_uid"/>
|
||||
|
|
Loading…
Reference in New Issue