[FIX] website_forum:
Use if_dom_contains to check if we need to load js Fix bug where _tag_to_write_vals was called like old API but model converter was new api Move IsKarmaValid and Load CKE only in website_forum context
This commit is contained in:
parent
d80f2a716b
commit
3288f07eaa
|
@ -223,7 +223,7 @@ class WebsiteForum(http.Controller):
|
|||
else:
|
||||
question_tag_ids.append((0, 0, {'name': tag, 'forum_id': forum.id}))
|
||||
elif tag_version == "select2":
|
||||
question_tag_ids = forum._tag_to_write_vals(cr, uid, post.get('question_tags', ''), context=context)
|
||||
question_tag_ids = forum._tag_to_write_vals(post.get('question_tags', ''))
|
||||
|
||||
new_question_id = request.registry['forum.post'].create(
|
||||
request.cr, request.uid, {
|
||||
|
@ -413,7 +413,7 @@ class WebsiteForum(http.Controller):
|
|||
question_tags.append(new_tag)
|
||||
tags_val = [(6, 0, question_tags)]
|
||||
elif tag_version == "select2": # new version
|
||||
tags_val = forum._tag_to_write_vals(cr, uid, kwargs.get('question_tag', ''), context=context)
|
||||
tags_val = forum._tag_to_write_vals(kwargs.get('question_tag', ''))
|
||||
|
||||
vals = {
|
||||
'tag_ids': tags_val,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
$(document).ready(function () {
|
||||
if ($('.website_forum').length){
|
||||
openerp.website.if_dom_contains('.website_forum', function () {
|
||||
$('.karma_required').on('click', function (ev) {
|
||||
var karma = $(ev.currentTarget).data('karma');
|
||||
if (karma) {
|
||||
|
@ -217,24 +217,24 @@ $(document).ready(function () {
|
|||
var editor = CKEDITOR.instances['content'];
|
||||
editor.on('instanceReady', CKEDITORLoadComplete);
|
||||
}
|
||||
}
|
||||
|
||||
IsKarmaValid = function(eventNumber, minKarma){
|
||||
"use strict";
|
||||
if(parseInt($("#karma").val()) >= minKarma){
|
||||
CKEDITOR.tools.callFunction(eventNumber,this);
|
||||
return false;
|
||||
} else {
|
||||
alert("Sorry you need more than " + minKarma + " Karma.");
|
||||
}
|
||||
};
|
||||
|
||||
CKEDITORLoadComplete = function(){
|
||||
"use strict";
|
||||
$('.cke_button__link').attr('onclick','IsKarmaValid(33,30)');
|
||||
$('.cke_button__unlink').attr('onclick','IsKarmaValid(37,30)');
|
||||
$('.cke_button__image').attr('onclick','IsKarmaValid(41,30)');
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
function IsKarmaValid(eventNumber,minKarma){
|
||||
"use strict";
|
||||
if(parseInt($("#karma").val()) >= minKarma){
|
||||
CKEDITOR.tools.callFunction(eventNumber,this);
|
||||
return false;
|
||||
} else {
|
||||
alert("Sorry you need more than " + minKarma + " Karma.");
|
||||
}
|
||||
}
|
||||
|
||||
function CKEDITORLoadComplete(){
|
||||
"use strict";
|
||||
$('.cke_button__link').attr('onclick','IsKarmaValid(33,30)');
|
||||
$('.cke_button__unlink').attr('onclick','IsKarmaValid(37,30)');
|
||||
$('.cke_button__image').attr('onclick','IsKarmaValid(41,30)');
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue