[FIX] website_forum: people having enough karma can accepts answers on every question, not just their own. Fixed the condition computation.
This commit is contained in:
parent
de9654deec
commit
907862655a
|
@ -346,10 +346,10 @@ class WebsiteForum(http.Controller):
|
|||
if not request.session.uid:
|
||||
return {'error': 'anonymous_user'}
|
||||
user = request.registry['res.users'].browse(request.cr, SUPERUSER_ID, request.uid, context=request.context)
|
||||
if post.parent_id.create_uid.id != uid:
|
||||
return {'error': 'own_post'}
|
||||
if post.parent_id.create_uid.id != uid and user.karma < request.registry['forum.forum']._karma_answer_accept_all:
|
||||
return {'error': 'not_enough_karma', 'karma': request.registry['forum.forum']._karma_answer_accept_all}
|
||||
if post.create_uid.id == user.id and user.karma < request.registry['forum.forum']._karma_answer_accept_own:
|
||||
return {'error': 'not_enough_karma', 'karma': 20}
|
||||
return {'error': 'not_enough_karma', 'karma': request.registry['forum.forum']._karma_answer_accept_own}
|
||||
|
||||
# set all answers to False, only one can be accepted
|
||||
request.registry['forum.post'].write(cr, uid, [c.id for c in post.parent_id.child_ids], {'is_correct': False}, context=context)
|
||||
|
|
|
@ -54,15 +54,10 @@ $(document).ready(function () {
|
|||
'<button type="button" class="close notification_close" data-dismiss="alert" aria-hidden="true">×</button>'+
|
||||
'Sorry, anonymous users cannot choose correct answer.'+
|
||||
'</div>');
|
||||
} else if (data['error'] == 'own_post'){
|
||||
var $warning = $('<div class="alert alert-danger alert-dismissable" id="correct_answer_alert" style="position:absolute; margin-top: -30px; margin-left: 90px;">'+
|
||||
'<button type="button" class="close notification_close" data-dismiss="alert" aria-hidden="true">×</button>'+
|
||||
'Sorry, only the user who asked this question can accept the answer as correct.'+
|
||||
'</div>');
|
||||
} else if (data['error'] == 'not_enough_karma') {
|
||||
var $warning = $('<div class="alert alert-danger alert-dismissable" id="vote_alert" style="max-width: 500px; position:absolute; margin-top: -30px; margin-left: 90px;">'+
|
||||
'<button type="button" class="close notification_close" data-dismiss="alert" aria-hidden="true">×</button>'+
|
||||
'Sorry, at least ' + data['karma'] + ' karma is required to accept your own answers. You can gain karma by answering questions and receiving votes.'+
|
||||
'Sorry, at least ' + data['karma'] + ' karma is required to accept this answer. You can gain karma by answering questions and receiving votes.'+
|
||||
'</div>');
|
||||
}
|
||||
correct_answer_alert = $link.parent().find("#correct_answer_alert");
|
||||
|
|
Loading…
Reference in New Issue