[FIX] website_forum:
authorJeremy Kersten <jke@odoo.com>
Tue, 18 Nov 2014 13:31:36 +0000 (14:31 +0100)
committerJeremy Kersten <jke@odoo.com>
Tue, 18 Nov 2014 13:31:36 +0000 (14:31 +0100)
   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

addons/website_forum/controllers/main.py
addons/website_forum/static/src/js/website_forum.js

index 95e604a..03416f4 100644 (file)
@@ -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,
index 49aa2fc..3e632e3 100644 (file)
@@ -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)');
-}